public class OptionGUI implements ActionListener { //Tab Panel private JTabbedPane tabbedPane = new JTabbedPane(); //Inhalter der Tabs private JPanel internetPanel = new JPanel(); private JPanel fieldPanel = new JPanel(); private JPanel tablePanel = new JPanel(); //Inhalt für Internet Panel private JCheckBox checkProxy = new JCheckBox("Proxy verwenden"); private JTextField txtProxy = new JTextField(30); private JTextField txtPort = new JTextField(5); private JLabel lblProxy = new JLabel("Proxy"); private JLabel lblPort = new JLabel("Port"); private JFrame optionWindow = new JFrame("Optionen"); private JPanel createInternetPanel() { internetPanel.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.HORIZONTAL; c.gridx = 1; c.gridy = 1; c.gridwidth = 5; checkProxy.setVisible(true); checkProxy.addActionListener(this); internetPanel.add(checkProxy); c.gridx = 1; c.gridy = 2; c.gridwidth = 3; txtPort.setEnabled(false); txtPort.setVisible(true); internetPanel.add(txtProxy); c.gridx = 5; c.gridy = 3; c.gridwidth = 2; txtProxy.setEnabled(false); txtProxy.setVisible(true); internetPanel.add(txtPort); return internetPanel; } public void createOptionWindow() { tabbedPane.addTab("Internet", createInternetPanel()); tabbedPane.addTab("Felder", fieldPanel); tabbedPane.addTab("Tabelle", tablePanel); tabbedPane.setVisible(true); optionWindow.add(tabbedPane); optionWindow.setSize(600, 400); optionWindow.pack(); optionWindow.setVisible(true); } public void actionPerformed(ActionEvent e) { if(e.getActionCommand().equals("Proxy verwenden")){ if(checkProxy.isSelected()) { txtPort.setEnabled(true); txtProxy.setEnabled(true); } else { txtPort.setEnabled(false); txtProxy.setEnabled(false); } } } }
Dieser Beitrag wurde von Eardy bearbeitet: 22. Juni 2007 - 13:31