Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package chessgame;
- import javax.swing.*;
- import java.awt.*;
- import java.awt.event.*;
- public class Chess {
- private JFrame f;
- private JPanel p_inicio;
- private JButton b1;
- private JLabel lab;
- public Chess(){
- gui();
- }
- public void gui(){
- f = new JFrame("Jogo de Xadrez");
- f.setVisible(true);
- f.setSize(600,600);
- f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- p_inicio = new JPanel();
- p_inicio.setBackground(Color.GRAY);
- b1 = new JButton("Player 1 VS Player 2");
- b1.addActionListener(new começar());
- lab = new JLabel("Jogo de Xadrez em Java");
- p_inicio.add(lab);
- p_inicio.add(b1);
- f.add(p_inicio);
- }
- static class começar implements ActionListener{
- public void actionPerformed (ActionEvent e){
- JFrame f_nome = new JFrame ("Jogo de Xadrez");
- f_nome.setSize(600,600);
- f_nome.setVisible(true);
- f_nome.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- JPanel p_nome = new JPanel();
- p_nome.setBackground(Color.LIGHT_GRAY);
- JLabel l_nome = new JLabel ("Insira o nome do Player 1 do PLayer2");
- JButton b_nome = new JButton ("JOGAR");
- f_nome.add(p_nome);
- p_nome.add(l_nome);
- p_nome.add(b_nome);
- }
- }
- public static void main (String [] args){
- new Chess();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement