DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 6 of 6

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: 01-31-2002, 11:08 PM
  2. Replies: 1
    Last Post: 03-27-2001, 10:45 AM
  3. Replies: 0
    Last Post: 09-26-2000, 09:52 AM
  4. Re: VB vs. Visual Age for Java
    By JJ in forum Enterprise
    Replies: 1
    Last Post: 07-06-2000, 04:50 AM

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
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links