Advertisement
0rioNN

Untitled

May 18th, 2014
331
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1. package chessgame;
  2.  
  3. import javax.swing.*;
  4.  
  5. import java.awt.*;
  6. import java.awt.event.*;
  7.  
  8. public class Chess{
  9.  
  10. private JFrame f;
  11. private JPanel p_inicio;
  12. private JButton b1;
  13. private JLabel lab;
  14.  
  15.  
  16.  
  17. public Chess(){
  18.  
  19. gui();
  20.  
  21. }
  22.  
  23. public void gui(){
  24.  
  25. f = new JFrame("Jogo de Xadrez");
  26. f.setVisible(true);
  27. f.setSize(600,600);
  28. f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  29.  
  30.  
  31. p_inicio = new JPanel();
  32. p_inicio.setBackground(Color.GRAY);
  33.  
  34.  
  35. b1 = new JButton("Player 1 VS Player 2");
  36. b1.addActionListener(new comecar());
  37.  
  38. lab = new JLabel("Jogo de Xadrez em Java");
  39.  
  40.  
  41. p_inicio.add(lab);
  42. p_inicio.add(b1);
  43.  
  44.  
  45.  
  46. f.add(p_inicio);
  47.  
  48.  
  49. }
  50.  
  51.  
  52. static class comecar implements ActionListener{
  53.  
  54. public void actionPerformed (ActionEvent e){
  55.  
  56.  
  57. JFrame f_nome = new JFrame ("Jogo de Xadrez");
  58. f_nome.setSize(600,600);
  59. f_nome.setVisible(true);
  60. f_nome.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  61.  
  62. JPanel p_nome = new JPanel();
  63. p_nome.setBackground(Color.GRAY);
  64.  
  65. JLabel l_nome = new JLabel ("Insira o nome do Player 1 do PLayer2");
  66. JButton b_nome = new JButton ("JOGAR");
  67. JTextField t_p1 = new JTextField( "Player 1");
  68. JTextField t_p2 = new JTextField( "Player 2");
  69.  
  70.  
  71. f_nome.add(p_nome);
  72.  
  73. p_nome.add(l_nome);
  74. p_nome.add(b_nome);
  75. p_nome.add(t_p1);
  76. p_nome.add(t_p2);
  77.  
  78.  
  79. }
  80. }
  81.  
  82.  
  83.  
  84.  
  85.  
  86.  
  87.  
  88.  
  89. public static void main (String [] args){
  90.  
  91. new Chess();
  92. }
  93.  
  94.  
  95. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement