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
|
package testihm;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import com.borland.jbcl.layout.*;
import javax.swing.event.*;
import java.awt.Dimension;
public class Cadre1 extends JFrame {
JPanel contentPane;
XYLayout xYLayout1 = new XYLayout();
JButton jButton1 = new JButton();
Cadre2 JDialogue2 ;
JCheckBox jCheckBox1 = new JCheckBox();
List list1 = new List();
List list2 = new List();
String[] data = {"one", "two", "three", "four"};
JList jList1 = new JList(data) ;
/**Construire le cadre*/
public Cadre1() {
enableEvents(AWTEvent.WINDOW_EVENT_MASK);
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
/**Initialiser le composant*/
private void jbInit() throws Exception {
//setIconImage(Toolkit.getDefaultToolkit().createImage(Cadre1.class.getResource("[Votre icône]")));
contentPane = (JPanel) this.getContentPane();
jButton1.setText("jButton1");
jButton1.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(MouseEvent e) {
jButton1_mouseClicked(e);
}
});
contentPane.setLayout(xYLayout1);
this.setSize(new Dimension(472, 350));
this.setTitle("Titre du cadre");
//System.out.println(jList1.getModel()) ;
String liste = new String() ;
liste = "aa" ;
contentPane.add(jButton1, new XYConstraints(42, 29, 170, 47));
contentPane.add(jCheckBox1, new XYConstraints(42, 97, -1, -1));
contentPane.add(list1, new XYConstraints(379, 16, 70, 102));
contentPane.add(jList1, new XYConstraints(240, 31, 107, 49));
contentPane.add(list2, new XYConstraints(202, 95, 76, 92));
list1.add("aaa", 1);
}
/**Remplacé, ainsi nous pouvons sortir quand la fenêtre est fermée*/
protected void processWindowEvent(WindowEvent e) {
super.processWindowEvent(e);
if (e.getID() == WindowEvent.WINDOW_CLOSING) {
System.exit(0);
}
}
void jButton1_mouseClicked(MouseEvent e) {
System.out.println("abcd") ;
//JDialog open = new JDialog(this.contentPane, "bbb", true) ;
JDialogue2 = new testihm.Cadre2() ;
JDialogue2.setVisible(true) ;
// this.setVisible(false);
}
} |