Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.gui > #156

Windows XP Platform Look

From "Ian Wilson" <ian.wilson@THRWHITE.remove-dii-this>
Subject Windows XP Platform Look
Message-ID <daCdneznw9hh6PnYnZ2dnUVZ8sednZ2d@bt.com> (permalink)
Newsgroups comp.lang.java.gui
Date 2011-04-27 15:25 +0000
Organization TDS.net

Show all headers | View raw


  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

Back to comp.lang.java.gui | Previous | NextNext in thread | Find similar


Thread

Windows XP Platform Look "Ian Wilson" <ian.wilson@THRWHITE.remove-dii-this> - 2011-04-27 15:25 +0000
  Re: Windows XP Platform L "Karsten Lentzsch" <karsten.lentzsch@THRWHITE.remove-dii-this> - 2011-04-27 15:25 +0000
    Re: Windows XP Platform L "Ian Wilson" <ian.wilson@THRWHITE.remove-dii-this> - 2011-04-27 15:25 +0000
      Re: Windows XP Platform L "Karsten Lentzsch" <karsten.lentzsch@THRWHITE.remove-dii-this> - 2011-04-27 15:25 +0000
        Re: Windows XP Platform L "Ian Wilson" <ian.wilson@THRWHITE.remove-dii-this> - 2011-04-27 15:25 +0000

csiph-web