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


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

Re: Windows XP Platform L

From "Ian Wilson" <ian.wilson@THRWHITE.remove-dii-this>
Subject Re: Windows XP Platform L
Message-ID <0t6dnQQq6ZVbLPjYRVnyuw@bt.com> (permalink)
Newsgroups comp.lang.java.gui
References <ek22c4$hjd$01$1@news.t-online.com>
Date 2011-04-27 15:25 +0000
Organization TDS.net

Show all headers | View raw


  To: comp.lang.java.gui
Karsten Lentzsch wrote:
> Ian Wilson wrote:
> 
>> [...]
>> 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.
> 
> 
> The JGoodies Windows L&f uses the native command button margins
> by default. You can get wider non-native margins by calling
> Options#setUseNarrowButtons(false)

Thanks Karsten,

I have now tried that (see test app [1] below) but didn't see any 
difference in the button margins. I've had a quick glance at the Looks 
docs but don't yet see where I am going wrong.


> If you want to comply with the Windows style guide
> you should use the native margins, and ensure a
> minimum command button width of 50 Dialog Units.

If I was using JGoodies FormLayout then using DLUs would be easy. 
However I have used a mixture of other layout managers and don't relish 
the idea of conversion (just yet anyway).

In my real app, to get equal sized buttons, I am doing this:
         Dimension buttonSize = (
                new JButton("XXXXXXXX")).getPreferredSize();
         okButton.setPreferredSize(buttonSize);
         cancelButton.setPreferredSize(buttonSize);
This is horrible but will suffice until I find something better, or 
until I need to localize the label text, or ...  :-)



[1] Test program showing no effect from Options.setUseNarrowButtons(false)
-----------------------------------8<----------------------------------
import java.awt.BorderLayout;

import javax.swing.JButton;
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;

import com.jgoodies.looks.Options;
import com.jgoodies.looks.windows.WindowsLookAndFeel;

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(new WindowsLookAndFeel());
         } catch (Exception e) {
             System.out.println("Unable to set LAF");
         }
         Options.setUseNarrowButtons(false); // ******************
         JFrame.setDefaultLookAndFeelDecorated(true);
         JFrame frame = new JFrame();
         frame.setTitle("Testing fonts");
         JPanel p = (JPanel) frame.getContentPane();
         p.setLayout(new BorderLayout());
         p.add(new TestFonts(), BorderLayout.CENTER);
         p.add(new ButtonPanel(), BorderLayout.SOUTH);

         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();
             }
         });
     }
}

class ButtonPanel extends JPanel {
     ButtonPanel() {
         add(new JButton("OK"));
         add(new JButton("Cancel"));
     }
}
-----------------------------------8<----------------------------------

---
 * 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 | NextPrevious in thread | Next 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