Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / February 2005

Tip: Looking for answers? Try searching our database.

Tried to follow Java Look and Feel Design Guidelines?

Thread view: 
Dirk Starke - 22 Feb 2005 15:57 GMT
Hello Java-GUI-Developers,

did anyone ever try to develop a Java GUI conforming with Sun's "Java
Look and Feel Design Guidelines"? I receive the impression this is a
hard job. I tried to implement a layout with two radiobuttons with the
below-mentioned code. Somehow the vertical distance between these two
radiobuttons is 11 pixels, not 5 like I intended. Even if I set the
buttons margins to zero I do not reach a 5 pixels distance.
The same problem with checkboxes.

What do I do wrong? Or did Sun's swinging programmers have something
roomier in mind when constructing the metal look and feel?  ;o)

Greetings
   Dirk

import java.awt.Color;
import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.WindowConstants;

public class RadioButtonExampleGB extends JPanel {
 JRadioButton startAtTopRadioButton = new JRadioButton();
 JRadioButton wrapAroundRadioButton = new JRadioButton();

 public RadioButtonExampleGB() {
   init();
 }

 public static void main(String[] args) {
   RadioButtonExampleGB radioButtonExampleGB = new
RadioButtonExampleGB();
   JFrame frame = new JFrame("RadioButtonExampleGB");
   frame.getContentPane().add(radioButtonExampleGB);
   frame.pack();
   frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
   frame.setVisible(true);
 }

 private void init() {
   setLayout(new GridBagLayout());
   setBackground(Color.blue);

   startAtTopRadioButton.setText("Match Case");
//    startAtTopRadioButton.setMargin(new Insets(0, 0, 0, 0));
   startAtTopRadioButton.setBackground(Color.green);
   wrapAroundRadioButton.setText("Whole Word");
//    wrapAroundRadioButton.setMargin(new Insets(0, 0, 0, 0));
   wrapAroundRadioButton.setBackground(Color.red);

   GridBagConstraints constraints =
     new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0,
                            GridBagConstraints.NORTHWEST,
                            GridBagConstraints.NONE,
                            new Insets(0, 0, 0, 0), 0, 0);

   add(startAtTopRadioButton, constraints);

   constraints.gridy++;
   add(wrapAroundRadioButton, constraints);
 }
}
Karsten Lentzsch - 22 Feb 2005 19:23 GMT
Hallo,

I recommend to not follow the Java L&f Design Guidelines;
the Windows Layout Guidelines are much more useful for both
pure Windows and multiplatform design; you should just mix in
some extras for Aqua and Linux.

The Java L&f Design Guidelines is based on pixel sizes.
And that's a pretty poor approach on window systems that
allow to change the font, font size and screen resolution.
Pixel sizes are only approapriate if you can't change
the font - as is the case for most fonts on Aqua.
Next, the Java L&f Design Guidelines are specific to
the Java L&f and work poorly with other professional L&fs
such as Apple's Aqua L&f and winlaf or JGoodies Windows L&f.

You can read more about these issues in two presentations
that you can find at my JGoodies articles pages, see
http://www.jgoodies.com/articles/

The JGoodies Windows L&f has been designed to fix many
micro-design issues in the implementation; so it aims
to make things consistent and matches the MS guidelines.
The JGoodies Plastic L&f family uses similar component
bounds and so allows to design for Windows and other
platforms in a high quality cheaply. Downloads are free:
http://www.jgoodies.com/downloads/libraries.html

The JGoodies Forms layout system provides helper classes
that utilize the underlying FormLayout and help you
follow multiple style guides with a single layout spec.
See the "Layout and Panel Building" presentation. See
http://www.jgoodies.com/downloads/libraries.html

Hope this helps. Regards,
Karsten Lentzsch


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.