Quel code dans mon actionPerformed?
Bonjour tout le monde.
J' ai cree 2 fenetres, la premiere a un bouton pour ouvrir la seconde.
je ne comprends pas le code à mettre dans public void actionPerformed pour ouvrir cette seconde fenetre :oops:
code:
Code:
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
|
package pack;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.WindowConstants;
import javax.swing.SwingUtilities;
/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class Fenetre1 extends javax.swing.JFrame {
private JButton bouton1;
/**
* Auto-generated main method to display this JFrame
*/
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
Fenetre1 inst = new Fenetre1();
inst.setLocationRelativeTo(null);
inst.setVisible(true);
}
});
}
public Fenetre1() {
super();
initGUI();
}
private void initGUI() {
try {
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
BorderLayout thisLayout = new BorderLayout();
this.setTitle("Fenetre 1");
getContentPane().setLayout(thisLayout);
{
bouton1 = new JButton();
getContentPane().add(bouton1, BorderLayout.NORTH);
bouton1.setText("Fenetre2");
bouton1.setPreferredSize(new java.awt.Dimension(411, 47));
bouton1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
System.out.println("bouton1.actionPerformed, event="+evt);
//TODO add your code for bouton1.actionPerformed
}
});
}
pack();
setSize(400, 300);
} catch (Exception e) {
e.printStackTrace();
}
}
} |
Merci de votre aide