Results 1 to 5 of 5
  1. #1
    mine0926 is offline Senior Member
    Join Date
    Apr 2010
    Location
    Philippines
    Posts
    580
    Rep Power
    4

    Default Help on Look and Feel

    I have two Forms. frmLogin and frmMain. I try to change its physical appearance through LookandFeel. Here is the code:
    Java Code:
        try {
        UIManager.setLookAndFeel(new NimbusLookAndFeel());
        }
        catch (Exception e)
        { e.printStackTrace();}

    This code works on frmMain controls but not in frmLogin. I thought that the problem was in property because I changes some but I already change everything in form's property then try if LookandFeel works but still same result. And what makes me more confusing is when I put a JInternalFrame and JOptionDialog under frmLogin, JInternalFrame is in "METAL" LookandFeel and when JOptionDialog pops up it is "NIMBUS" look.


    Thank you in advance,
    geje
    Last edited by mine0926; 05-05-2010 at 03:36 AM.

  2. #2
    mine0926 is offline Senior Member
    Join Date
    Apr 2010
    Location
    Philippines
    Posts
    580
    Rep Power
    4

    Default

    Ok, I was able to change the frmLogin LookandFeel to Nimbus now. I just place the code to:
    Java Code:
        public static void main(String args[]) {
            try {
                UIManager.setLookAndFeel(new NimbusLookAndFeel());
            }
            catch (Exception e)
            { e.printStackTrace();}
    
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    new frmLogin().setVisible(true);
                }
            });
        }
    Before the code was placed in:
    Java Code:
    public class frmLogin extends javax.swing.JFrame {
        public frmLogin() {
            initComponents();
            try {
                UIManager.setLookAndFeel(new NimbusLookAndFeel());
            }
            catch (Exception e)
            { e.printStackTrace();}
     
        }// Creates new form frmLogin
    ...

    Question:
    1. I know that it run base on what I want but is this the right thing to do?
    2. My problem was solved when I place the code to "public static void main(String args[])" (what should I call this? :)),
    but why is it running good in frmMain since the code was place the same with frmLogin?


    Thanks in advance
    geje

  3. #3
    curmudgeon is offline Senior Member
    Join Date
    May 2010
    Posts
    436
    Rep Power
    4

    Default

    I'm not sure I understand your question, and I'm guessing it's because English is not your native language, so if I'm not answering correctly, you may wish to clarify, but previously, here:

    Java Code:
    public class frmLogin extends javax.swing.JFrame {
        public frmLogin() {
            initComponents();
            try {
                UIManager.setLookAndFeel(new NimbusLookAndFeel());
            }
            catch (Exception e)
            { e.printStackTrace();}
     
        }// Creates new form frmLogin
    You appear to be trying to set the look and feel after calling initComponents or after your components have been constructed. I think that it's better setting the look and feel before any component has been constructed.

  4. #4
    mine0926 is offline Senior Member
    Join Date
    Apr 2010
    Location
    Philippines
    Posts
    580
    Rep Power
    4

    Default

    curmadgeon,
    Thanks for pointing me that. Now I understand it more. I thought that for every form I should put the code for LookandFeel that is why it made me think that the same code place in the same class was running good in the one form and not in the other.

    The LookandFeel was already fired when frmMain was shown but in frmLogin the code was not fired yet since I place it after the initComponents();

    That makes my mind clearer... BTW, English is not my native language too so pardon me if my english is bad or my explanation is hard to understant. :)

    Thanks again,
    geje

  5. #5
    curmudgeon is offline Senior Member
    Join Date
    May 2010
    Posts
    436
    Rep Power
    4

    Default

    Quote Originally Posted by mine0926 View Post
    That makes my mind clearer... BTW, English is not my native language too so pardon me if my english is bad or my explanation is hard to understant. :)
    That's no problem. I'd have lots of problems if this forum were in any language but English. I'm not sure how folks who don't speak English as a primary language communicate here at all. Your effort is appreciated.

    Thanks again,
    geje
    You're welcome!

Similar Threads

  1. Look and Feel of GUI
    By titir in forum AWT / Swing
    Replies: 9
    Last Post: 04-21-2010, 01:34 PM
  2. About look and feel
    By makpandian in forum AWT / Swing
    Replies: 6
    Last Post: 02-13-2009, 02:55 AM
  3. Look and Feel
    By Stein in forum New To Java
    Replies: 10
    Last Post: 10-03-2008, 04:07 AM
  4. A Look-and-feel switcher
    By Java Tip in forum javax.swing
    Replies: 0
    Last Post: 06-26-2008, 07:45 PM
  5. Look and Feel
    By arun_kumar in forum AWT / Swing
    Replies: 1
    Last Post: 11-17-2007, 06:21 PM

Posting Permissions

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