- final JButton buttonStart = new JButton("Start");
- frame.getContentPane().add(buttonStart);
- buttonStart.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- JDialog dialog = new JDialog(frame, "TestDialog");
- JLabel label = new JLabel("Dialog open");
- dialog.getContentPane().add(label);
- dialog.pack();
- dialog.setVisible(true);
- }
- });
+ // Start dialog button
+ {
+ final JButton buttonStart = new JButton("Start");
+ frame.getContentPane().add(buttonStart);
+ buttonStart.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ JDialog dialog = new JDialog(frame, "TestDialog");
+ JLabel label = new JLabel("Dialog open");
+ dialog.getContentPane().add(label);
+ dialog.pack();
+ dialog.setVisible(true);
+ }
+ });
+ }
+
+ // Complex Panel
+ {
+ JPanel complexPanel = new JPanel();
+ complexPanel.setLayout(new GridLayout(1, 2));
+ final JTextField textTime = new JTextField(Long.toString(System
+ .currentTimeMillis()));
+ complexPanel.add(textTime);
+ JButton buttonTime = new JButton("Now!");
+ buttonTime.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ textTime.setText(Long.toString(System.currentTimeMillis()));
+ }
+ });
+ complexPanel.add(buttonTime);
+ frame.getContentPane().add(complexPanel);
+ }