-
Bug
-
Resolution: Not an Issue
-
P4
-
None
-
6u16
-
x86
-
windows_xp
FULL PRODUCT VERSION :
java version "1.5.0_09"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_09-b03)
Java HotSpot(TM) Client VM (build 1.5.0_09-b03, mixed mode, sharing)
And
java version "1.6.0_10"
Java(TM) SE Runtime Environment (build 1.6.0_10-b33)
Java HotSpot(TM) Client VM (build 11.0-b15, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
WIndows XP
A DESCRIPTION OF THE PROBLEM :
Got the size of menu.Font from UIManager and created the PLAIN format Font object using the size obtained from Font obtained from UIManager.
Set this Font to JTextArea. Got the Preferred width from JTextArea.
The width returns the different values in versions Java 1.5.0_09 and Java 1.6.0_10.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The Preferred width values returned after the Font is set to JTextArea should be the same in both versions of Java
ACTUAL -
The width values returned by using preferredSize() method of JTextArea differs.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.Dimension;
import java.awt.Font;
import java.awt.FontMetrics;
import javax.swing.JFrame;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
public class TestJTextField {
/**
* Create the GUI and show it. For thread safety,
* this method should be invoked from the
* event-dispatching thread.
*/
private static void createAndShowGUI() {
Dimension dim;
int height,width;
//Make sure we have nice window decorations.
//JFrame.setDefaultLookAndFeelDecorated(true);
String name = UIManager.getSystemLookAndFeelClassName();
try {
UIManager.setLookAndFeel(name);
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InstantiationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalAccessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (UnsupportedLookAndFeelException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
//Create and set up the window.
JFrame frame = new JFrame("HelloWorldSwing");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//Add the ubiquitous "Hello World" label.
JTextField jtf = new JTextField();
frame.getContentPane().add(jtf);
Font workingFont = UIManager.getFont("Menu.font");
int desiredSize = workingFont.getSize();
JTextArea jta = new JTextArea(1,1);
workingFont = new Font("Display",Font.PLAIN,desiredSize);
jta.setFont(workingFont);
dim = jta.getPreferredSize();
height = dim.height;
width = dim.width;
System.out.println("width is"+ width);
//Display the window.
frame.pack();
frame.setVisible(true);
}
public static void main(String[] args) {
//Schedule a job for the event-dispatching thread:
//creating and showing this application's GUI.
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
createAndShowGUI();
}
});
}
}
---------- END SOURCE ----------
java version "1.5.0_09"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_09-b03)
Java HotSpot(TM) Client VM (build 1.5.0_09-b03, mixed mode, sharing)
And
java version "1.6.0_10"
Java(TM) SE Runtime Environment (build 1.6.0_10-b33)
Java HotSpot(TM) Client VM (build 11.0-b15, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
WIndows XP
A DESCRIPTION OF THE PROBLEM :
Got the size of menu.Font from UIManager and created the PLAIN format Font object using the size obtained from Font obtained from UIManager.
Set this Font to JTextArea. Got the Preferred width from JTextArea.
The width returns the different values in versions Java 1.5.0_09 and Java 1.6.0_10.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The Preferred width values returned after the Font is set to JTextArea should be the same in both versions of Java
ACTUAL -
The width values returned by using preferredSize() method of JTextArea differs.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.Dimension;
import java.awt.Font;
import java.awt.FontMetrics;
import javax.swing.JFrame;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
public class TestJTextField {
/**
* Create the GUI and show it. For thread safety,
* this method should be invoked from the
* event-dispatching thread.
*/
private static void createAndShowGUI() {
Dimension dim;
int height,width;
//Make sure we have nice window decorations.
//JFrame.setDefaultLookAndFeelDecorated(true);
String name = UIManager.getSystemLookAndFeelClassName();
try {
UIManager.setLookAndFeel(name);
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InstantiationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalAccessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (UnsupportedLookAndFeelException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
//Create and set up the window.
JFrame frame = new JFrame("HelloWorldSwing");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//Add the ubiquitous "Hello World" label.
JTextField jtf = new JTextField();
frame.getContentPane().add(jtf);
Font workingFont = UIManager.getFont("Menu.font");
int desiredSize = workingFont.getSize();
JTextArea jta = new JTextArea(1,1);
workingFont = new Font("Display",Font.PLAIN,desiredSize);
jta.setFont(workingFont);
dim = jta.getPreferredSize();
height = dim.height;
width = dim.width;
System.out.println("width is"+ width);
//Display the window.
frame.pack();
frame.setVisible(true);
}
public static void main(String[] args) {
//Schedule a job for the event-dispatching thread:
//creating and showing this application's GUI.
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
createAndShowGUI();
}
});
}
}
---------- END SOURCE ----------