import javax.swing.*; public class MyFrame extends JFrame { public MyFrame() { try { UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()); } catch (Exception e) { e.printStackTrace(); } // Other code to set up the frame... } }
import javax.swing.*; public class MyApp { public static void main(String[] args) { try { UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()); } catch (Exception e) { e.printStackTrace(); } JFrame frame = new JFrame("My App"); // Other code to set up the frame... frame.setVisible(true); } }In this example, we are setting the look and feel of the JFrame to the cross-platform look and feel in the main method of our application. The package library for javax.swing.UIManager is the Java Swing library.