Make a JFrame looks like a JDialog : JRootPane « Swing « Java Tutorial






import java.awt.Dimension;

import javax.swing.JFrame;
import javax.swing.JRootPane;

public class Main extends JFrame {

  public Main() {
    setTitle("like JDialog");
    setSize(new Dimension(500, 100));
    setUndecorated(true);
    setResizable(false);
    getRootPane().setWindowDecorationStyle(JRootPane.PLAIN_DIALOG);
    setLocationRelativeTo(null);
    setDefaultCloseOperation(EXIT_ON_CLOSE);
  }

  public static void main(String[] args) {
    new Main().setVisible(true);
  }
}








14.84.JRootPane
14.84.1.JRootPane
14.84.2.Setting Window Decoration StyleSetting Window Decoration Style
14.84.3.Setting the default buttonSetting the default button
14.84.4.Interact directly with the JRootPane of a JFrame
14.84.5.Make a JFrame looks like a JDialog
14.84.6.Customizing JRootPane Look and Feel