How to get Java GUI to look like Windows


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 6 of 6

Thread: How to get Java GUI to look like Windows

Hybrid View

  1. #1
    Join Date
    Apr 2006
    Posts
    6

    How to get Java GUI to look like Windows

    I am diving into Java, and I wanted to create a simple program with two text boxes, a few labels, and a button.

    The problem is, I want the java program to look exactly like a windows program does. I am talking about window decorations and button styles, etc.

    When I use swing to create my GUI, it looks javaish. How can I make it look windowsish?

    (Yes, I have set the "JFrame.setDefaultLookAndFeelDecorated" to false.

  2. #2
    Join Date
    Apr 2006
    Posts
    16
    hi,
    use java.awt.* instead of javax.swing.* and read java.awt.* api because in this api JButton is Button like that so read that and use it to look the gui same as windows look

    Regards

    Rahul Vyas

  3. #3
    Join Date
    Feb 2006
    Location
    Cologne - Germany
    Posts
    271
    you can also do it within swing, since swing has a plugable look and feel. see http://java.sun.com/docs/books/tutor...misc/plaf.html

  4. #4
    Join Date
    Mar 2005
    Location
    UK, London
    Posts
    150
    Add this code to your main method.

    Code:
    try
    {
    UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
    }
    
    catch (Exception e)
    {
    System.out.println("Unable to load Windows look and feel");
    }

  5. #5
    Join Date
    Apr 2006
    Posts
    6
    All of your suggestions worked great. I am going to use the last, because my code is already in swing.

    Thanks.

  6. #6
    Join Date
    May 2013
    Posts
    1

    Question What about changing back?

    Apreciated the post and the answer but i have another question:

    What about changing back to Java's look ?

    I was thinking about inserting an option where the user could switch between them.
    Thanks.

Similar Threads

  1. Replies: 0
    Last Post: 02-01-2002, 12:08 AM
  2. Replies: 1
    Last Post: 03-27-2001, 11:45 AM
  3. Replies: 0
    Last Post: 09-26-2000, 10:52 AM
  4. Re: VB vs. Visual Age for Java
    By JJ in forum Enterprise
    Replies: 1
    Last Post: 07-06-2000, 05:50 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center