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

JCheckBoxMenuItem does not pick up the correct font settings for Windows L&F

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 1.4.0
    • 1.4.0
    • client-libs
    • beta2
    • x86
    • windows_2000



      Name: bsC130419 Date: 07/10/2001


      java version "1.4.0-beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta-b65)
      Java HotSpot(TM) Client VM (build 1.4.0-beta-b65, mixed mode)

      The JCheckBoxMenuItem does not pick up the correct font settings for Windows
      Look & Feel.

      Example source code below:
      (Two files)

      <Frame1.java>
      import java.awt.*;
      import java.awt.event.*;
      import javax.swing.*;

      public class Frame1 extends JFrame
      {
        JPanel contentPane;
        JMenuBar jMenuBar1 = new JMenuBar();
        JMenu jMenuFile = new JMenu();
        JMenuItem jMenuFileExit = new JMenuItem();
        JMenuItem good = new JMenuItem("Correct Windows Look&Feel Font");
        JCheckBoxMenuItem bad = new JCheckBoxMenuItem("Incorrect Windows Look&Feel
      Font");
        JMenu jMenuHelp = new JMenu();
        JMenuItem jMenuHelpAbout = new JMenuItem();
        BorderLayout borderLayout1 = new BorderLayout();

        /**Construct the frame*/
        public Frame1()
        {
          enableEvents(AWTEvent.WINDOW_EVENT_MASK);
          try
          {
            jbInit();
          }
          catch(Exception e)
          {
            e.printStackTrace();
          }
        }
        /**Component initialization*/
        private void jbInit() throws Exception
        {
          //setIconImage(Toolkit.getDefaultToolkit().createImage
      (Frame1.class.getResource("[Your Icon]")));
          contentPane = (JPanel) this.getContentPane();
          contentPane.setLayout(borderLayout1);
          this.setSize(new Dimension(400, 300));
          this.setTitle("Frame Title");
          jMenuFile.setText("File");
          jMenuFileExit.setText("Exit");
          jMenuFileExit.addActionListener(new ActionListener()
          {
            public void actionPerformed(ActionEvent e)
            {
      jMenuFileExit_actionPerformed(e);
            }
          });
          jMenuHelp.setText("Help");
          jMenuHelpAbout.setText("About");
          jMenuHelpAbout.addActionListener(new ActionListener()
          {
            public void actionPerformed(ActionEvent e)
            {
      jMenuHelpAbout_actionPerformed(e);
            }
          });
          jMenuFile.add(good);
          jMenuFile.add(bad);
          jMenuFile.add(jMenuFileExit);
          jMenuHelp.add(jMenuHelpAbout);
          jMenuBar1.add(jMenuFile);
          jMenuBar1.add(jMenuHelp);
          this.setJMenuBar(jMenuBar1);
        }
        /**File | Exit action performed*/
        public void jMenuFileExit_actionPerformed(ActionEvent e)
        {
          System.exit(0);
        }
        /**Help | About action performed*/
        public void jMenuHelpAbout_actionPerformed(ActionEvent e)
        {
        }
        /**Overridden so we can exit when window is closed*/
        protected void processWindowEvent(WindowEvent e)
        {
          super.processWindowEvent(e);
          if (e.getID() == WindowEvent.WINDOW_CLOSING)
          {
            jMenuFileExit_actionPerformed(null);
          }
        }
      }


      <Application1.java>
      import javax.swing.UIManager;
      import java.awt.*;

      public class Application1
      {
        boolean packFrame = false;

        /**Construct the application*/
        public Application1()
        {
          Frame1 frame = new Frame1();
          //Validate frames that have preset sizes
          //Pack frames that have useful preferred size info, e.g. from their layout
          if (packFrame)
          {
            frame.pack();
          }
          else
          {
            frame.validate();
          }
          //Center the window
          Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
          Dimension frameSize = frame.getSize();
          if (frameSize.height > screenSize.height)
          {
            frameSize.height = screenSize.height;
          }
          if (frameSize.width > screenSize.width)
          {
            frameSize.width = screenSize.width;
          }
          frame.setLocation((screenSize.width - frameSize.width) / 2,
      (screenSize.height - frameSize.height) / 2);
          frame.setVisible(true);
        }
        /**Main method*/
        public static void main(String[] args)
        {
          try
          {
            UIManager.setLookAndFeel
      ("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
          }
          catch(Exception e)
          {
            e.printStackTrace();
          }
          new Application1();
        }
      }



      Run with SDK v1.4 beta interpreter. Entry point class is Application1. Click
      on the "File" menu to see the bug.
      (Review ID: 127728)
      ======================================================================

            mdavidsosunw Mark Davidson (Inactive)
            bstrathesunw Bill Strathearn (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: