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) { Main mainPanel = new Main(); JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(mainPanel);//from www . ja v a 2 s . c o m frame.pack(); frame.setVisible(true); }
From source file:PaintMethods.java
/** "main program" method - construct and show */ public static void main(String[] av) { final JFrame f = new JFrame("PaintMethods demo"); f.getContentPane().add("Center", new PaintMethods("Testing 1 2 3")); f.pack(); f.setVisible(true);/*from w w w . ja v a 2 s . com*/ f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); }
From source file:Main.java
public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { public void run() { JFrame frame = new JFrame(); frame.add(new TestImage()); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); frame.setVisible(true);//from ww w . j a v a2s. c o m } }); }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); new Main().initContainer(frame); frame.pack(); frame.setVisible(true);/*ww w .j a va 2 s . c om*/ }
From source file:Main.java
public static void main(String[] args) { JTabbedPane tp = new JTabbedPane(); tp.addTab("Dates", new JPanel()); tp.addTab("Deliveries", new JPanel()); tp.addTab("Exports", new JPanel()); tp.setTabComponentAt(0, new JLabel("Dates")); tp.setTabComponentAt(1, new JLabel("Deliveries")); tp.setTabComponentAt(2, new JLabel("Exports")); JFrame frame = new JFrame("Testing"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setLayout(new BorderLayout()); frame.add(tp);//from w w w.j a v a 2 s .c o m frame.pack(); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { DefaultMutableTreeNode root = new DefaultMutableTreeNode("Days"); for (DaysOfTheWeek dotw : DaysOfTheWeek.values()) { root.add(new DefaultMutableTreeNode(dotw)); }/*from w ww . j a v a 2 s . c o m*/ final DefaultTreeModel model = new DefaultTreeModel(root); JTree tree = new JTree(model); tree.setRootVisible(true); tree.setShowsRootHandles(true); ToolTipManager.sharedInstance().registerComponent(tree); tree.setCellRenderer(new MyTreeCellRenderer()); JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.add(new JScrollPane(tree)); f.pack(); f.setVisible(true); }
From source file:Main.java
public static void main(final String[] av) { JFrame frame = new JFrame(); Container cp = frame.getContentPane(); cp.add(new FileTree(new File("."))); frame.pack(); frame.setVisible(true);//from ww w. ja v a 2s . c o m frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); }
From source file:Main.java
public static void main(String[] args) { JPanel panel = new JPanel(); JTextField tf1 = new JTextField(10); panel.add(tf1);// w ww . ja va 2 s . c o m JTextField tf2 = new JTextField(10); panel.add(tf2); new TextPrompt("First Name", tf1); new TextPrompt("Last Name", tf2); JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(panel); frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true); }
From source file:Main.java
public static void main(String args[]) { JPanel container = new ScrollablePanel(); container.setLayout(new FlowLayout(FlowLayout.CENTER, 0, 0)); for (int i = 0; i < 20; ++i) { JPanel p = new JPanel(); p.setPreferredSize(new Dimension(50, 50)); p.add(new JLabel("" + i)); container.add(p);// w w w . j av a 2 s. c o m } JScrollPane scroll = new JScrollPane(container); scroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); scroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.getContentPane().add(scroll); f.pack(); f.setSize(250, 300); f.setVisible(true); }
From source file:Main.java
public static void main(String s[]) { JFrame frame1 = new JFrame("2D Text"); frame1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame1.getContentPane().add("Center", new Main()); frame1.pack(); frame1.setSize(new Dimension(500, 300)); frame1.setVisible(true);/*from w w w . j a va 2 s .c o m*/ }