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

javax.swing: buttons loose thier size and look squashed under motif LF


    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Won't Fix
    • Affects Version/s: 1.0
    • Fix Version/s: None
    • Component/s: client-libs
    • Labels:


      Customer created sample code for the buttons getting squashed under motif look and feel.

      This test case was compiled with jdk1.2.2 and was adapted from the
      ...jdk1.2/demo/jfc/Simple/SimpleExample demo code provided by Sun.

      This is a simple test case:
      import java.awt.*;
      import java.awt.event.*;
      import javax.swing.*;

       * An application that displays a JButton and several JRadioButtons.
       * The JRadioButtons determine the look and feel used by the application.
      public class SimpleExample extends JPanel {
          static JFrame frame;

          static String metal= "Metal";
          static String metalClassName = "javax.swing.plaf.metal.MetalLookAndFeel";

          static String motif = "Motif";
          static String motifClassName =

          static String windows = "Windows";
          static String windowsClassName =

          JRadioButton metalButton, motifButton, windowsButton;

          public SimpleExample() {



              // Create the buttons.
              JButton button = new JButton("Test");
              metalButton = new JRadioButton(metal);

              motifButton = new JRadioButton(motif);

              windowsButton = new JRadioButton(windows);

              // Group the radio buttons.
              ButtonGroup group = new ButtonGroup();

              // Register a listener for the radio buttons.
              RadioListener myListener = new RadioListener();



          /** An ActionListener that listens to the radio buttons. */
          class RadioListener implements ActionListener {
              public void actionPerformed(ActionEvent e) {
                  String lnfName = e.getActionCommand();

                  try {
              // frame.pack();
                  catch (Exception exc) {
                      JRadioButton button = (JRadioButton)e.getSource();
                      System.err.println("Could not load LookAndFeel: " + lnfName);


          public void updateState() {
               String lnfName = UIManager.getLookAndFeel().getClass().getName();
               if (lnfName.indexOf(metal) >= 0) {
               } else if (lnfName.indexOf(windows) >= 0) {
               } else if (lnfName.indexOf(motif) >= 0) {
               } else {
                   System.err.println("SimpleExample is using an unknown L&F: " + lnfName);

          public static void main(String s[]) {
                 NOTE: By default, the look and feel will be set to the
                 Cross Platform Look and Feel (which is currently Metal).
                 The user may someday be able to override the default
                 via a system property. If you as the developer want to
                 be sure that a particular L&F is set, you can do so
                 by calling UIManager.setLookAndFeel(). For example, the
                 first code snippet below forcibly sets the UI to be the
                 System Look and Feel. The second code snippet forcibly
                 sets the look and feel to the Cross Platform L&F.

                 Snippet 1:
                    try {
                    } catch (Exception exc) {
                        System.err.println("Error loading L&F: " + exc);

                 Snippet 2:
                    try {
                    } catch (Exception exc) {
                        System.err.println("Error loading L&F: " + exc);

              SimpleExample panel = new SimpleExample();

              frame = new JFrame("SimpleExample");
              frame.addWindowListener(new WindowAdapter() {
                  public void windowClosing(WindowEvent e) {System.exit(0);}
              frame.getContentPane().add("Center", panel);


      Full test environment can be found at:




            • Assignee:
              jeff Jeff Dinkins
              duke J. Duke (Inactive)
            • Votes:
              0 Vote for this issue
              0 Start watching this issue


              • Created: