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(String[] args) { JFrame frame = new JFrame("MainClass"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(200, 200); frame.setLocation(200, 200);/*w w w . ja v a2s . c o m*/ frame.setContentPane(new MainClass()); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame(); JPanel panel = new JPanel(); frame.setSize(300, 200); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JButton redButton = new JButton("Red"); JButton greenButton = new JButton("Green"); JButton blueButton = new JButton("Blue"); class Listener extends JPanel implements ActionListener { public void actionPerformed(ActionEvent event) { Color color;/* www .j a v a2 s . co m*/ if (event.getSource() == redButton) { color = Color.red; redButton.setBackground(color); panel.setBackground(color); } else if (event.getSource() == greenButton) { color = Color.green; greenButton.setBackground(color); panel.setBackground(color); } else { color = Color.blue; blueButton.setBackground(color); panel.setBackground(color); } setBackground(color); repaint(); } } redButton.addActionListener(new Listener()); greenButton.addActionListener(new Listener()); blueButton.addActionListener(new Listener()); panel.add(redButton); panel.add(greenButton); panel.add(blueButton); frame.add(panel); frame.setVisible(true); }
From source file:RoundedLineBorder.java
public static void main(String s[]) { JFrame frame = new JFrame("Rounded Line Border"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(500, 200); frame.setContentPane(new RoundedLineBorder()); frame.setVisible(true);//from w ww. ja va2 s. com }
From source file:ColorBlocks.java
public static void main(String[] args) { JFrame f = new JFrame(); f.getContentPane().add(new ColorBlocks()); f.setSize(350, 250); f.show();//w w w. j av a 2 s . c o m }
From source file:SketchPanel.java
public static void main(String[] args) { JFrame frame = new JFrame(); frame.setTitle("Sketch"); frame.setSize(300, 200); frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0);// w w w.j a va2 s . co m } }); Container contentPane = frame.getContentPane(); contentPane.add(new SketchPanel()); frame.show(); }
From source file:Main.java
public static void main(String[] args) { String imageFile = "A.jpg"; RepaintManager.currentManager(null).setDoubleBufferingEnabled(false); Image image = Toolkit.getDefaultToolkit().getImage(Main.class.getResource(imageFile)); image = image.getScaledInstance(imageWidth, imageHeight, Image.SCALE_AREA_AVERAGING); JFrame frame = new JFrame("DragImage"); frame.getContentPane().add(new Main(image)); frame.setSize(300, 300); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true);//w w w . ja v a 2 s . com }
From source file:LineMetricsIllustration.java
public static void main(String[] args) { JFrame f = new JFrame(); f.getContentPane().add(new LineMetricsIllustration()); f.setSize(850, 250); f.show();/* w w w. j ava2s.com*/ }
From source file:MainClass.java
public static void main(String[] args) { JFrame frame = new JFrame("MainClass"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(250, 250); frame.setLocation(200, 200);/*from w w w.ja va2 s .co m*/ frame.setContentPane(new MainClass()); frame.setVisible(true); }
From source file:MatteExample.java
public static void main(String s[]) { JFrame frame = new JFrame("Matte Borders"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(500, 200); frame.setContentPane(new MatteExample()); frame.setVisible(true);/*from w w w . j a va 2 s . c om*/ }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(400, 400); JDialog dialog = new JDialog(frame, "Dialog", true); JPanel mainGui = new JPanel(new BorderLayout()); mainGui.setBorder(new EmptyBorder(20, 20, 20, 20)); mainGui.add(new JLabel("Contents go here"), BorderLayout.CENTER); JPanel buttonPanel = new JPanel(new FlowLayout()); mainGui.add(buttonPanel, BorderLayout.SOUTH); JButton close = new JButton("Close"); close.addActionListener(e -> dialog.setVisible(false)); buttonPanel.add(close);/*from w w w. j a v a2s .co m*/ frame.setVisible(true); dialog.setContentPane(mainGui); dialog.pack(); dialog.setVisible(true); }