List of usage examples for javax.swing JFrame pack
@SuppressWarnings("deprecation") public void pack()
From source file:Main.java
public static void main(String[] args) { JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); jtp.setPreferredSize(new Dimension(400, 200)); createTab("Reds", Color.RED); f.add(jtp, BorderLayout.CENTER); f.pack(); f.setVisible(true);/*from w w w .ja v a 2 s . com*/ }
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("."); Icon icon = fileChooser.getIcon(new File(".")); frame.add(fileChooser, BorderLayout.CENTER); frame.pack(); frame.setVisible(true);//from w w w . j ava2 s.co m }
From source file:MainClass.java
public static void main(String[] av) { JFrame frame = new JFrame("MainClass"); frame.setForeground(Color.black); frame.setBackground(Color.lightGray); Container cp = frame.getContentPane(); cp.add(new MainClass(new File("."))); frame.pack(); frame.setVisible(true);//from w ww . j a va 2 s .co m frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); }
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(); frame.setVisible(true);//from www . j ava 2s .c om }
From source file:Main.java
public static void main(String[] args) { JCheckBox a = new JCheckBox("A"); a.setSelected(true);/*from w w w . ja v a 2s. co m*/ JCheckBox b = new JCheckBox("B"); JCheckBox c = new JCheckBox("C"); JCheckBox d = new JCheckBox("D"); JFrame frame = new JFrame(); frame.setLayout(new FlowLayout()); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(new JLabel("Car Features")); frame.add(a); frame.add(b); frame.add(c); frame.add(d); frame.pack(); frame.setVisible(true); }
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("."); String name = fileChooser.getName(new File(".")); frame.add(fileChooser, BorderLayout.CENTER); frame.pack(); frame.setVisible(true);//from w w w . j a va2 s.c o m }
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("."); String text = fileChooser.getApproveButtonText(); frame.add(fileChooser, BorderLayout.CENTER); frame.pack(); frame.setVisible(true);// ww w .jav a 2s .c o m }
From source file:Main.java
public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { @Override/*ww w . ja v a 2 s .com*/ public void run() { try { Image img = null; img = ImageIO.read(new URL("http://www.java2s.com/style/download.png")); JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setLayout(new BorderLayout()); frame.add(new ImagePanel(img)); frame.pack(); frame.setVisible(true); } catch (Exception exp) { exp.printStackTrace(); } } }); }
From source file:Main.java
public static void main(String[] args) { JFrame f = new JFrame("Test"); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JTable table = new JTable(new String[][] { { "One" }, { "Two" }, { "Three" } }, new String[] { "Ordinal" }); table.addRowSelectionInterval(1, 1); f.add(new JScrollPane(table)); f.pack(); f.setLocationRelativeTo(null);/*from w w w.jav a 2 s .c o m*/ f.setVisible(true); }
From source file:KeymapExample.java
public static void main(String[] args) { JTextArea area = new JTextArea(6, 32); Keymap parent = area.getKeymap(); Keymap newmap = JTextComponent.addKeymap("KeymapExampleMap", parent); KeyStroke u = KeyStroke.getKeyStroke(KeyEvent.VK_U, InputEvent.CTRL_MASK); Action actionU = new UpWord(); newmap.addActionForKeyStroke(u, actionU); Action actionList[] = area.getActions(); Hashtable lookup = new Hashtable(); for (int j = 0; j < actionList.length; j += 1) lookup.put(actionList[j].getValue(Action.NAME), actionList[j]); KeyStroke L = KeyStroke.getKeyStroke(KeyEvent.VK_L, InputEvent.CTRL_MASK); Action actionL = (Action) lookup.get(DefaultEditorKit.selectLineAction); newmap.addActionForKeyStroke(L, actionL); KeyStroke W = KeyStroke.getKeyStroke(KeyEvent.VK_W, InputEvent.CTRL_MASK); Action actionW = (Action) lookup.get(DefaultEditorKit.selectWordAction); newmap.addActionForKeyStroke(W, actionW); area.setKeymap(newmap);/*from w ww .j av a 2 s . c om*/ JFrame f = new JFrame("KeymapExample"); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.getContentPane().add(new JScrollPane(area), BorderLayout.CENTER); area.setText("www.\n java2s \n .com."); f.pack(); f.setVisible(true); }