Page 2 of 2 FirstFirst 12
Results 11 to 18 of 18

Thread: Making Java GUI's look good

  1. #11
    Join Date
    Nov 2007
    Location
    New Zealand
    Beans
    1,026
    Distro
    Ubuntu 11.04 Natty Narwhal

    Re: Making Java GUI's look good

    I've been happy with the Sun JRE version.

    The following command will tell you for sure what JRE you are using.

    Code:
    java -version
    You may have multiple JRE's on your machine, if this is the case then synaptic package manager may tell you that you have the Sun JRE installed but you will not actually be using it when you invoke the "java" command. The above java version command will tell you what JRE you are using.

    Also, there are three things you can do to get Java GUI's looking better without too much work.

    1. Using the "native look and feel".
    2. Create your own base JPanel class and enable antialiasing.

    Code:
    public class JBasePanel extends JPanel {
        @Override
        public void paint(Graphics g){
            Graphics2D g2d = (Graphics2D) g;
            g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, 
                    RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
        }
    }
    All panels you create should extend this.

    3. Manually set your fonts to something sensible like arial.

    There are a lot of other things you can do, the above tips are just the easy ones.

  2. #12
    Join Date
    Jul 2008
    Beans
    7

    Re: Making Java GUI's look good

    Yeah, thanks Tinny. I'm using native L&F, and setting the antialiasing, etc. The most obvious "ick" I have is I override JButton to paint my own border and generally give it my own look. The border doesn't paint nicely.

    I read here (and confirmed on the fedora 9 release notes) that the openjdk (which I am using) is a blend of Sun and IcedTea. I suspect that the "blending" is causing me trouble. I'll check it out when I get the chance, and come back here if I figure something else out. Thanks again!

  3. #13
    Join Date
    Nov 2007
    Location
    New Zealand
    Beans
    1,026
    Distro
    Ubuntu 11.04 Natty Narwhal

    Re: Making Java GUI's look good

    Yeah, thanks Tinny. I'm using native L&F, and setting the antialiasing, etc. The most obvious "ick" I have is I override JButton to paint my own border and generally give it my own look. The border doesn't paint nicely.
    Have a look at the Substance l&f library, it has some very nice buttons.

    You can see these in the Demo application by using web start.

  4. #14
    Join Date
    Jul 2008
    Location
    Athens, Georgia
    Beans
    228

    Re: Making Java GUI's look good

    Quote Originally Posted by tinny View Post

    1. Using the "native look and feel".
    Good call - best way to change the "platform" appearance. You can actually alter the look-and-feel from the native to some other style in the UIManager (packaged in javax.swing). You can load the installed versions into an array using UIManager.getInstalledLookAndFeels() (the array should be of type UIManager.LookAndFeelInfo) You can then use UIManager.setLookAndFeel(<array reference>[value].getClassName()) to test out the look-and-feels until you find one you like! There should be one that looks very much like Windows GUIs.

  5. #15
    Join Date
    Nov 2007
    Beans
    108

    Re: Making Java GUI's look good

    1. Using the "native look and feel".
    Yeah, unless it happens to be GTK+ If you don't believe me, create a JComboBox and see what happens. I had to go back to metal in some of my apps because of that.


    Though it seems like Sun is about to release a new default look and feel called Nimbus. There is a screenshot at this page:
    http://java.sun.com/developer/techni...vase/java6u10/

  6. #16
    Join Date
    Nov 2007
    Location
    New Zealand
    Beans
    1,026
    Distro
    Ubuntu 11.04 Natty Narwhal

    Re: Making Java GUI's look good

    Quote Originally Posted by Phristen View Post
    Yeah, unless it happens to be GTK+ If you don't believe me, create a JComboBox and see what happens. I had to go back to metal in some of my apps because of that.


    Though it seems like Sun is about to release a new default look and feel called Nimbus. There is a screenshot at this page:
    http://java.sun.com/developer/techni...vase/java6u10/
    Sorry its not default.

    For compatibility reasons, Metal is still the default Swing look and feel, but updating applications to use Nimbus couldn't be simpler. It only takes a single line of code:
    Maybe you meant that it is one of the default "set" of look and feels?

    Here is a web start application that demos this look and feel. Looks like they have borrowed some ideas from apple.
    Last edited by tinny; July 11th, 2008 at 05:20 AM.

  7. #17
    Join Date
    Nov 2007
    Beans
    108

    Re: Making Java GUI's look good

    Maybe you meant that it is one of the default "set" of look and feels?
    Evidently

  8. #18
    Join Date
    Jun 2006
    Location
    The Netherlands
    Beans
    2,185
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: Making Java GUI's look good

    Quote Originally Posted by dhimes View Post
    So, is openjdk-6-jre Sun's version? I thought they just open-sourced what they had.
    Quote Originally Posted by bruce89 View Post
    Suprisingly, no. I think it's a forked version of Sun's OpenJDK with the non-free bits replaced.

    OpenJDK when released had about 95% source available, meaning the other 5 had to be replaced.
    OpenJDK is Sun's project to make a 100% open source Java. It is exactly the same as Sun Java, but with the last proprietary parts (partly) replaced by open source parts. It's not 100% complete yet, but works well for almost everything.
    Ubuntu 12.04

Page 2 of 2 FirstFirst 12

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •