Advertisement
Guest User

GUI - tictactoe

a guest
May 22nd, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.25 KB | None | 0 0
  1. import java.awt.*;
  2. import java.awt.event.*;
  3. import javax.swing.*;
  4. import java.awt.GridLayout.*;
  5.  
  6. public class GUI extends JFrame implements ActionListener {
  7.  
  8.  
  9.     public GUI() {
  10.         this.setBounds(0, 0,800, 800);
  11.         this.setTitle("TicTacToe");
  12.         FlowLayout f = new FlowLayout();
  13.         this.setLayout(f);
  14.  
  15.         JLabel image = new JLabel("");
  16.         image.setIcon(new ImageIcon("src/Tic-Tac-Toe.png")); //endre bildenavn og evt. plassering
  17.         image.setLocation(0, 0);
  18.         image.setSize(800, 800);
  19.         this.add(image);
  20.  
  21.  
  22.         JButton knapp = new JButton();
  23.         knapp.addActionListener(this);
  24.  
  25.         //knapp 1
  26.         knapp.setText("1 player");
  27.         setVisible(true);
  28.         this.add(knapp);
  29.         knapp.addActionListener(this);
  30.         knapp.setBounds(200, 300, 500, 500);
  31.  
  32.  
  33.         //knapp 2
  34.         JButton knapp2 = new JButton();
  35.         knapp2.setText(" 2 player");
  36.         this.add(knapp2);
  37.         knapp2.addActionListener(this);
  38.         knapp2.setBounds(200, 200, 500, 500);
  39.  
  40.         this.setVisible(true);
  41.  
  42.  
  43.     }
  44.  
  45.     @Override
  46.     public void actionPerformed(ActionEvent actionarg0) {
  47.  
  48.     }
  49.  
  50.     public static void main(String[] args) {
  51.         GUI g = new GUI();
  52.     }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement