List of usage examples for javax.swing JFrame JFrame
public JFrame(String title) throws HeadlessException
Frame
with the specified title. From source file:Main.java
public static void main(String[] a) { JFrame frame = new JFrame("JFileChooser Popup"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JFileChooser fileChooser = new JFileChooser("."); int mu = fileChooser.getApproveButtonMnemonic(); frame.add(fileChooser, BorderLayout.CENTER); frame.pack();/*from ww w . ja va2 s . c om*/ frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame("JFrame"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container contentPane = frame.getContentPane(); // Add a close button JButton closeButton = new JButton("Close"); contentPane.add(closeButton);/*from w w w .j a va 2 s .c o m*/ closeButton.addActionListener(e -> { System.out.println(e.getActionCommand()); System.exit(0); }); frame.pack(); frame.setVisible(true); }
From source file:SizingWindowswithToolkit.java
public static void main(String[] args) { JFrame aWindow = new JFrame("This is the Window Title"); Toolkit theKit = aWindow.getToolkit(); Dimension wndSize = theKit.getScreenSize(); aWindow.setBounds(wndSize.width / 4, wndSize.height / 4, // Position wndSize.width / 2, wndSize.height / 2); // Size aWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); aWindow.setVisible(true);//from w w w . ja va 2 s .co m }
From source file:SwingSplitSample.java
public static void main(String args[]) { JFrame frame = new JFrame("JSplitPane Sample"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JSplitPane splitPane = new JSplitPane(); splitPane.setOrientation(JSplitPane.HORIZONTAL_SPLIT); frame.getContentPane().add(splitPane, BorderLayout.CENTER); frame.setSize(300, 200);/* w w w. j a v a 2 s . c o m*/ frame.setVisible(true); }
From source file:CenteringaWindow.java
public static void main(String[] args) { JFrame aWindow = new JFrame("This is the Window Title"); Point center = GraphicsEnvironment.getLocalGraphicsEnvironment().getCenterPoint(); int windowWidth = 400; int windowHeight = 150; // set position and size aWindow.setBounds(center.x - windowWidth / 2, center.y - windowHeight / 2, windowWidth, windowHeight); aWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); aWindow.setVisible(true); // Display the window }
From source file:SettingDefaultButton.java
public static void main(String args[]) { JFrame frame = new JFrame("DefaultButton"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JButton button4 = new JButton("AAA"); frame.add(button4, "Center"); frame.add(new JButton("BBB"), "South"); JRootPane rootPane = frame.getRootPane(); rootPane.setDefaultButton(button4);/*from www. j av a 2 s. com*/ frame.setSize(300, 200); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame("JLabel Test"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JLabel label = new JLabel("First Name"); label.setFont(new Font("Courier New", Font.ITALIC, 18)); label.setForeground(Color.RED); frame.add(label);//w w w.jav a 2 s . c o m frame.pack(); frame.setVisible(true); }
From source file:Main.java
License:asdf
public static void main(final String args[]) { JFrame frame = new JFrame("EditorPane Example"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JEditorPane editorPane = new JEditorPane(); editorPane.setText("asdf"); JScrollPane scrollPane = new JScrollPane(editorPane); frame.add(scrollPane);//from w w w . ja v a2 s . c o m frame.setSize(640, 480); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame f = new JFrame("Fixed size content"); f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); Container c = f.getContentPane(); c.setBackground(Color.YELLOW); Dimension d = new Dimension(400, 40); c.setPreferredSize(d);/*from w ww. ja v a 2 s . com*/ f.pack(); f.setResizable(false); f.setVisible(true); }
From source file:DoubleColor.java
public static void main(String args[]) { JFrame frame = new JFrame("Double Color Choosers"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JColorChooser left = new JColorChooser(); left.setDragEnabled(true);/* w ww . ja v a 2 s .c o m*/ frame.add(left, BorderLayout.WEST); JColorChooser right = new JColorChooser(); right.setDragEnabled(true); frame.add(right, BorderLayout.EAST); frame.pack(); frame.setVisible(true); }