List of usage examples for javax.swing JFrame JFrame
public JFrame() throws HeadlessException
From source file:Main.java
public static void main(String[] argv) throws Exception { JFrame frame = new JFrame(); GridBagLayout gbl = new GridBagLayout(); frame.setLayout(gbl);//from w w w .j a va 2s. c o m frame.add(new JButton("1")); frame.add(new JButton("2")); gbl.layoutContainer(frame); double[][] weights = gbl.getLayoutWeights(); for (int i = 0; i < 2; i++) { for (int j = 0; j < weights[i].length; j++) { weights[i][j] = 1; } } gbl.columnWeights = weights[0]; gbl.rowWeights = weights[1]; frame.pack(); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame f = new JFrame(); DefaultListModel<String> dlm = new DefaultListModel(); String[] modelElems = { "Apple", "Orange", "Banana" }; for (int i = 0; i < modelElems.length; i++) dlm.add(i, modelElems[i]);/*from ww w .ja va 2 s .co m*/ JList<String> lstFruitList = new JList(dlm); lstFruitList.setVisible(true); JPanel p = new JPanel(); p.add(lstFruitList); f.add(p); f.setLocation(0, 0); f.setSize(400, 400); f.setVisible(true); }
From source file:StringArrayOptionPopups.java
public static void main(String[] a) { JFrame frame = new JFrame(); Icon blueIcon = new ImageIcon("yourFile.gif"); Object stringArray[] = { "Do It", "No Way" }; JOptionPane.showOptionDialog(frame, "Continue printing?", "Select an Option", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, blueIcon, stringArray, stringArray[0]); }
From source file:Main.java
public static void main(final String args[]) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JMenuBar menuBar = new JMenuBar(); // File Menu, F - Mnemonic JMenu fileMenu = new JMenu("File"); fileMenu.setDelay(100);//from www. j a va 2 s . c o m // File->New, N - Mnemonic JMenuItem newMenuItem = new JMenuItem("New"); fileMenu.add(newMenuItem); frame.setJMenuBar(menuBar); frame.setSize(350, 250); frame.setVisible(true); }
From source file:Main.java
public static void main(final String args[]) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JMenuBar menuBar = new JMenuBar(); // File Menu, F - Mnemonic JMenu fileMenu = new JMenu("File"); fileMenu.setMenuLocation(10, 10);/*from w ww . j a v a2 s .com*/ // File->New, N - Mnemonic JMenuItem newMenuItem = new JMenuItem("New"); fileMenu.add(newMenuItem); frame.setJMenuBar(menuBar); frame.setSize(350, 250); frame.setVisible(true); }
From source file:Main.java
public static void main(String args[]) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Object rowData[][] = { { "Row1-Column1", "Row1-Column2", "Row1-Column3" }, { "Row2-Column1", "Row2-Column2", "Row2-Column3" } }; Object columnNames[] = { "1", "2", "3" }; JTable table = new JTable(rowData, columnNames); JScrollPane scrollPane = new JScrollPane(table); table.setTableHeader(null);//from w ww . ja v a2s.c o m frame.add(scrollPane, BorderLayout.CENTER); frame.setSize(300, 150); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JProgressBar bar = new JProgressBar(JProgressBar.VERTICAL); bar.setEnabled(true);/*from w w w . j av a2 s . c o m*/ bar.setBackground(Color.YELLOW); bar.setForeground(Color.GREEN); bar.setStringPainted(true); bar.setString("2000 g"); bar.setValue(65); frame.setLayout(new BorderLayout()); frame.add(bar, BorderLayout.CENTER); frame.setSize(500, 400); frame.setVisible(true); }
From source file:Main.java
public static void main(final String args[]) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JMenuBar menuBar = new JMenuBar(); // File Menu, F - Mnemonic JMenu fileMenu = new JMenu("File"); // File->New, N - Mnemonic JMenuItem newMenuItem = new JMenuItem("New"); fileMenu.add(newMenuItem);// ww w . j a v a 2 s. c om frame.setJMenuBar(menuBar); frame.setSize(350, 250); frame.setVisible(true); fileMenu.setSelected(true); }
From source file:Main.java
public static void main(String[] args) throws InterruptedException { JFrame frame = new JFrame(); frame.add(new JLabel("Minimize demo")); frame.pack();//from w ww . j a va 2 s.c om // Show the frame frame.setVisible(true); // Sleep for 5 seconds, then minimize Thread.sleep(5000); frame.setState(Frame.ICONIFIED); // Sleep for 5 seconds, then restore Thread.sleep(5000); frame.setState(Frame.NORMAL); // Sleep for 5 seconds, then kill window Thread.sleep(5000); frame.setVisible(false); frame.dispose(); // Terminate test System.exit(0); }
From source file:Main.java
public static void main(final String args[]) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JMenuBar menuBar = new JMenuBar(); // File Menu, F - Mnemonic JMenu fileMenu = new JMenu("File"); // File->New, N - Mnemonic JMenuItem newMenuItem = new JMenuItem("New"); fileMenu.add(newMenuItem);// w w w .j a v a 2 s .c o m frame.setJMenuBar(menuBar); frame.setSize(350, 250); frame.setVisible(true); fileMenu.setPopupMenuVisible(true); }