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:Main.java
public static void main(String[] argv) throws Exception { JTextField component = new JTextField(); component.addKeyListener(new MyKeyListener()); JFrame f = new JFrame(); f.add(component);/*from w w w. j a v a 2s . com*/ f.setSize(300, 300); f.setVisible(true); }
From source file:Main.java
public static void main(String[] argv) throws Exception { JTextField component = new JTextField(); component.addMouseListener(new MyMouseListener()); JFrame f = new JFrame(); f.add(component);// ww w . j av a 2 s . com f.setSize(300, 300); f.setVisible(true); component.addMouseListener(new MyMouseListener()); }
From source file:Main.java
public static void main(String[] argv) throws Exception { DefaultMutableTreeNode root = new DefaultMutableTreeNode("Root Label"); root.add(new DefaultMutableTreeNode("Node Label")); JTree tree = new JTree(root); JFrame f = new JFrame(); f.add(new JScrollPane(tree)); f.setSize(300, 300); f.setVisible(true);//ww w . j a v a 2 s . com }
From source file:Main.java
public static void main(String[] argv) throws Exception { JTree tree = new JTree(); JFrame f = new JFrame(); f.add(new JScrollPane(tree)); f.setSize(300, 300); f.setVisible(true);//from w w w . j av a 2 s.co m // Get paths of all selected nodes TreePath[] paths = tree.getSelectionPaths(); }
From source file:Main.java
public static void main(String[] args) { JFrame jframe = new JFrame(); jframe.setSize(500, 200); jframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JTextPane jTextPane = new JTextPane(); jTextPane.setEditorKit(new HTMLEditorKit()); JButton btn = new JButton("Print"); btn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { try { jTextPane.setContentType("text/html"); boolean done = jTextPane.print(); if (done) { System.out.println("Printing is done"); } else { System.out.println("Error while printing"); }/*from w w w . j a va2 s . c o m*/ } catch (Exception pex) { pex.printStackTrace(); } } }); jframe.add(btn, BorderLayout.SOUTH); jframe.add(jTextPane); jframe.setVisible(true); }
From source file:MouseWheelTest.java
public static void main(String args[]) { JFrame frame = new MouseWheelTest(); frame.setSize(300, 300); frame.show();/* ww w . j av a 2 s . c o m*/ }
From source file:Main.java
public static void main(String[] argv) throws Exception { JTextField component = new JTextField(); component.addMouseListener(new MyMouseListener()); JFrame f = new JFrame(); f.add(component);// w w w. j a va 2 s . c o m f.setSize(300, 300); f.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { FlowLayout layout = new FlowLayout(FlowLayout.LEADING, horizontalGap, verticalGap); JButton button = new JButton("Discard"); JLabel[] panels = new JLabel[5]; JFrame frame = new JFrame("Poker"); frame.setSize(width, height); frame.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT); JPanel deckPanel = new JPanel(layout); for (int i = 0; i < 5; i++) { panels[i] = new JLabel("" + i); deckPanel.add(panels[i]);/* w w w. j av a 2 s . com*/ } frame.getContentPane().add(deckPanel); JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.CENTER)); buttonPanel.add(button); frame.getContentPane().add(buttonPanel, BorderLayout.SOUTH); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); frame.setVisible(true); }
From source file:FontShow.java
public static void main(String args[]) { JFrame frame = new JFrame(); frame.setSize(420, 300); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(new FontShow()); frame.setVisible(true);//from w w w . j ava 2 s.c om }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new TextStyleTestFrame(); frame.setSize(300, 300); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setLocationRelativeTo(null);//from www. j av a 2s. c o m frame.setVisible(true); }