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 Main().getFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); frame.setVisible(true);//from w w w . j ava 2s . c o m }
From source file:ImageTest.java
public static void main(String[] args) { JPanel panel = new JPanel(); final ImageButton button = new ImageButton("button.png"); button.setPressedIcon(new ImageIcon("down.png")); button.setRolloverIcon(new ImageIcon("over.png")); button.setSelectedIcon(new ImageIcon("sel.png")); button.setRolloverSelectedIcon(new ImageIcon("sel-over.png")); button.setDisabledIcon(new ImageIcon("disabled.png")); button.setDisabledSelectedIcon(new ImageIcon("disabled-selected.png")); button.setLocation(60, 74);//from w ww . j a v a 2s . com button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { button.setSelected(!button.isSelected()); System.out.println("selecting"); } }); // button.setSelected(true); // button.setDisabled(false); panel.add(button); JFrame frame = new JFrame(); frame.getContentPane().add(panel); frame.pack(); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame(); MyTextPane textPane = new MyTextPane(); frame.add(textPane);//w w w . java2 s . c om frame.pack(); frame.setVisible(true); }
From source file:JComboBoxDemo.java
public static void main(String[] args) { JFrame frame = new JComboBoxDemo(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); frame.setVisible(true);// w ww .j a va 2 s. c om }
From source file:MainClass.java
public static void main(String[] args) { JFrame frame = new MainClass("javax.swing.JButton"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); frame.setVisible(true);//ww w .java 2 s. c o m }
From source file:Main.java
public static void main(String[] args) { JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.add(pb);//from w w w. j a v a 2s . com f.pack(); f.setVisible(true); Timer timer = new Timer(50, new ActionListener() { @Override public void actionPerformed(ActionEvent e) { progress += 1; if (progress >= 100) { progress = 100; ((Timer) e.getSource()).stop(); } pb.setValue(progress); } }); timer.start(); }
From source file:com.archivas.clienttools.arcmover.gui.panels.CopyOptionsPanel.java
public static void main(String[] args) { // just test this panel. CopyOptionsPanel p = new CopyOptionsPanel(null, new CopyJob()); JFrame f = new JFrame(); f.add(p);//from w w w. ja v a2 s . c o m f.pack(); f.setLocation(100, 800); f.setSize(new Dimension(700, 500)); f.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); f.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { try {/* www. jav a2 s. c o m*/ bg = ImageIO.read(new URL("http://www.java2s.com/style/download.png")); } catch (Exception ex) { System.out.println(ex); } JPanel tabPanel = new JPanel(new GridBagLayout()) { @Override protected void paintComponent(Graphics g) { super.paintComponent(g); g.drawImage(bg, 0, 0, getWidth(), getHeight(), this); } @Override public Dimension getPreferredSize() { return new Dimension(400, 300); } }; JPanel buttons = new JPanel(new GridLayout(4, 1, 15, 15)); buttons.setOpaque(false); for (int i = 0; i < 4; i++) { buttons.add(new JButton("Button")); } tabPanel.add(buttons); JTabbedPane tabPane = new JTabbedPane(); tabPane.add("Panel with Bachground", tabPanel); JFrame frame = new JFrame(); frame.setContentPane(tabPane); frame.pack(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { AbstractButton jb = new JButton("Press Me"); jb.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { System.out.println(((JComponent) arg0.getSource()).getFont()); }//ww w . j a v a 2 s . c om }); jb.doClick(1000); JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.getContentPane().add(jb); f.pack(); f.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { AbstractButton jb = new JButton("Press Me"); jb.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent ev) { System.out.println("ChangeEvent!"); }//from ww w. j ava 2s . co m }); ChangeListener[] lis = jb.getChangeListeners(); JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.getContentPane().add(jb); f.pack(); f.setVisible(true); }