Path: csiph.com!x330-a1.tempe.blueboxinc.net!feeder1.hal-mli.net!news.glorb.com!news-out.readnews.com!transit3.readnews.com!news-out.news.tds.net!newsreading01.news.tds.net!86597e80!not-for-mail From: "Ian Wilson" Subject: Windows XP Platform Look Message-ID: X-Comment-To: comp.lang.java.gui Newsgroups: comp.lang.java.gui Content-Type: text/plain; charset=IBM437 Content-Transfer-Encoding: 8bit X-Gateway: time.synchro.net [Synchronet 3.15a-Win32 NewsLink 1.92] Lines: 72 Date: Wed, 27 Apr 2011 15:25:55 GMT NNTP-Posting-Host: 96.60.20.240 X-Complaints-To: news@tds.net X-Trace: newsreading01.news.tds.net 1303917955 96.60.20.240 (Wed, 27 Apr 2011 10:25:55 CDT) NNTP-Posting-Date: Wed, 27 Apr 2011 10:25:55 CDT Organization: TDS.net Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.gui:156 To: comp.lang.java.gui I'm trying to get my Swing app to look like a native XP app when run on XP. In the example below, when run on Windows XP, I find the font used in the JSpinner is considerably larger than that used in the JTextField and JLabel. The main problem is that antialiasing badly affects the clarity of the digit "2" in the JSpinner. Is this a common occurrence or am I doing something very unusual? What do other people do? ---------------------------------8<--------------------------------- import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JSpinner; import javax.swing.JTextField; import javax.swing.SpinnerDateModel; import javax.swing.UIManager; public class TestFonts extends JPanel { TestFonts() { add(new JLabel("Lorem Ipsum 21/11/2006")); add(new JTextField("Foo", 4)); SpinnerDateModel dateModel = new SpinnerDateModel(); JSpinner dateSpinner = new JSpinner(dateModel); dateSpinner.setEditor(new JSpinner.DateEditor(dateSpinner, "dd/MM/yyyy")); add(dateSpinner); } private static void createAndShowGUI() { String antialiasing = "swing.aatext"; if (null == System.getProperty(antialiasing)) System.setProperty(antialiasing, "true"); try { UIManager.setLookAndFeel( UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) { System.out.println("Unable to set LAF"); } JFrame.setDefaultLookAndFeelDecorated(true); JFrame frame = new JFrame(); frame.setTitle("Testing fonts"); frame.getContentPane().add(new TestFonts()); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); frame.setVisible(true); } public static void main(String[] args) { javax.swing.SwingUtilities.invokeLater(new Runnable() { public void run() { createAndShowGUI(); } }); } } ---------------------------------8<--------------------------------- P.S. JGoodies WindowsLookAndFeel eliminates these problems. However it does ugly things to JButton sizes (presumably because JForms handles this) which I have to work around. --- * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet! --- Synchronet 3.15a-Win32 NewsLink 1.92 Time Warp of the Future BBS - telnet://time.synchro.net:24