-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
1.2.0
-
x86
-
solaris_2.6
Name: rm29839 Date: 02/19/98
Run the following application (java B).
It will create a toolbar with one button in it
in the "North" region of a border layout panel.
You'll see that the button has been incorrectly
resized so that its label text requires
truncation.
The label should read "label"; instead it
reads "la...". This problem seems to be
related to BorderLayout and the BoxLayout that
is used by the JToolBar widget.
-------------------------------------------------
import java.awt.swing.JButton;
import java.awt.swing.JToolBar;
import java.awt.swing.BoxLayout;
import java.awt.swing.Box;
import java.awt.swing.JPanel;
import java.awt.swing.JLabel;
import java.awt.swing.JFrame;
import java.awt.Font;
import java.awt.Container;
import java.awt.BorderLayout;
class B {
public static void main(String args[]){
JToolBar toolbar = new JToolBar();
toolbar.add(createButton("Label"));
JFrame frame = new JFrame();
Container pane = frame.getContentPane();
pane.setLayout(new BorderLayout());
pane.add("North",toolbar);
pane.add("South",new JLabel("South"));
pane.add("Center",new JLabel("Center"));
frame.pack();
frame.setVisible(true);
}
static JButton createButton(String label){
JButton b = new JButton();
Font f = b.getFont();
Font newFont = new Font(f.getName(),f.getStyle(),9);
b.setFont(newFont);
b.setText(label);
return b;
}
}
(Review ID: 25096)
======================================================================
- duplicates
-
JDK-4102059 FontMetrics.stringWidth & Graphics.drawString do not agree on length
-
- Closed
-