List of usage examples for javax.swing JFrame setBounds
public void setBounds(int x, int y, int width, int height)
The width or height values are automatically enlarged if either is less than the minimum size as specified by previous call to setMinimumSize .
From source file:FlowLayoutChangingGap.java
public static void main(String[] args) { JFrame aWindow = new JFrame("This is a Flow Layout"); aWindow.setBounds(50, 50, 500, 500); aWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); FlowLayout flow = new FlowLayout(FlowLayout.LEFT, 20, 30); Container content = aWindow.getContentPane(); // Get the content pane content.setLayout(flow); // Set the container layout mgr for (int i = 1; i <= 6; i++) { content.add(new JButton("Press " + i)); // Add a Button to content pane }// www . ja va 2 s.com aWindow.setVisible(true); // Display the window }
From source file:TryGridLayout.java
public static void main(String[] args) { JFrame aWindow = new JFrame("This is a Grid Layout"); aWindow.setBounds(30, 30, 300, 300); aWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); GridLayout grid = new GridLayout(3, 4, 30, 20); Container content = aWindow.getContentPane(); content.setLayout(grid);/*w w w . ja va2s . com*/ JButton button = null; for (int i = 1; i <= 10; i++) { content.add(button = new JButton(" Press " + i)); } aWindow.pack(); aWindow.setVisible(true); }
From source file:UIDefaultsButton.java
License:asdf
public static void main(String[] args) { UIManager.put("Button.background", Color.BLACK); UIManager.put("Button.foreground", Color.RED); JFrame aWindow = new JFrame("This is a Border Layout"); aWindow.setBounds(30, 30, 300, 300); // Size aWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JButton bn = new JButton("asdf"); aWindow.add(bn);/*w ww . j av a 2 s . c om*/ aWindow.setVisible(true); // Display the window }
From source file:FlowLayoutSettingGaps.java
public static void main(String[] args) { JFrame aWindow = new JFrame("This is a Flow Layout"); aWindow.setBounds(30, 30, 300, 300); // Size aWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); FlowLayout flow = new FlowLayout(); // Create a layout manager flow.setHgap(35); // Set the horizontal gap Container content = aWindow.getContentPane(); // Get the content pane content.setLayout(flow); // Set the container layout mgr // Now add six button components for (int i = 1; i <= 6; i++) { content.add(new JButton("Press " + i)); // Add a Button to content pane }//from www. j ava2 s. c o m aWindow.setVisible(true); // Display the window }
From source file:Main.java
public static void main(String[] args) { JFrame aWindow = new JFrame(); aWindow.setBounds(200, 200, 200, 200); aWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container content = aWindow.getContentPane(); content.add(new MouseMotionAdapterDemo()); aWindow.setVisible(true);// www.j av a 2 s .co m }
From source file:GradientPane.java
public static void main(String[] a) { JFrame window = new JFrame("Acyclic Gradient Paint"); window.setBounds(30, 30, 300, 300); window.getContentPane().add(new GradientPane()); window.setVisible(true);//from www . j a v a2s.co m }
From source file:MainClass.java
public static void main(String[] args) { JFrame aWindow = new JFrame(); aWindow.setBounds(200, 200, 200, 200); aWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container content = aWindow.getContentPane(); content.add(new SpringLayoutPanel()); aWindow.setVisible(true);/* w w w .ja va2 s. c o m*/ }
From source file:Main.java
public static void main(String[] args) { JFrame aWindow = new JFrame(); aWindow.setBounds(200, 200, 200, 200); aWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container content = aWindow.getContentPane(); content.add(new GridBagLayoutPanel()); aWindow.setVisible(true);/*from w w w . j a v a2 s. co m*/ }
From source file:MainClass.java
public static void main(String[] args) { JFrame aWindow = new JFrame(); aWindow.setBounds(200, 200, 200, 200); aWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container content = aWindow.getContentPane(); content.add(new MouseMotionEvents()); aWindow.setVisible(true);//from w ww. java 2 s.c o m }
From source file:TryBorderLayout.java
public static void main(String[] args) { JFrame aWindow = new JFrame("This is a Border Layout"); aWindow.setBounds(30, 30, 300, 300); // Size aWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); BorderLayout border = new BorderLayout(); // Create a layout manager Container content = aWindow.getContentPane(); // Get the content pane content.setLayout(border); // Set the container layout mgr EtchedBorder edge = new EtchedBorder(EtchedBorder.RAISED); // Button border // Now add five JButton components and set their borders JButton button;/* w w w .j a v a2s .com*/ content.add(button = new JButton("EAST"), BorderLayout.EAST); button.setBorder(edge); content.add(button = new JButton("WEST"), BorderLayout.WEST); button.setBorder(edge); content.add(button = new JButton("NORTH"), BorderLayout.NORTH); button.setBorder(edge); content.add(button = new JButton("SOUTH"), BorderLayout.SOUTH); button.setBorder(edge); content.add(button = new JButton("CENTER"), BorderLayout.CENTER); button.setBorder(edge); aWindow.setVisible(true); // Display the window }