Example usage for javax.swing JFrame setSize

List of usage examples for javax.swing JFrame setSize

Introduction

In this page you can find the example usage for javax.swing JFrame setSize.

Prototype

public void setSize(int width, int height) 

Source Link

Document

The width and height values are automatically enlarged if either is less than the minimum size as specified by previous call to setMinimumSize .

Usage

From source file:CustomScrollPane.java

public static void main(String[] args) {
    JFrame f = new JFrame("JScrollBar Demo");
    f.setSize(300, 250);

    ImageIcon icon = new ImageIcon("earth.jpg");
    CustomScrollPane myScrollPane = new CustomScrollPane(new JLabel(icon));
    f.getContentPane().add(myScrollPane);

    WindowListener wndCloser = new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);/*from  ww w  .jav a2s  . c  o m*/
        }
    };
    f.addWindowListener(wndCloser);
    f.setVisible(true);

}

From source file:TextLayoutLineBreakerMeasurer.java

public static void main(String[] args) {
    JFrame frame = new TextLayoutLineBreakerMeasurer();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    frame.setSize(200, 200);
    frame.setVisible(true);//from  w  w w.  j a  v a  2 s. co  m
}

From source file:Main.java

public static void main(String[] args) {
    JTabbedPane tab = new JTabbedPane();
    tab.addTab("New tab1", new JLabel("1"));
    tab.addTab("New Tab2", new JLabel("2"));
    JPanel p = new JPanel(new BorderLayout());
    p.add(new JLayer<JComponent>(tab, new TopRightCornerLabelLayerUI()));

    JFrame f = new JFrame();
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.getContentPane().add(p);/*from  w w  w  .j  a v  a  2 s .c  o m*/
    f.setSize(320, 240);
    f.setVisible(true);
}

From source file:TreeRowHeight15.java

public static void main(String[] argv) {
    JTree tree = new JTree();

    tree.setRowHeight(15);/*w  ww.  ja v  a2 s .  c om*/

    JFrame frame = new JFrame("Image");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.add(new JScrollPane(tree));
    frame.setSize(380, 320);
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);

}

From source file:SwingSuspendResume.java

public static void main(String[] args) {
    SwingSuspendResume vsr = new SwingSuspendResume();
    Thread t = new Thread(vsr);
    t.start();//from w  ww .  j  av a  2s. c o  m

    JFrame f = new JFrame();
    f.setContentPane(vsr);
    f.setSize(320, 200);
    f.setVisible(true);
    f.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }
    });
}

From source file:RotateTransformed.java

public static void main(String[] args) {
    JFrame frame = new JFrame();
    frame.add(new RotateTransformed());
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setSize(400, 400);
    frame.setVisible(true);//from www  .  java  2s . co  m
}

From source file:Main.java

public static void main(String[] args) {
    JFrame f = new JFrame();
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.setSize(200, 200);
    f.getContentPane().setLayout(new BorderLayout());
    JTextPane jtp = new JTextPane();
    jtp.setEditorKit(new WrapEditorKit());
    JScrollPane jsp = new JScrollPane(jtp);
    jsp.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
    f.getContentPane().add(jsp, BorderLayout.CENTER);
    jtp.setText("thisIsATestThisisAtestthisIsATestThisisAtestthisIsATestThisisAtest");
    f.setVisible(true);//from w ww .j a  v a2s .c  o m
}

From source file:Main.java

public static void main(String[] args) {
    JTabbedPane tabbedPane;/*from  w  ww.ja  v a  2 s.c  o m*/
    JTextField txtFoo = new JTextField(10);
    JPanel pnlFoo = new JPanel();
    pnlFoo.add(new JButton("Button 1"));
    pnlFoo.add(new JLabel("Foo"));
    pnlFoo.add(txtFoo);

    JTextField txtBar = new JTextField(10);
    JPanel pnlBar = new JPanel();
    pnlBar.add(new JButton("Button 3"));
    pnlBar.add(new JLabel("Bar"));
    pnlBar.add(txtBar);

    tabbedPane = new JTabbedPane();
    tabbedPane.addTab("Tab 1", pnlFoo);
    tabbedPane.addTab("Tab 2", pnlBar);

    tabbedPane.addChangeListener(e -> {
        Component comp = tabbedPane.getSelectedComponent();
        if (comp.equals(pnlFoo)) {
            txtFoo.requestFocusInWindow();
        } else if (comp.equals(pnlBar)) {
            txtBar.requestFocusInWindow();
        }
    });

    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setSize(460, 200);
    frame.getContentPane().add(tabbedPane, BorderLayout.CENTER);
    frame.setVisible(true);

    txtFoo.requestFocusInWindow();
}

From source file:Main.java

public static void main(String[] a) {
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    frame.add(new JSeparator(JSeparator.VERTICAL));

    frame.setSize(300, 200);
    frame.setVisible(true);//from   w  w  w . j  a  v a2s  .  c o  m
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    JTabbedPane pane = new JTabbedPane();
    pane.setUI(new SpacedTabbedPaneUI());
    pane.addTab("One", new JPanel());
    pane.addTab("Two", new JPanel());
    pane.addTab("Threeeeeee", new JPanel());
    pane.addTab("Four", new JPanel());

    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.add(pane);/*from   w  w w. ja  v a  2  s. c  o m*/
    frame.setSize(500, 200);
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
}