-
Bug
-
Resolution: Fixed
-
P3
-
1.0.2, 1.2.0
-
None
-
swing1.1
-
generic, x86, sparc
-
generic, solaris_2.6, windows_nt
Example. For the text "Lights Tool" the metal JTextArea gives a
preferredSize of "126 x 21" and on Motif (which looks correct
it is "90 x 21".
---------------------------------------------
I was initally fooled by this description, so I'm going to add more here.
Here is an ASCII representation of the problem
Motif:
---------------
| Lights Tool |
---------------
Metal:
-----------------------------
| Lights Tool |
-----------------------------
This is with Swing-1.0.2. The problem however is not limited to Metal or Motif. It happens that Motif uses Monospaced as it's font, but Metal uses SansSerif. I experimented with other fonts and it seems to only get the right answer with Monospaced. Dialog font returns strange answers as well.
Here is a sample program I wrote to demonstrate the problem.
import com.sun.java.swing.*;
import com.sun.java.swing.border.*;
import java.awt.*;
class Scratch {
public static void main(String[] args) {
try {
UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel");
System.out.println("set motif");
} catch (Exception e) {
System.out.println(e);
}
JTextArea area = new JTextArea();
area.setBorder(new LineBorder(Color.black));
area.setText("Lights Tool");
area.setFont(new Font("Dialog", Font.PLAIN, 12));
System.out.println(area.getPreferredSize());
System.out.println(area.getFont());
JFrame f = new JFrame();
f.getContentPane().add(area);
f.getContentPane().setLayout(new FlowLayout());
f.pack();
f.show();
}
}
When you run it, you will see that the TextArea stays about 2x as wide as it needs to be.
steve.wilson@eng 1998-05-20
preferredSize of "126 x 21" and on Motif (which looks correct
it is "90 x 21".
---------------------------------------------
I was initally fooled by this description, so I'm going to add more here.
Here is an ASCII representation of the problem
Motif:
---------------
| Lights Tool |
---------------
Metal:
-----------------------------
| Lights Tool |
-----------------------------
This is with Swing-1.0.2. The problem however is not limited to Metal or Motif. It happens that Motif uses Monospaced as it's font, but Metal uses SansSerif. I experimented with other fonts and it seems to only get the right answer with Monospaced. Dialog font returns strange answers as well.
Here is a sample program I wrote to demonstrate the problem.
import com.sun.java.swing.*;
import com.sun.java.swing.border.*;
import java.awt.*;
class Scratch {
public static void main(String[] args) {
try {
UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel");
System.out.println("set motif");
} catch (Exception e) {
System.out.println(e);
}
JTextArea area = new JTextArea();
area.setBorder(new LineBorder(Color.black));
area.setText("Lights Tool");
area.setFont(new Font("Dialog", Font.PLAIN, 12));
System.out.println(area.getPreferredSize());
System.out.println(area.getFont());
JFrame f = new JFrame();
f.getContentPane().add(area);
f.getContentPane().setLayout(new FlowLayout());
f.pack();
f.show();
}
}
When you run it, you will see that the TextArea stays about 2x as wide as it needs to be.
steve.wilson@eng 1998-05-20
- duplicates
-
JDK-4131141 WindowNT, metal: JScrollPane shows a scrollbar when it should not be seen
-
- Closed
-
-
JDK-4137295 JTextArea is being displayed incorrectly in Java LAF (Swing 1.0.2).
-
- Closed
-
-
JDK-4143490 JTextArea in a JScrollpane does not work properly
-
- Closed
-