I have a java application that somehow has a different behavior when launched in windows by double clicking the jar file compared to launching it using the command prompt.
The behavior that i'm noticing specifically is when I override a JLabel to render better using the following
lblDate = new ATimeLabel(ATimeLabel.DATE_LETTERS) {
private static final long serialVersionUID = 1L;
@Override
protected void paintComponent(Graphics g) {
Graphics2D g2d = (Graphics2D) g;
g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
g2d.setRenderingHint(RenderingHints.KEY_RENDERING,
RenderingHints.VALUE_RENDER_QUALITY);
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
g2d.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS,
RenderingHints.VALUE_FRACTIONALMETRICS_ON);
super.paintComponent(g2d);
}
};
The effect appears when I launch the app from my IDE or launch the jar from the command prompt but when I double click my app it will show the label without the paintComponent()
overriden effects.
would appreciate help to figure out exactly how to be able to have the same effect happen on double click of my app.
EDIT:
I should also mention that I add the following font changes after creating one of 2 JLabels
lblDate.setForeground(Color.gray);
lblDate.setFont(boldFont.deriveFont(Font.PLAIN, timeFontSize));
Here is a screen shot of what it looks like. The one on the left clearly has the anti-aliasing and clean text rendering i'm looking for while the one on the right is fatter and not as sharp. (I also temporary added the red border to show that the paint method is in effect)
EDIT 2:
Seems that when I double click the JVM is 1.7 and my IDE uses JDK 1.6 I don't understand why the RenderingHints for the fonts wouldn't look the same on Java6 and Java7 they are in both APIs and run without exceptions...
Any help would be appreciated.