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

Using JTollBar & JMenuBar together, under the CROSS L&F, JMenuBar will change

XMLWordPrintable

      FULL PRODUCT VERSION :
      Eclipse

      ADDITIONAL OS VERSION INFORMATION :
      Windows XP

      A DESCRIPTION OF THE PROBLEM :
      When JMenuBar and JToolBar were used together, under the Default Look and Feel, When dragging the JToolBar around, and when the ToolBar fly over the JMenuBar, it will left unpleasant color on the JMenuBar.

      I have tried the same program under the Windows L&F and UNIX L&F, it will not show such problems in these L&Fs.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Run the attached program, drag the tool bar and move around it a while, purposely move it over the menubar, then unpleasant shadow color will be left over the menu bar.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      slove it.
      ACTUAL -
      should have no effect on the menu bar

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.awt.BorderLayout;
      import java.awt.event.ActionEvent;
      import java.awt.event.ActionListener;

      import javax.swing.JButton;
      import javax.swing.JFrame;
      import javax.swing.JMenu;
      import javax.swing.JMenuBar;
      import javax.swing.JToolBar;

      import net.effortech.harry.swing.Laf;

      public class MenuBarAndToolBar extends JFrame {
        private JMenuBar mb;

        private JToolBar tb;

        private JMenu fileMenu, editMenu;

        private JButton addBtn, exitBtn;

        public MenuBarAndToolBar() {
          super("MenuBar and ToolBar");
          setJMenuBar(getMb());
          getContentPane().add(getTb(), BorderLayout.PAGE_START);
          setSize(500, 400);
          setDefaultCloseOperation(EXIT_ON_CLOSE);
          setVisible(true);
        }

        private JMenuBar getMb() {
          if (mb == null) {
            mb = new JMenuBar();
            mb.add(getFileMenu());
            mb.add(getEditMenu());
          }
          return mb;
        }

        private JMenu getFileMenu() {
          if (fileMenu == null) {
            fileMenu = new JMenu("File");
          }
          return fileMenu;
        }

        private JMenu getEditMenu() {
          if (editMenu == null) {
            editMenu = new JMenu("Edit");
          }
          return editMenu;
        }

        private JToolBar getTb() {
          if (tb == null) {
            tb = new JToolBar();
            tb.add(getAddBtn());
            tb.add(getExitBtn());
          }
          return tb;
        }

        private JButton getAddBtn() {
          if (addBtn == null) {
            addBtn = new JButton("Add");
            addBtn.addActionListener(new ActionListener() {
              public void actionPerformed(ActionEvent e) {

              }
            });
          }
          return addBtn;
        }

        private JButton getExitBtn() {
          if (exitBtn == null) {
            exitBtn = new JButton("Exit");
            exitBtn.addActionListener(new ActionListener() {
              public void actionPerformed(ActionEvent e) {
                System.exit(0);
              }
            });
          }
          return exitBtn;
        }

        public static void main(String[] args) {
      // Laf.setLaf(Laf.UNIX);
          new MenuBarAndToolBar();
        }

      }

      ---------- END SOURCE ----------

            shickeysunw Shannon Hickey (Inactive)
            ndcosta Nelson Dcosta (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: