1

I want to run my application in different platform and i want to use different look and feel for each platform. could you please guide how can approach this?

This is what i did. in main java class i added static block and by adding below condition.

if(System.getProperty("os.name").startsWith("Windows")) //Added for linux
{
  UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
}
else
{
  UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
}

When I run my application in linux platform, it is not showing metal look and feel rather it's showing java default look and feel mainly in JOptionPane.

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
user1280096
  • 137
  • 1
  • 1
  • 9

2 Answers2

2

Perhaps your answer is available here: http://docs.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html

Or read into this SO question: How to set jframe look and feel

Community
  • 1
  • 1
Chris Mukherjee
  • 841
  • 9
  • 25
  • yes now I getting what i expected. but the JOptionPane shows without title bar. could you please help me? – user1280096 Jun 21 '13 at 07:23
  • That may be an unrelated problem. Please post some code. It would be better to open another question for this second problem. Post a link to the new question as a comment here and I will try to help. – Chris Mukherjee Jun 21 '13 at 18:42
  • Also, feel free to accept my solution above if it helped (even though it wasn't a direct solution, and was actually more of a guide to the right solution). Your choice. – Chris Mukherjee Jun 21 '13 at 18:43
2

Use the System Look And Feel.

UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433