daily pastebin goal
11%
SHARE
TWEET

Untitled

a guest May 16th, 2018 114 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     import java.awt.*;
  2.     import javax.swing.*;
  3.     import java.awt.event.*;
  4.      
  5.     public class Fenster{
  6.      
  7.     public Fenster(){
  8.     startFrame();
  9.     }
  10.      
  11.     public void startFrame(){
  12.      
  13.         /*Generate Frame*/
  14.         JFrame frame = new JFrame("Tic Tac Toe");
  15.         frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  16.         frame.setVisible(true);
  17.         frame.setSize(500,500);
  18.        
  19.         /*Generate Headline and add to frame*/
  20.         JLabel headline = new JLabel("Tic Tac Toe");
  21.         frame.add(BorderLayout.NORTH, headline);
  22.        
  23.         /*Generate Panel for Buttons*/
  24.         JPanel panel = new JPanel(new GridLayout(0,3));
  25.        
  26.         /*Generate Buttons*/
  27.         JButton b1 = new JButton("");
  28.         JButton b2 = new JButton("");
  29.         JButton b3 = new JButton("");
  30.         JButton b4 = new JButton("");
  31.         JButton b5 = new JButton("");
  32.         JButton b6 = new JButton("");
  33.         JButton b7 = new JButton("");
  34.         JButton b8 = new JButton("");
  35.         JButton b9 = new JButton("");
  36.         ActionListener al = new ActionListener() {
  37.             public void actionPerformed( ActionEvent e ) {
  38.             System.exit( 0 );
  39.          }
  40.         };
  41.         b1.addActionListener(al);
  42.         b1.setActionCommand("restart");
  43.        
  44.         /*Add Buttons to Panel*/
  45.         panel.add(b1);
  46.         panel.add(b2);
  47.         panel.add(b3);
  48.         panel.add(b4);
  49.         panel.add(b5);
  50.         panel.add(b6);
  51.         panel.add(b7);
  52.         panel.add(b8);
  53.         panel.add(b9);
  54.        
  55.         /*Add Panel to Frame*/
  56.         frame.add(BorderLayout.CENTER, panel);
  57.        
  58.     }
  59.    
  60.     public static void main(String[] args) {
  61.         Fenster f= new Fenster();
  62.     }
  63.      
  64.      
  65.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top