• Post Reply Bookmark Topic Watch Topic
  • New Topic

Can I set different look & feel for different components in the same frame?  RSS feed

 
Pomchi Bedi
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Can I set different look and feel for different components in the same frame.......or for different frames in the same application??
Thanks
Pomchi
 
Manfred Leonhardt
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Pomchi,
I have not personally done it, but check out the API on the package:
javax.swing.plaf.multi
it seems to be what you want.
Regards,
Manfred.
 
Wirianto Djunaidi
Ranch Hand
Posts: 210
Ruby Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, you can do it using javax.swing.UIManager.setLookAndFeel().
 
Pomchi Bedi
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks but is there any way where I can say setLookAndFeel for this component only.

Regards
Pomchi

[This message has been edited by Pomchi Bedi (edited June 15, 2001).]
 
Wirianto Djunaidi
Ranch Hand
Posts: 210
Ruby Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can, basically once you declare a certain LookAndFeel,
all component have the that LookAndFeel until you change
the LookAndFeel.
Here's an example:
<pre>
import javax.swing.*;
import java.awt.*;
public class LaF
{
public static void main( String[] args )
{
JFrame f = new JFrame( "Look and Feel" );
f.setSize( 200, 200 );
f.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
UIManager.LookAndFeelInfo[] info = UIManager.getInstalledLookAndFeels();
for ( int i = 0; i < info.length ; i++ )
{
System.out.println( info[i].getClassName() );

Container c = f.getContentPane();

c.setLayout( new FlowLayout() );

try
{
UIManager.setLookAndFeel( info[i].getClassName() );
}
catch (Exception e)
{
e.printStackTrace();
}

c.add( new JButton( info[i].getName() ) );
c.add( new JCheckBox( info[i].getName() ) );
}

f.setVisible( true );
}
}
</pre>
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!