1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
| public class Fenetre extends JFrame{
private JPanel accueil = new JPanel();
private JPanel page1 = new JPanel();
private JLabel label = new JLabel("TEST");
private JButton b = new JButton ("Jouer");
public Fenetre(){
this.setTitle("TEST");
this.setSize(1000,800);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setLocationRelativeTo(null);
this.setVisible(true);
accueil.setLayout(null);
accueil.setBackground(Color.white);
Font police = new Font("Arial", Font.BOLD, 22);
label.setFont(police);
label.setForeground(Color.ORANGE);
label.setBounds(this.getWidth()/2-75, this.getHeight()/2-105, 200, 75);
b.addActionListener(new BoutonListener());
b.setForeground(Color.blue);
b.setBackground(Color.orange);
b.setBounds(this.getWidth()/2-75, this.getHeight()/4*3, 100, 60);
accueil.add(b);
accueil.add(label);
this.setContentPane(accueil);
}
public void changerMenu(){
this.setContentPane(this.page1);
this.revalidate();
this.repaint();
}
public void PaintComponent(Graphics g){
System.out.println("Dans paint componenent");
//Colonnes
g.drawLine(this.getWidth()/15,0,this.getWidth()/15,this.getHeight());
g.drawLine(this.getWidth()/15*2,0,this.getWidth()/15*2,this.getHeight());
g.drawLine(this.getWidth()/15*3,0,this.getWidth()/15*3,this.getHeight());
g.drawLine(this.getWidth()/15*4,0,this.getWidth()/15*4,this.getHeight());
g.drawLine(this.getWidth()/15*5,0,this.getWidth()/15*5,this.getHeight());
g.drawLine(this.getWidth()/15*6,0,this.getWidth()/15*6,this.getHeight());
g.drawLine(this.getWidth()/15*7,0,this.getWidth()/15*7,this.getHeight());
g.drawLine(this.getWidth()/15*8,0,this.getWidth()/15*8,this.getHeight());
g.drawLine(this.getWidth()/15*9,0,this.getWidth()/15*9,this.getHeight());
g.drawLine(this.getWidth()/15*10,0,this.getWidth()/15*10,this.getHeight());
g.drawLine(this.getWidth()/15*11,0,this.getWidth()/15*11,this.getHeight());
g.drawLine(this.getWidth()/15*12,0,this.getWidth()/15*12,this.getHeight());
g.drawLine(this.getWidth()/15*13,0,this.getWidth()/15*13,this.getHeight());
//Lignes
g.drawLine(0, this.getHeight()/15, this.getWidth(), this.getHeight()/15);
g.drawLine(0, this.getHeight()/15*2, this.getWidth(), this.getHeight()/15*2);
g.drawLine(0, this.getHeight()/15*3, this.getWidth(), this.getHeight()/15*3);
g.drawLine(0, this.getHeight()/15*4, this.getWidth(), this.getHeight()/15*4);
g.drawLine(0, this.getHeight()/15*5, this.getWidth(), this.getHeight()/15*5);
g.drawLine(0, this.getHeight()/15*6, this.getWidth(), this.getHeight()/15*6);
g.drawLine(0, this.getHeight()/15*7, this.getWidth(), this.getHeight()/15*7);
g.drawLine(0, this.getHeight()/15*8, this.getWidth(), this.getHeight()/15*8);
g.drawLine(0, this.getHeight()/15*9, this.getWidth(), this.getHeight()/15*9);
g.drawLine(0, this.getHeight()/15*10, this.getWidth(), this.getHeight()/15*10);
g.drawLine(0, this.getHeight()/15*11, this.getWidth(), this.getHeight()/15*11);
g.drawLine(0, this.getHeight()/15*12, this.getWidth(), this.getHeight()/15*12);
g.drawLine(0, this.getHeight()/15*13, this.getWidth(), this.getHeight()/15*13);
g.drawLine(0, this.getHeight()/15*14, this.getWidth(), this.getHeight()/15*14);
page1.paint(g);
}
class BoutonListener implements ActionListener{
@Override
public void actionPerformed(ActionEvent arg0) {
// TODO Auto-generated method stub
Fenetre.this.changerMenu();
}
} |
Partager