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) { String[] ITEMS1 = { "one", "two", "three", "four", "five" }; String[] ITEMS2 = { "Monday", "Tuesday", "Wednesday", "Thursday", "Friday" }; JPanel northPanel = new JPanel(); northPanel.add(new JCheckBox("Reminder")); northPanel.add(new JComboBox(ITEMS1)); northPanel.add(new JComboBox(ITEMS2)); JPanel p = new JPanel(new BorderLayout()); p.add(northPanel, BorderLayout.NORTH); p.add(new JScrollPane(new JTextArea(8, 30)), BorderLayout.CENTER); JFrame frame = new JFrame(); frame.getContentPane().add(p);//from w w w. j av a 2 s . co m frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JTextPane textPane = new JTextPane(); textPane.setText("12345678\n\t1\t2\t3a"); JScrollPane scrollPane = new JScrollPane(textPane); scrollPane.setPreferredSize(new Dimension(700, 100)); setTabs(textPane, 8);/*from ww w .j a va2 s. co m*/ JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(scrollPane); frame.pack(); frame.setVisible(true); }
From source file:NestedJSplitPane.java
public static void main(String[] a) { int HORIZSPLIT = JSplitPane.HORIZONTAL_SPLIT; int VERTSPLIT = JSplitPane.VERTICAL_SPLIT; boolean continuousLayout = true; JLabel label1 = new JLabel("a"); JLabel label2 = new JLabel("b"); JLabel label3 = new JLabel("c"); JSplitPane splitPane1 = new JSplitPane(VERTSPLIT, continuousLayout, label1, label2); splitPane1.setOneTouchExpandable(true); splitPane1.setDividerSize(2);// w w w . j a v a 2 s. co m splitPane1.setDividerLocation(0.5); JSplitPane splitPane2 = new JSplitPane(HORIZSPLIT, splitPane1, label3); splitPane2.setOneTouchExpandable(true); splitPane2.setDividerLocation(0.4); splitPane2.setDividerSize(2); JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(splitPane2); frame.pack(); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { NumberFormat numberFormatGuFalse = NumberFormat.getNumberInstance(); numberFormatGuFalse.setGroupingUsed(false); JFormattedTextField jftFieldGuFalse = new JFormattedTextField(numberFormatGuFalse); NumberFormat numberFormatGuTrue = NumberFormat.getNumberInstance(); // numberFormatGuFalse.setGroupingUsed(true); // not necessary as is default JFormattedTextField jftFieldGuTrue = new JFormattedTextField(numberFormatGuTrue); JPanel panel = new JPanel(new BorderLayout()); panel.add(jftFieldGuFalse, BorderLayout.NORTH); panel.add(jftFieldGuTrue, BorderLayout.SOUTH); JFrame frame = new JFrame(); frame.getContentPane().add(panel);//from ww w . ja va 2s. com frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] argv) throws Exception { // Read from a URL URL url = new URL("http://java.org/source.gif"); Image image = ImageIO.read(url); JFrame frame = new JFrame(); JLabel label = new JLabel(new ImageIcon(image)); frame.getContentPane().add(label, BorderLayout.CENTER); frame.pack(); frame.setVisible(true);//w ww . j a v a 2s. c o m }
From source file:Main.java
public static void main(String[] argv) throws Exception { InputStream is = new BufferedInputStream(new FileInputStream("s.gif")); Image image = ImageIO.read(is); JFrame frame = new JFrame(); JLabel label = new JLabel(new ImageIcon(image)); frame.getContentPane().add(label, BorderLayout.CENTER); frame.pack(); frame.setVisible(true);/*from www . ja v a 2 s . c om*/ }
From source file:Main.java
public static void main(String[] argv) throws Exception { File sourceimage = new File("source.gif"); Image image = ImageIO.read(sourceimage); JFrame frame = new JFrame(); JLabel label = new JLabel(new ImageIcon(image)); frame.getContentPane().add(label, BorderLayout.CENTER); frame.pack(); frame.setVisible(true);/* w ww .j a v a 2 s .com*/ }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(new TestPane()); frame.pack(); frame.setVisible(true);//from w w w. j a va 2 s . c o m }
From source file:Main.java
public static void main(String[] args) { GraphicsDevice[] sds = GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices(); for (GraphicsDevice sd : sds) { System.out.println(sd.getIDstring()); GraphicsConfiguration gc = sd.getDefaultConfiguration(); JFrame f = new JFrame(gc); f.add(new JLabel(sd.getIDstring())); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.pack(); centerOn(f, gc);/* ww w . jav a 2 s .co m*/ f.setVisible(true); } }
From source file:Main.java
public static void main(String[] argv) throws Exception { JTextField component = new JTextField(10); JTextField component1 = new JTextField(10); component.addFocusListener(new MyFocusListener()); component1.addFocusListener(new MyFocusListener()); JFrame f = new JFrame(); f.setLayout(new FlowLayout()); f.add(component1);//from w ww . ja va 2 s . c om f.add(component); f.pack(); f.setVisible(true); }