-
Bug
-
Resolution: Fixed
-
P4
-
5.0
-
b68
-
generic
-
generic
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8098694 | emb-9 | Sergey Bylokhov | P4 | Resolved | Fixed | team |
JSpinner reflects new font only once at runtime. After this even if setFont is invoked, it does not reflect the new font.
Compile and Run JSpinnerTest.java
A new Font is set in loop at runtime. Its noted that JSpinner reflects the new font for first loop. On subsequent loop, even though jSpinner.getFont returns the updated font, its not reflected on screen.
Adding "JSpinnerTest.java" here so it will be visible to the community.
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class JSpinnerTest {
private static final String metal =
"javax.swing.plaf.metal.MetalLookAndFeel";
private static final String motif =
"com.sun.java.swing.plaf.motif.MotifLookAndFeel";
private static final String windowsXP =
"com.sun.java.swing.plaf.windows.WindowsLookAndFeel";
private static final String windowsClassic =
"com.sun.java.swing.plaf.windows.WindowsClassicLookAndFeel";
private static final String gtk =
"com.sun.java.swing.plaf.gtk.GTKLookAndFeel";
static int fontSize = 20;
static JSpinner spinner = new JSpinner();
public static void main(String args[]) throws Exception {
//UIManager.setLookAndFeel(windowsXP);
JFrame frame = new JFrame();
frame.getContentPane().setLayout(new FlowLayout(FlowLayout.CENTER, 50, 50));
frame.getContentPane().add(spinner);
frame.pack();
frame.setVisible(true);
Thread thread = new Thread() {
public void run() {
try {
sleep(3000);
} catch (Exception e) {}
while(true) {
Font font = new Font("dialog", Font.BOLD, fontSize);
spinner.setFont(font);
System.out.println(spinner.getFont());
fontSize += 5;
try {
sleep(2000);
} catch (Exception e) {}
}
}
};
thread.start();
}
}
Compile and Run JSpinnerTest.java
A new Font is set in loop at runtime. Its noted that JSpinner reflects the new font for first loop. On subsequent loop, even though jSpinner.getFont returns the updated font, its not reflected on screen.
Adding "JSpinnerTest.java" here so it will be visible to the community.
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class JSpinnerTest {
private static final String metal =
"javax.swing.plaf.metal.MetalLookAndFeel";
private static final String motif =
"com.sun.java.swing.plaf.motif.MotifLookAndFeel";
private static final String windowsXP =
"com.sun.java.swing.plaf.windows.WindowsLookAndFeel";
private static final String windowsClassic =
"com.sun.java.swing.plaf.windows.WindowsClassicLookAndFeel";
private static final String gtk =
"com.sun.java.swing.plaf.gtk.GTKLookAndFeel";
static int fontSize = 20;
static JSpinner spinner = new JSpinner();
public static void main(String args[]) throws Exception {
//UIManager.setLookAndFeel(windowsXP);
JFrame frame = new JFrame();
frame.getContentPane().setLayout(new FlowLayout(FlowLayout.CENTER, 50, 50));
frame.getContentPane().add(spinner);
frame.pack();
frame.setVisible(true);
Thread thread = new Thread() {
public void run() {
try {
sleep(3000);
} catch (Exception e) {}
while(true) {
Font font = new Font("dialog", Font.BOLD, fontSize);
spinner.setFont(font);
System.out.println(spinner.getFont());
fontSize += 5;
try {
sleep(2000);
} catch (Exception e) {}
}
}
};
thread.start();
}
}
- backported by
-
JDK-8098694 JSpinner does not reflect new font on subsequent calls to setFont
-
- Resolved
-
- relates to
-
JDK-8085836 [PIT] Layout looks someway broken in JSpinner
-
- Closed
-