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

Component JButton does not show all button text when the font is switched.

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Cannot Reproduce
    • Affects Version/s: 1.2.2
    • Fix Version/s: None
    • Component/s: client-libs
    • Labels:
    • Subcomponent:
    • CPU:
      x86
    • OS:
      linux

      Description



      Name: kaC94536 Date: 01/21/2000



      Component JButton does not show all button text, when sertain fonts are set for this button.
      Frame window of the following test contains two buttons ("Next font" and "Previous font" - at left) and
      tested JButton component (at right).
      By clicking on buttons "Next" and "Prev" you can change fonts of tested button.
      In many cases you'll see that all text does not appear in the button label.

      Note that the TextButton components look correctly with any font.

      --------------------test.java---------------------------------------------

      import javax.swing.*;
      import java.awt.*;
      import java.awt.event.*;

      public class test extends JFrame {

          public test() {
              super("JButton test");
              getContentPane().add(new ButtonDemo(this),BorderLayout.CENTER);
          }
         
         public static void main(String[] args) {
              JFrame frame = new test();
              frame.addWindowListener(new WindowAdapter() {
                  public void windowClosing(WindowEvent e) {
                      System.exit(0);
                  }
              });
              frame.pack();
              frame.setVisible(true);
          }
      }

      class ButtonDemo extends JPanel implements ActionListener {
          static Font[] systemFontArray;
          protected int currentFontCount;
          Button b1, b2;
          JButton testButton;
          test t;

          public ButtonDemo(test tt) {
              t = tt;
              b1 = new Button("Next font");
              b1.setActionCommand("next");
              b1.addActionListener(this);
              add(b1);
              b2 = new Button("Previous font");
              b2.setActionCommand("prev");
              b2.addActionListener(this);
              add(b2);

              testButton = new JButton("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789");
              currentFontCount = 0;
      setButtonFont(currentFontCount);
              add(testButton);
          }

          static {
              systemFontArray=GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts();
           }

          public void actionPerformed(ActionEvent e) {
              if (e.getActionCommand().equals("next")) nextFont(); else prevFont();
           }

          public void nextFont() {
      if (currentFontCount < systemFontArray.length-1) setButtonFont(++currentFontCount);
             }

            public void prevFont () {
      if (currentFontCount > 0) setButtonFont(--currentFontCount);
             }

            public void setButtonFont(int i) {
      testButton.setFont(new Font(systemFontArray[i].getFontName(), 0, 12));
                t.setTitle(systemFontArray[i].getFontName());
             }
      }

      ======================================================================

      ======================================================================

        Attachments

          Activity

            People

            Assignee:
            mbronsonsunw Mike Bronson (Inactive)
            Reporter:
            kanisimosunw Konstantin Anisimov (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: