Results 1 to 5 of 5
Thread: Help on Look and Feel
- 05-05-2010, 03:08 AM #1
Senior Member
- Join Date
- Apr 2010
- Location
- Philippines
- Posts
- 580
- Rep Power
- 4
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,
gejeLast edited by mine0926; 05-05-2010 at 03:36 AM.
- 05-05-2010, 04:04 AM #2
Senior Member
- Join Date
- Apr 2010
- Location
- Philippines
- Posts
- 580
- Rep Power
- 4
Ok, I was able to change the frmLogin LookandFeel to Nimbus now. I just place the code to:
Before the code was placed in: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); } }); }
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
- 05-05-2010, 04:11 AM #3
Senior Member
- Join Date
- May 2010
- Posts
- 436
- Rep Power
- 4
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:
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.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
- 05-05-2010, 04:24 AM #4
Senior Member
- Join Date
- Apr 2010
- Location
- Philippines
- Posts
- 580
- Rep Power
- 4
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
- 05-05-2010, 04:27 AM #5
Senior Member
- Join Date
- May 2010
- Posts
- 436
- Rep Power
- 4
Similar Threads
-
Look and Feel of GUI
By titir in forum AWT / SwingReplies: 9Last Post: 04-21-2010, 01:34 PM -
About look and feel
By makpandian in forum AWT / SwingReplies: 6Last Post: 02-13-2009, 02:55 AM -
Look and Feel
By Stein in forum New To JavaReplies: 10Last Post: 10-03-2008, 04:07 AM -
A Look-and-feel switcher
By Java Tip in forum javax.swingReplies: 0Last Post: 06-26-2008, 07:45 PM -
Look and Feel
By arun_kumar in forum AWT / SwingReplies: 1Last Post: 11-17-2007, 06:21 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks