Bonjour,
Je me remets sur Java, parcque jusqu'à présent j'ai réussi à tout faire en autoit, mais j'atteint un peu les limites alors je me remets sur un langage un peu plus "noble" (sans vouloir manquer de respect à qui que ce soit..).
Le code suivant fonctionne parfaitement, mais dès que je veux mettre la 2ème classe (CheckIPAddress) dans une autre classe, sous Eclipse, ce dernier me dit que combo ne peut être résolu...
Une idée?
Merci d'avance
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 import javax.swing.JFrame; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Dimension; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JButton; import javax.swing.JComboBox; import javax.swing.JPanel; import javax.swing.JLabel; public class MainWindow extends JFrame{ private static final long serialVersionUID = 1L; private JPanel container = new JPanel(); public JLabel label = new JLabel("Choose or type you IP address"); private static JComboBox<?> combo = new JComboBox<Object>(); private JButton check = new JButton("Check"); public MainWindow() { this.setBounds(100, 100, 500, 400); this.setTitle("Bobst Synchronisation Software"); this.setTitle("Bobst Synchronisation Software"); this.setSize(600, 300); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setLocationRelativeTo(null); container.setBackground(Color.white); container.setLayout(new BorderLayout()); combo.setPreferredSize(new Dimension(130, 20)); combo.setEditable(true); JPanel top = new JPanel(); top.add(label); top.add(combo); top.add(check); container.add(top, BorderLayout.NORTH); this.setContentPane(container); this.setVisible(true); check.addActionListener(new CheckIPAddress()); } public class CheckIPAddress implements ActionListener{ public void actionPerformed(ActionEvent e) { System.out.println(combo.getSelectedItem().toString()); } } public static void main(String[] args) { new MainWindow(); } }
Partager