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 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228
|
import javax.swing.*;
import java.awt.event.* ;
import java.io.*;
public class MenuPrincipal extends JPanel implements MouseListener{
/** Creates new form Panel */
public MenuPrincipal() {
initComponents();
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
// <editor-fold defaultstate="collapsed" desc=" Generated Code ">
private void initComponents() {
jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
jButton3 = new javax.swing.JButton();
jButton4 = new javax.swing.JButton();
jButton5 = new javax.swing.JButton();
jButton6 = new javax.swing.JButton();
jButton7 = new javax.swing.JButton();
jButton8 = new javax.swing.JButton();
jButton9 = new javax.swing.JButton();
jButton10 = new javax.swing.JButton();
jButton11 = new javax.swing.JButton();
jButton1.setText("Jouer");
jButton1.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
jButton2.setText("Options");
jButton2.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
jButton3.setText("Gestion");
jButton3.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
jButton4.setText("Aide");
jButton4.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
jButton5.setText("Quitter");
jButton5.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
jButton6.setText("Creer partie");
jButton6.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
jButton7.setText("Rejoinde partie");
jButton7.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
jButton8.setText("Ajout d'un jeu");
jButton8.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
jButton9.setText("MAJ d'un jeu");
jButton9.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
jButton10.setText("Oui");
jButton10.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
jButton11.setText("Non");
jButton11.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
.add(162, 162, 162)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jButton5, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 69, Short.MAX_VALUE)
.add(jButton4, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 69, Short.MAX_VALUE)
.add(jButton3, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 69, Short.MAX_VALUE)
.add(jButton2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 69, Short.MAX_VALUE)
.add(jButton1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 69, Short.MAX_VALUE))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jButton11, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 103, Short.MAX_VALUE)
.add(jButton7, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 103, Short.MAX_VALUE)
.add(jButton8, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 103, Short.MAX_VALUE)
.add(jButton9, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 103, Short.MAX_VALUE)
.add(jButton10, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 103, Short.MAX_VALUE)
.add(jButton6, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 103, Short.MAX_VALUE))
.add(84, 84, 84))
);
layout.setVerticalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(org.jdesktop.layout.GroupLayout.LEADING, layout.createSequentialGroup()
.add(77, 77, 77)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jButton1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.add(jButton6))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jButton2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 23, Short.MAX_VALUE)
.add(jButton7))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jButton3, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 23, Short.MAX_VALUE)
.add(jButton8))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jButton4, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 23, Short.MAX_VALUE)
.add(jButton9))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jButton5, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 23, Short.MAX_VALUE)
.add(jButton10))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jButton11)
.add(59, 59, 59))
);
}// </editor-fold>
// Variables declaration - do not modify
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton10;
private javax.swing.JButton jButton11;
private javax.swing.JButton jButton2;
private javax.swing.JButton jButton3;
private javax.swing.JButton jButton4;
private javax.swing.JButton jButton5;
private javax.swing.JButton jButton6;
private javax.swing.JButton jButton7;
private javax.swing.JButton jButton8;
private javax.swing.JButton jButton9;
// End of variables declaration
public void initButton(){
init();
jButton1.addMouseListener(this);
jButton2.addMouseListener(this);
jButton3.addMouseListener(this);
jButton4.addMouseListener(this);
jButton5.addMouseListener(this);
jButton6.addMouseListener(this);
jButton7.addMouseListener(this);
jButton8.addMouseListener(this);
jButton9.addMouseListener(this);
jButton10.addMouseListener(this);
jButton11.addMouseListener(this);
}
public void init(){
jButton1.setVisible(true);
jButton2.setVisible(true);
jButton3.setVisible(true);
jButton4.setVisible(true);
jButton5.setVisible(true);
jButton6.setVisible(false);
jButton7.setVisible(false);
jButton8.setVisible(false);
jButton9.setVisible(false);
jButton10.setVisible(false);
jButton11.setVisible(false);
}
public void mousePressed(MouseEvent e) {}
public void mouseReleased(MouseEvent e) {}
public void mouseClicked(MouseEvent e) {
if (e.getSource() == jButton6){ // creation de partie
this.removeAll();
this.repaint();
CreateGame cg = new CreateGame();
cg.initButton();
this.add(cg);
this.repaint();
}else if (e.getSource() == jButton7){ // rejoindre une partie
this.removeAll();
this.repaint();
JoinGame jg = new JoinGame();
//jg.initButton();
this.add(jg);
this.revalidate();
}else if (e.getSource() == jButton2){ // rejoindre une partie
this.removeAll();
this.repaint();
Option o = new Option();
//jg.initButton();
this.add(o);
this.revalidate();
}else if (e.getSource() == jButton8){ // rejoindre une partie
this.removeAll();
this.repaint();
AddGame ag = new AddGame();
//jg.initButton();
this.add(ag);
this.revalidate();
}else if (e.getSource() == jButton9){ // rejoindre une partie
this.removeAll();
this.repaint();
UpdateGame ug = new UpdateGame();
//jg.initButton();
this.add(ug);
this.revalidate();
}else if (e.getSource() == jButton4){ // rejoindre une partie
try{
BrowserLauncher.openURL("./src/games/corps.html");
}catch(IOException ioe){System.out.println(ioe);}
}
else if (e.getSource() == jButton10){ // rejoindre une partie
//System.out.println("exit");
System.exit(0);
}else if (e.getSource() == jButton11){ // rejoindre une partie
init();
}
}
public void mouseEntered(MouseEvent e) {
if (e.getSource() == jButton1){
init();
jButton6.setVisible(true);
jButton7.setVisible(true);
} else if (e.getSource() == jButton2){
init();
}else if (e.getSource() == jButton3){
init();
jButton8.setVisible(true);
jButton9.setVisible(true);
}else if (e.getSource() == jButton4){
init();
}else if (e.getSource() == jButton5){
init();
jButton10.setVisible(true);
jButton11.setVisible(true);
}}
public void mouseExited(MouseEvent e) {}
} |
Partager