List of usage examples for javax.swing JFrame setSize
public void setSize(int width, int height)
The width and height values are automatically enlarged if either is less than the minimum size as specified by previous call to setMinimumSize .
From source file:MainClass.java
public static void main(final String args[]) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(500, 300); frame.setVisible(true);/* ww w . j av a 2 s .c o m*/ EscapeDialog esc = new EscapeDialog(frame); esc.setSize(200, 200); esc.setVisible(true); }
From source file:Toolbars.java
public static void main(String[] args) { JToolBar toolbar1 = new JToolBar(); JToolBar toolbar2 = new JToolBar(); JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); JButton newb = new JButton(new ImageIcon("new.png")); JButton openb = new JButton(new ImageIcon("open.png")); JButton saveb = new JButton(new ImageIcon("save.png")); toolbar1.add(newb);/*from ww w.ja va 2s . c o m*/ toolbar1.add(openb); toolbar1.add(saveb); toolbar1.setAlignmentX(0); JButton exitb = new JButton(new ImageIcon("exit.png")); toolbar2.add(exitb); toolbar2.setAlignmentX(0); exitb.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { System.exit(0); } }); panel.add(toolbar1); panel.add(toolbar2); JFrame f = new JFrame(); f.add(panel, BorderLayout.NORTH); f.setSize(300, 200); f.setLocationRelativeTo(null); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame(); frame.add(new Main()); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(200, 200); frame.setVisible(true);// ww w .ja v a 2s. c o m }
From source file:ChartPanel.java
public static void main(String[] argv) { JFrame f = new JFrame(); f.setSize(400, 300); double[] values = new double[3]; String[] names = new String[3]; values[0] = 1;/* www . j a v a2 s.c o m*/ names[0] = "Item 1"; values[1] = 2; names[1] = "Item 2"; values[2] = 4; names[2] = "Item 3"; f.getContentPane().add(new ChartPanel(values, names, "title")); WindowListener wndCloser = new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }; f.addWindowListener(wndCloser); f.setVisible(true); }
From source file:Main.java
public static void main(String[] args) throws Exception { URL url16 = new URL("http://www.java2s.com/style/download.png"); URL url32 = new URL("http://www.java2s.com/style/download.png"); final List<Image> icons = new ArrayList<Image>(); icons.add(ImageIO.read(url16)); icons.add(ImageIO.read(url32)); JFrame f = new JFrame(); f.setIconImages(icons);//w ww. j a v a2 s . co m f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setSize(200, 100); f.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { int TIME_VISIBLE = 3000; JFrame frame1 = new JFrame(); frame1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame1.setSize(100, 100); frame1.setLocation(100, 100);//w ww . ja va 2 s. c om JButton button = new JButton("My Button"); frame1.getContentPane().add(button); button.addActionListener(e -> { JOptionPane pane = new JOptionPane("Message", JOptionPane.INFORMATION_MESSAGE); JDialog dialog = pane.createDialog(null, "Title"); dialog.setModal(false); dialog.setVisible(true); new Timer(TIME_VISIBLE, new ActionListener() { @Override public void actionPerformed(ActionEvent e) { dialog.setVisible(false); } }).start(); }); frame1.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame parent = new JFrame(); parent.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); parent.setSize(300, 300); parent.setVisible(true);/*ww w .j av a2 s . c om*/ Main dlg = new Main(parent); dlg.setVisible(true); }
From source file:Main.java
public static void main(String[] args) throws Exception { JEditorPane editor = new JEditorPane("text/html", "<H1>A!</H1><P><FONT COLOR=blue>blue</FONT></P>"); editor.setEditable(false);/*from w w w . j av a 2 s. c o m*/ JScrollPane pane = new JScrollPane(editor); JFrame f = new JFrame("HTML Demo"); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.getContentPane().add(pane); f.setSize(800, 600); f.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment(); Rectangle bounds = env.getMaximumWindowBounds(); System.out.println("Screen Bounds: " + bounds); GraphicsDevice screen = env.getDefaultScreenDevice(); GraphicsConfiguration config = screen.getDefaultConfiguration(); System.out.println("Screen Size : " + config.getBounds()); JFrame frame = new JFrame("Frame Info"); System.out.println("Frame Insets : " + frame.getInsets()); frame.setSize(200, 200); System.out.println("Frame Insets : " + frame.getInsets()); frame.setVisible(true);/* www . java 2 s. c o m*/ System.out.println("Frame Size : " + frame.getSize()); System.out.println("Frame Insets : " + frame.getInsets()); System.out.println("Content Size : " + frame.getContentPane().getSize()); }
From source file:Main.java
public static void main(String args[]) { Object rowData[][] = { { "Row1-Column1", "Row1-Column2", "Row1-Column3" }, { "Row2-Column1", "Row2-Column2", "Row2-Column3" } }; Object columnNames[] = { "Column 1", "Column 2", "Column 3" }; JTable table = new JTable(rowData, columnNames); table.setTableHeader(null);//from ww w.ja va 2 s .c o m JScrollPane scrollPane = new JScrollPane(table); scrollPane.setColumnHeaderView(null); JFrame frame = new JFrame(); frame.getContentPane().add(scrollPane, BorderLayout.CENTER); frame.setSize(300, 150); frame.setVisible(true); }