import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
public class Frame {
private JFrame jFrame;
public Frame() {
try {
UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
JFrame.setDefaultLookAndFeelDecorated(true);
JDialog.setDefaultLookAndFeelDecorated(true);
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException e) {
e.printStackTrace();
}
}
private void create() {
jFrame = new JFrame("frame");
jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
jFrame.setSize(200, 200);
jFrame.setVisible(true);
}
public static void main(String[] args) {
new Frame().create();
}
}
The code above works fine but if I set jFrame.undecorated to true, it doesn't remove the frame? Does anyone know why not? Thanks.
Edit: Also found that if I set jFrame.undecorated to false, another frame with default look and feel also displays. Like this: