Advertisement
Miti059

pocha mioti

Jan 20th, 2020
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.11 KB | None | 0 0
  1. import java.awt.EventQueue;
  2.  
  3. import javax.swing.JFrame;
  4. import java.awt.Color;
  5. import javax.swing.JButton;
  6. import java.awt.Font;
  7. import java.awt.event.ActionListener;
  8. import java.awt.event.ActionEvent;
  9. import javax.swing.JTextField;
  10. import javax.swing.JLabel;
  11.  
  12. public class Assignment1 {
  13.  
  14.     private JFrame frame;
  15.     private JLabel lblBalls;
  16.     private JLabel lblStrickes;
  17.     /**
  18.      * Launch the application.
  19.      */
  20.     public static void main(String[] args) {
  21.         EventQueue.invokeLater(new Runnable() {
  22.             public void run() {
  23.                 try {
  24.                     Assignment1 window = new Assignment1 ();
  25.                     window.frame.setVisible(true);
  26.                 } catch (Exception e) {
  27.                     e.printStackTrace();
  28.                 }
  29.             }
  30.         });
  31.     }
  32.  
  33.     /**
  34.      * Create the application.
  35.      */
  36.     public Assignment1 () {
  37.         initialize();
  38.     }
  39.  
  40.     /**
  41.      * Initialize the contents of the frame.
  42.      */
  43.     private void initialize() {
  44.         frame = new JFrame();
  45.         frame.getContentPane().setBackground(Color.MAGENTA);
  46.         frame.setBounds(100, 100, 678, 415);
  47.         frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  48.         frame.getContentPane().setLayout(null);
  49.        
  50.         JButton btnNewButton = new JButton(" Add Balls");
  51.         btnNewButton.addActionListener(new ActionListener() {
  52.             int Add_Balls=0;
  53.             public void actionPerformed(ActionEvent e) {
  54.                 Add_Balls++;
  55.                 lblBalls.setText("Balls:"+Add_Balls);
  56.                                  
  57.             }
  58.         });
  59.         btnNewButton.setFont(new Font("Tahoma", Font.BOLD | Font.ITALIC, 16));
  60.         btnNewButton.setForeground(Color.RED);
  61.         btnNewButton.setBackground(Color.PINK);
  62.         btnNewButton.setBounds(160, 227, 125, 32);
  63.         frame.getContentPane().add(btnNewButton);
  64.        
  65.         JButton btnNewButton_1 = new JButton(" Add Strickes");      
  66.         btnNewButton_1.addActionListener(new ActionListener() {
  67.             int Add_Strickes=0;
  68.             public void actionPerformed(ActionEvent e) {
  69.                 Add_Strickes++;
  70.                 lblStrickes.setText("Strickes:"+Add_Strickes);
  71.  
  72.  
  73.             }
  74.         });
  75.         btnNewButton_1.setForeground(Color.RED);
  76.         btnNewButton_1.setFont(new Font("Tahoma", Font.BOLD | Font.ITALIC, 16));
  77.         btnNewButton_1.setBackground(Color.PINK);
  78.         btnNewButton_1.setBounds(372, 227, 153, 32);
  79.         frame.getContentPane().add(btnNewButton_1);
  80.        
  81.         lblBalls = new JLabel("Balls:");
  82.         lblBalls.setFont(new Font("Tahoma", Font.BOLD | Font.ITALIC, 16));
  83.         lblBalls.setBackground(new Color(240, 240, 240));
  84.         lblBalls.setForeground(Color.BLACK);
  85.         lblBalls.setBounds(160, 71, 153, 41);
  86.         frame.getContentPane().add(lblBalls);
  87.        
  88.         lblStrickes = new JLabel("Strickes:");
  89.         lblStrickes.setFont(new Font("Tahoma", Font.BOLD | Font.ITALIC, 16));
  90.         lblStrickes.setBounds(160, 123, 163, 32);
  91.         frame.getContentPane().add(lblStrickes);
  92.     }
  93.  
  94. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement