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(Dimension d) 

Source Link

Document

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

Usage

From source file:Main.java

public static void main(String[] args) {
    JFrame frame = new JFrame();
    frame.setSize(new Dimension(500, 500));

    JDialog dialog = new JDialog(frame, "Export", ModalityType.MODELESS);
    dialog.setSize(300, 300);// www .j  av  a  2 s. c  om

    JDialog dialog1 = new JDialog(dialog, "Export", ModalityType.APPLICATION_MODAL);
    dialog1.setSize(200, 200);

    frame.add(new JButton(new AbstractAction("Dialog") {
        @Override
        public void actionPerformed(ActionEvent e) {
            frame.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
            dialog.setVisible(true);
            dialog1.setVisible(true);
        }
    }));
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String args[]) {
    JFrame f = new JFrame();
    f.setSize(new Dimension(300, 300));
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.setLayout(new FlowLayout());
    JLabel label = new JLabel("Update");
    String[] data = { "one", "two", "three", "four" };
    JList<String> dataList = new JList<>(data);

    dataList.addListSelectionListener(new ListSelectionListener() {

        @Override/*from w w  w.  j ava2s .  c  o m*/
        public void valueChanged(ListSelectionEvent arg0) {
            if (!arg0.getValueIsAdjusting()) {
                label.setText(dataList.getSelectedValue().toString());
            }
        }
    });
    f.add(new JScrollPane(dataList));
    f.add(label);

    f.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    final JTextPane textPane = new JTextPane();
    final JScrollPane scrollPane = new JScrollPane(textPane);

    String text = "Lorem ipsum dolor sit amet, " + "consectetur adipiscing elit."
            + "Fusce nec sapien id diam consequat adipiscing.";
    textPane.setText(text);//  ww  w . j ava 2 s  .c o m

    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.getContentPane().add(scrollPane);

    frame.setSize(new Dimension(200, 200));
    frame.setVisible(true);

    FontMetrics metrics = textPane.getFontMetrics(textPane.getFont());
    textPane.setMargin(new Insets(scrollPane.getViewport().getHeight() - metrics.getHeight(), 0, 0, 0));
}

From source file:Main.java

public static void main(String[] a) {
    JFrame f = new JFrame();
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.add(new Main());
    f.pack();//from  w  w  w.  j a  v  a2  s.co m
    f.setSize(new Dimension(300, 200));
    f.setVisible(true);

}

From source file:com.archivas.clienttools.arcmover.gui.panels.CopyOptionsPanel.java

public static void main(String[] args) {
    // just test this panel.
    CopyOptionsPanel p = new CopyOptionsPanel(null, new CopyJob());
    JFrame f = new JFrame();
    f.add(p);// ww w  . j a v a  2  s.c  om
    f.pack();
    f.setLocation(100, 800);
    f.setSize(new Dimension(700, 500));
    f.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }
    });
    f.setVisible(true);
}

From source file:Main.java

public static void main(String arg[]) {
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.add("Center", new Main());
    frame.pack();/*from w w w  . j a va2 s.  c o  m*/
    frame.setSize(new Dimension(350, 400));
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String s[]) {
    JFrame frame1 = new JFrame("2D Text");
    frame1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    frame1.getContentPane().add("Center", new Main());
    frame1.pack();/*from w  w  w . j  a  v  a  2  s . co  m*/
    frame1.setSize(new Dimension(500, 300));
    frame1.setVisible(true);
}

From source file:Main.java

public static void main(String s[]) {
    JFrame frame1 = new JFrame("2D Images ");
    frame1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    frame1.getContentPane().add("Center", new Main());
    frame1.pack();//from  ww w .j a va  2 s. c  o m
    frame1.setSize(new Dimension(300, 300));
    frame1.setVisible(true);
}

From source file:LineBreakMeasurerDemo.java

public static void main(String arg[]) {
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.getContentPane().add("Center", new DisplayPanel());
    frame.pack();//from  w  w w. j  a v a  2  s  .c o  m
    frame.setSize(new Dimension(350, 400));
    frame.setVisible(true);
}

From source file:AreaAdding.java

public static void main(String arg[]) {
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.getContentPane().add("Center", new AreaAdding());
    frame.pack();//from w  ww  . j  av  a  2  s  .  c o  m
    frame.setSize(new Dimension(400, 300));
    frame.setVisible(true);
}