Bonjour,
Je suis entrain de faire un petit formulaire et j'ai un problème pour attacher un JButton "browserButton" et un JTextField "location" à un panel "fr1". Le code du panel est ci-dessous et lorsque j'execute le programme, le bouton et le textfield ne s'affiche pas.
Est-ce-que quelqu'un aurait une idée.
Merci
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 public class Form extends JFrame implements ActionListener { JTextField location = new JTextField(); JButton browserButton = new JButton("Browse"); public static void main(String[] args) { JFrame frame = new JFrame(); frame.setTitle("Properties Configurator"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JComponent panel = new Form().buildPanel(); frame.getContentPane().add(panel); frame.pack(); frame.setVisible(true); } private JComponent buildPanel() { JTabbedPane tabbedPane = new JTabbedPane(); tabbedPane.putClientProperty("jgoodies.noContentBorder", Boolean.TRUE); tabbedPane.add("I/O parameters", setIOParam()); return tabbedPane; } private JComponent setIOParam(){ JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); getContentPane().add(panel); JPanel fr1 = new JPanel(); fr1.setBorder(new TitledBorder("Input database")); BoxLayout layout = new BoxLayout(fr1, BoxLayout.X_AXIS); fr1.setLayout(layout); browserButton.addActionListener(this); fr1.add(new JLabel("Source file:")); fr1.add(location); fr1.add(browserButton); panel.add(fr1); }
Partager