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 frame = new JFrame(); JButton btn = new JButton("Test"); JPanel panel = new JPanel(); panel.add(btn);//from w w w . jav a 2 s . com JTabbedPane tabbedPane = new JTabbedPane(); tabbedPane.add("Tab1", panel); frame.add(tabbedPane, BorderLayout.CENTER); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); frame.setMinimumSize(new Dimension(300, 300)); frame.setVisible(true); }
From source file:GeneralPathDemo2D.java
public static void main(String s[]) { JFrame f = new JFrame(""); f.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0);//w w w .ja v a 2 s . c om } }); JApplet applet = new GeneralPathDemo2D(); f.getContentPane().add("Center", applet); applet.init(); f.pack(); f.setSize(new Dimension(300, 300)); f.show(); }
From source file:Main.java
public static void main(String[] args) { JFrame.setDefaultLookAndFeelDecorated(true); JFrame frame = new JFrame(); frame.setTitle("JLabel Test"); frame.setLayout(new FlowLayout()); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JLabel label = new JLabel("First Name"); label.setFont(new Font("Courier New", Font.ITALIC, 12)); label.setForeground(Color.GRAY); frame.add(label);//from w w w .ja va2s.co m frame.pack(); frame.setVisible(true); }
From source file:FilledGeneralPath.java
public static void main(String s[]) { JFrame f = new JFrame(""); f.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0);// www . ja v a 2 s . c om } }); JApplet applet = new FilledGeneralPath(); f.getContentPane().add("Center", applet); applet.init(); f.pack(); f.setSize(new Dimension(300, 300)); f.show(); }
From source file:Main.java
public static void main(String args[]) { SwingUtilities.invokeLater(new Runnable() { public void run() { try { JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); BufferedImage image = ImageIO.read(new URL("http://www.java2s.com/style/download.png")); f.getContentPane().add(new JLabel(new ImageIcon(dye(image, new Color(255, 0, 0, 128))))); f.pack(); f.setVisible(true);/*from ww w.ja va 2 s . co m*/ } catch (Exception e) { e.printStackTrace(); } } }); }
From source file:GeneralPathOpenDemo2D.java
public static void main(String s[]) { JFrame f = new JFrame(""); f.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0);/*from w ww. ja va2 s . c o m*/ } }); JApplet applet = new GeneralPathOpenDemo2D(); f.getContentPane().add("Center", applet); applet.init(); f.pack(); f.setSize(new Dimension(300, 300)); f.show(); }
From source file:cimat.tesis.sna.visualization.ShowLayouts.java
public static void main(String[] args) { JPanel jp = getGraphPanel();//from w ww .j a v a 2 s . co m JFrame jf = new JFrame(); jf.getContentPane().add(jp); jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); jf.pack(); jf.setVisible(true); }
From source file:ImageOps.java
public static void main(String[] a) { JFrame f = new JFrame(); f.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0);/* w ww . ja v a 2s . com*/ } }); f.setContentPane(new ImageOps()); f.pack(); f.setVisible(true); }
From source file:fsart.diffTools.gui.DiffToolsGui.java
public static void main(String[] args) { //Create and set up the window. JFrame frame = new JFrame("DiffTools"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); log.debug("Demarrage de l'application"); DiffToolsMainPanel gui = new DiffToolsMainPanel(); frame.add(gui.getPanel());/*from w w w . jav a 2 s. c o m*/ frame.setMinimumSize(gui.getPanel().getMinimumSize()); frame.pack(); //frame.setMinimumSize(gui.getPanel().getMinimumSize()); frame.setLocationRelativeTo(frame.getParent()); frame.setVisible(true); //System.exit(0); }
From source file:Main.java
public static void main(String[] args) { JRadioButton dem = new JRadioButton("Bill", false); dem.setActionCommand("Bill"); JRadioButton rep = new JRadioButton("Bob", false); rep.setActionCommand("Bob"); JRadioButton ind = new JRadioButton("Ross", false); ind.setActionCommand("Ross"); final ButtonGroup group = new ButtonGroup(); group.add(dem);/* www . j a va2 s.com*/ group.add(rep); group.add(ind); class VoteActionListener implements ActionListener { public void actionPerformed(ActionEvent ex) { String choice = group.getSelection().getActionCommand(); System.out.println("ACTION Candidate Selected: " + choice); } } class VoteItemListener implements ItemListener { public void itemStateChanged(ItemEvent ex) { String item = ((AbstractButton) ex.getItemSelectable()).getActionCommand(); boolean selected = (ex.getStateChange() == ItemEvent.SELECTED); System.out.println("ITEM Candidate Selected: " + selected + " Selection: " + item); } } ActionListener al = new VoteActionListener(); dem.addActionListener(al); rep.addActionListener(al); ind.addActionListener(al); ItemListener il = new VoteItemListener(); dem.addItemListener(il); rep.addItemListener(il); ind.addItemListener(il); JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container c = frame.getContentPane(); c.setLayout(new GridLayout(4, 1)); c.add(new JLabel("Please Cast Your Vote")); c.add(dem); c.add(rep); c.add(ind); frame.pack(); frame.setVisible(true); }