Java examples for Swing:JFrame
The JFrame class supports a setType method.
setType method configures the general appearance of a window to one of the three types.
setType method can simplify the setting of a window's appearance.
import java.awt.FlowLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JButton; import javax.swing.JFrame; import java.awt.GraphicsDevice; import java.awt.GraphicsEnvironment; import javax.swing.JFrame; import javax.swing.SwingUtilities; public class Main extends JFrame { public Main() { this.setTitle("Example"); this.setBounds(100, 100, 200, 200); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setType(Type.UTILITY); this.setLayout(new FlowLayout()); /*from www . j a va2 s . c om*/ JButton exitButton = new JButton("Exit"); this.add(exitButton); exitButton.addActionListener(event->System.exit(0)); } public static void main(String[] args) { SwingUtilities.invokeLater(() ->{ Main window = new Main(); window.setVisible(true); }); } }
To set the window type, use the setType method with one of the three window types: