Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4424085

Several Swing problems

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: P4 P4
    • None
    • 1.3.0
    • client-libs



      Name: boT120536 Date: 03/09/2001


      PC (OS: NT4.0 SP4):
      java version "1.3.1-beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1-beta-b15)
      Java HotSpot(TM) Client VM (build 1.3.1beta-b15, mixed mode)

      Sparc (OS Solaris 2.6):
      java version "1.3.0"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0)
      Java HotSpot(TM) Client VM (build 1.3.0, mixed mode)


      1. Start up DialogProblem.main, e.g.:

        D:\jdk1.3.1Beta\bin\java -cp . DialogProblem

      A frame appears with a button to pop up a JDialog.
      This dialog demonstrates the following bugs:

      a. The very first time the contents of the textfield is not selected
      on a Sparc, whereas it is on the PC.

      b. On a PC the very first time the background color of panel and panel2
      of the dialog differs from the rest of the dialog. This does not happen
      on the Sparc.

      c. If a window of another application is put in front of the dialog
      and removed afterwards, the dialog is not repainted correctly. This
      happens both on a PC as on a Sparc.

      d. If the dialog is closed and popped up again the text in textfield1
      is not selected, neither on the PC nor on the Sparc.

      e. If the dialog is closed and popped up again the dialog is not
      painted correctly, both on a PC as on a Sparc. Again on the PC there
      are two different (grey) background colors.

      2. Source:
      import java.awt.*;
      import java.awt.event.*;
      import javax.swing.*;

      class DialogProblem implements ActionListener {

         MyDialog dialog;
         int number;

         DialogProblem(JFrame frame) {

            dialog = new MyDialog(frame);
         }

         public void actionPerformed(ActionEvent e) {

            dialog.setVisible(true);
         }

         public static void main(String[] args) {

            JFrame frame = new JFrame("DialogProblem");
            frame.addWindowListener(new WindowAdapter() {
      public void windowClosing(WindowEvent e) {System.exit(0);}
            });

            JButton button = new JButton("Dialog");
            button.addActionListener(new DialogProblem(frame));
            button.setAlignmentX(Component.CENTER_ALIGNMENT);
            button.setToolTipText("Show dialog");

            Box box = Box.createVerticalBox();
            box.add(Box.createRigidArea(new Dimension (240, 40)));
            box.add(button);
            box.add(Box.createVerticalStrut(40));

            frame.getContentPane().add(box);
            frame.pack();
            frame.setVisible(true);
         }

         class MyDialog extends JDialog implements ActionListener {

            JTextField textField1;
            JTextField textField2;

            MyDialog(JFrame frame) {

      super(frame, "Dialog", true);

      Box box = Box.createVerticalBox();

      box.add(Box.createVerticalStrut(20));

      JPanel panel = new JPanel();
      panel.setLayout(new FlowLayout(FlowLayout.CENTER));
      panel.add(new JLabel("Text Field 1: "));
      textField1 = new JTextField(20);
      panel.add(textField1);
      box.add(panel);

      box.add(Box.createVerticalStrut(6));

      JPanel panel2 = new JPanel();
      panel2.setLayout(new FlowLayout(FlowLayout.CENTER));
      panel2.add(new JLabel("Text Field 2: "));
      textField2 = new JTextField(20);
      panel2.add(textField2);
      box.add(panel2);

      box.add(Box.createVerticalStrut(20));

      JButton button = new JButton("OK");
      button.addActionListener(this);
      button.setAlignmentX(Component.CENTER_ALIGNMENT);
      box.add(button);

      box.add(Box.createVerticalStrut(20));

      setContentPane(box);
      pack();
            }

            public void setVisible(boolean v) {

      if (v) {
      textField1.setText(Integer.toString(++number));
      textField1.selectAll();
      textField2.setText(Integer.toString(2*number));
      }
      super.setVisible(v);
            }

            public void actionPerformed(ActionEvent e) {

      setVisible(false);
            }
         }
      }

      3-5. NA
      (Review ID: 118470)
      ======================================================================

            svioletsunw Scott Violet (Inactive)
            bonealsunw Bret O'neal (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: