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
|
public class Untitled2 extends JFrame implements ActionListener {
JPanel jPanel1 = new JPanel();
JScrollPane jS = new JScrollPane();
JButton ajouter = new JButton();
JTextField text = new JTextField();
public Untitled2() {
setTitle(" fenetre ");
this.setResizable(false);
this.setSize(650, 650);
this.setLocationRelativeTo(null);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
private void jbInit() throws Exception {
jPanel1.setLayout(null);
this.getContentPane().setLayout(null);
jPanel1.setBounds(new Rectangle(51, 12, 269, 262));
Object[][] data = {
{
"", "", "", "", "", "", "", ""}
, {
"", "", "", "", "", "", "", ""}
};
String[] columns = {
"Date_etablissement", "equipement", "Description_equipement",
"Designation_article"};
JTable t = new JTable(data, columns);
jS.setBounds(new Rectangle(30, 17, 208, 134));
jS.setViewportView(t);
jPanel1.add(jS);
ajouter.setBounds(new Rectangle(193, 197, 71, 23));
ajouter.setText("ajouter");
ajouter.addActionListener(this);
text.setText("");
text.addActionListener(this);
text.setBounds(new Rectangle(61, 196, 62, 20));
this.getContentPane().add(jPanel1, null);
jPanel1.add(ajouter, null);
jPanel1.add(text, null);
}
public static void main(String[] args) {
Untitled2 gui = new Untitled2();
gui.setVisible(true);
}
public void actionPerformed(ActionEvent e) {
if (e.getSource().equals(ajouter)) {
String A ;
A= text.getText().toString();
System.out.println(A);
}
}
} |
Partager