Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.EventQueue;
- import javax.swing.JFrame;
- import java.awt.Color;
- import javax.swing.JButton;
- import java.awt.Font;
- import java.awt.event.ActionListener;
- import java.awt.event.ActionEvent;
- import javax.swing.JTextField;
- import javax.swing.JLabel;
- public class Assignment1 {
- private JFrame frame;
- private JLabel lblBalls;
- private JLabel lblStrickes;
- /**
- * Launch the application.
- */
- public static void main(String[] args) {
- EventQueue.invokeLater(new Runnable() {
- public void run() {
- try {
- Assignment1 window = new Assignment1 ();
- window.frame.setVisible(true);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- });
- }
- /**
- * Create the application.
- */
- public Assignment1 () {
- initialize();
- }
- /**
- * Initialize the contents of the frame.
- */
- private void initialize() {
- frame = new JFrame();
- frame.getContentPane().setBackground(Color.MAGENTA);
- frame.setBounds(100, 100, 678, 415);
- frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- frame.getContentPane().setLayout(null);
- JButton btnNewButton = new JButton(" Add Balls");
- btnNewButton.addActionListener(new ActionListener() {
- int Add_Balls=0;
- public void actionPerformed(ActionEvent e) {
- Add_Balls++;
- lblBalls.setText("Balls:"+Add_Balls);
- }
- });
- btnNewButton.setFont(new Font("Tahoma", Font.BOLD | Font.ITALIC, 16));
- btnNewButton.setForeground(Color.RED);
- btnNewButton.setBackground(Color.PINK);
- btnNewButton.setBounds(160, 227, 125, 32);
- frame.getContentPane().add(btnNewButton);
- JButton btnNewButton_1 = new JButton(" Add Strickes");
- btnNewButton_1.addActionListener(new ActionListener() {
- int Add_Strickes=0;
- public void actionPerformed(ActionEvent e) {
- Add_Strickes++;
- lblStrickes.setText("Strickes:"+Add_Strickes);
- }
- });
- btnNewButton_1.setForeground(Color.RED);
- btnNewButton_1.setFont(new Font("Tahoma", Font.BOLD | Font.ITALIC, 16));
- btnNewButton_1.setBackground(Color.PINK);
- btnNewButton_1.setBounds(372, 227, 153, 32);
- frame.getContentPane().add(btnNewButton_1);
- lblBalls = new JLabel("Balls:");
- lblBalls.setFont(new Font("Tahoma", Font.BOLD | Font.ITALIC, 16));
- lblBalls.setBackground(new Color(240, 240, 240));
- lblBalls.setForeground(Color.BLACK);
- lblBalls.setBounds(160, 71, 153, 41);
- frame.getContentPane().add(lblBalls);
- lblStrickes = new JLabel("Strickes:");
- lblStrickes.setFont(new Font("Tahoma", Font.BOLD | Font.ITALIC, 16));
- lblStrickes.setBounds(160, 123, 163, 32);
- frame.getContentPane().add(lblStrickes);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement