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
|
package Test;
import java.awt.event.ActionEvent;
/**
*
* @author GRESLON Jérémy
*/
public class porte extends javax.swing.JFrame {
/** Creates new form porte */
public porte() {
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() {
jTogglePorte = new javax.swing.JToggleButton();
jLabelPorte = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jTogglePorte.setText("Ouverture porte");
jTogglePorte.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTogglePorteActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap(151, Short.MAX_VALUE)
.addComponent(jTogglePorte)
.addGap(144, 144, 144))
.addGroup(layout.createSequentialGroup()
.addGap(90, 90, 90)
.addComponent(jLabelPorte, javax.swing.GroupLayout.PREFERRED_SIZE, 203, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(107, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGap(108, 108, 108)
.addComponent(jLabelPorte, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 89, Short.MAX_VALUE)
.addComponent(jTogglePorte)
.addGap(48, 48, 48))
);
pack();
}// </editor-fold>
private void jTogglePorteActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
ActionEvent bool1 = evt;
if(){ //????? je ne sais pas qu'elle peut être la condition
PorteOuverte();
}
else{
PorteFermee();
}
}
public void PorteOuverte(){
jLabelPorte.setText("La porte est ouverte");
}
public void PorteFermee(){
jLabelPorte.setText("La porte est fermée");
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new porte().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JLabel jLabelPorte;
private javax.swing.JToggleButton jTogglePorte;
// End of variables declaration
} |