Posts

HANGMAN GAME

import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.Random; public class Main extends JFrame { private static final String[] WORDS = { "HELLO" , "WORLD" , "COMPUTER" , "JAVA" , "PROGRAMMING" , "ECLIPSE" }; private static final int MAX_TRIES = 6 ; private String wordToGuess ; private char [] guessedLetters ; private int triesLeft ; private JLabel wordLabel ; private JLabel triesLabel ; private JTextField letterInput ; private JButton guessButton ; public Main () { setTitle( "Hangman Game" ); setDefaultCloseOperation(JFrame. EXIT_ON_CLOSE ); setSize( 400 , 300 ); setLocationRelativeTo( null ); // Center window on screen // Initialize game state wordToGuess = selectWord(); guessedLetters = new char [ wordToGuess .length()]; triesLeft = MAX_

Tic-Tac-Toe

  import  javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; public class Main extends JFrame implements ActionListener { private static final int SIZE = 3 ; private JButton[][] buttons = new JButton[ SIZE ][ SIZE ]; private boolean playerX = true ; private JLabel statusLabel ; public Main () { setTitle( "Tic Tac Toe Game" ); setSize( 400 , 400 ); setDefaultCloseOperation(JFrame. EXIT_ON_CLOSE ); setLayout( new BorderLayout()); JPanel titlePanel = new JPanel(); JLabel titleLabel = new JLabel( "Tic Tac Toe Game" ); titleLabel.setFont( new Font( "Arial" , Font. BOLD , 30 )); titlePanel.add(titleLabel); add(titlePanel, BorderLayout. NORTH ); JPanel panel = new JPanel(); panel.setLayout( new GridLayout( SIZE , SIZE )); for ( int i = 0 ; i < SIZE ; i++) { for ( int j = 0 ; j &l

ATM Machine Project

import  java.util.ArrayList; import java.awt.Color; import java.awt.Dimension; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.GridLayout; import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.JButton; import javax.swing.JComponent; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JPasswordField; import javax.swing.JTextField; /** * the main class * @author * */ class MainATM1 { public static void main (String[] args) { // create the ATM frame ATM atm = new ATM(); // set size and location atm.setSize( 700 , 400 ); atm.setLocation( 100 , 100 ); // make it visible atm.setVisible( true ); } } /** * class for implementing the ATM * @author * */ class ATM extends