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

Label background not set properly

XMLWordPrintable

    • kestrel
    • x86
    • generic, windows_95, windows_nt
    • Verified



      Name: gsC80088 Date: 11/20/98


      This submission contains two source files:
      TreeCopy.java, and ConfigDialog.java.

      Perform the following steps to demonstrate
      the bug:
      1) build and run the program.
      2) From the "File" menu, select "New Window".
      3) From the "File" menu in the new window,
         select "Configure".

      In the dialog, the label text is drawn with
      a white background. It should be drawn with
      a grey background.

      Here is TreeCopy.java:
      import java.awt.*;
      import java.awt.event.*;

      /*
      This code reveals a bug in drawing backgrounds for
      labels.
      */

      public class TreeCopy extends Frame implements ActionListener
      {
      TextField tfRoot;
      ConfigDialog configDlg = null;
      MenuItem miConfigure = new MenuItem("Configure...");
      MenuItem miRun = new MenuItem("Run");
      MenuItem miStop = new MenuItem("Stop");
      MenuItem miExit = new MenuItem("Exit");
      MenuItem miNewWindow = new MenuItem("New Window");
      static int windowCount = 0;

      public TreeCopy(int windowNum)
      {
      super("TreeCopy Window #" + Integer.toString(windowNum));

      MenuBar mb = new MenuBar();
      Menu m = new Menu("File");
      configDlg = new ConfigDialog(this);

      m.add(miConfigure);
      m.add(miNewWindow);
      m.add(miRun);
      m.add(miStop);
      m.add(miExit);
      miConfigure.addActionListener(this);
      miRun.addActionListener(this);
      miStop.addActionListener(this);
      miNewWindow.addActionListener(this);
      miExit.addActionListener(this);
      mb.add(m);
      setMenuBar(mb);
      m.addActionListener(this);

      tfRoot = new TextField();
      tfRoot.setEditable(false);
      add(tfRoot);

      addWindowListener(new WindowAdapter()
      {
      public void windowClosing(WindowEvent we)
      {
      dispose();
      if ( --windowCount == 0 )
      {
      System.exit(0);
      }
      }
      });

      pack();
      show();
      }

      public void actionPerformed(ActionEvent ae)
      {
      Object source = ae.getSource();

      if ( source == miConfigure )
      {
      configDlg.setVisible(true);
      }
      else if ( source == miNewWindow )
      {
      new TreeCopy(++windowCount);
      }
      else if ( source == miExit )
      {
      System.exit(0);
      }
      }

      public static void main(String [] args)
      {
      new TreeCopy(++windowCount);
      }
      }


      Here is ConfigDialog.java:
      import java.awt.*;
      import java.awt.event.*;

      public class ConfigDialog extends Dialog implements ActionListener
      {
      public Button okButton;
      public Button cancelButton;
      Label l2;

      public ConfigDialog(Frame parent)
      {
      super(parent, "Configuration Dialog");

      okButton = new Button("OK");
      cancelButton = new Button("Cancel");

      // When the dialog is first made visible in a
      // secondary Frame, the background for the
      // label will be white instead of grey.
      Label l2 = new Label("This is a label:");

      setLayout(new FlowLayout());

      add(l2);
      add(okButton);
      add(cancelButton);

      okButton.addActionListener(this);
      cancelButton.addActionListener(this);

      pack();
      }

      public void actionPerformed(ActionEvent ae)
      {
      dispose();
      }
      }
      (Review ID: 42987)
      ======================================================================

            prssunw Prs Prs (Inactive)
            gstone Greg Stone
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: