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:Main.java

public static void main(String[] argv) {
    Vector rowData = new Vector();
    for (int i = 0; i < 1; i++) {
        Vector colData = new Vector(Arrays.asList("qq"));
        rowData.add(colData);/* w ww .j a v  a  2s.co  m*/
    }

    String[] columnNames = { "a" };

    Vector columnNamesV = new Vector(Arrays.asList(columnNames));

    JTable table = new JTable(rowData, columnNamesV);
    JFrame f = new JFrame();
    f.setSize(300, 300);
    f.add(new JScrollPane(table));
    f.setVisible(true);
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    DefaultTableModel model = new DefaultTableModel();
    JTable table = new JTable(model);

    model.addColumn("Col1");
    model.addColumn("Col2");

    // Create the first row
    model.insertRow(0, new Object[] { "r1" });

    // Append a row
    model.insertRow(model.getRowCount(), new Object[] { "r5" });

    JFrame f = new JFrame();
    f.setSize(300, 300);
    f.add(new JScrollPane(table));
    f.setVisible(true);/* w w w  . j  av  a2  s  .c o m*/
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    DefaultTableModel model = new DefaultTableModel();
    JTable table = new JTable(model);

    model.addColumn("Col1");
    model.addColumn("Col2");

    // Create the first row
    model.insertRow(0, new Object[] { "r1" });

    // Insert a row at position p
    int p = 1;//from  w  w  w  .j  ava  2 s  .c  o  m
    model.insertRow(p, new Object[] { "r3" });

    JFrame f = new JFrame();
    f.setSize(300, 300);
    f.add(new JScrollPane(table));
    f.setVisible(true);
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    DefaultTableModel model = new DefaultTableModel();
    JTable table = new JTable(model);

    model.addColumn("Col1");
    model.addColumn("Col2");

    model.addRow(new Object[] { "v1", "v2" });

    model.addRow(new Object[] { "v1" });

    model.addRow(new Object[] { "v1", "v2", "v3" });

    JFrame f = new JFrame();
    f.setSize(300, 300);
    f.add(new JScrollPane(table));
    f.setVisible(true);//www  .  j ava2 s  . c o  m

}

From source file:MainClass.java

public static void main(String args[]) {
    JFrame x = new JFrame("Look at me");
    x.setSize(200, 300);
    x.setVisible(true);/*from   w  w w .  j  ava 2 s .c o  m*/
    x.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    FileOutputStream f;
    try {
        f = new FileOutputStream("Test.xml");
        XMLEncoder e = new XMLEncoder(new BufferedOutputStream(f));
        e.writeObject(x);
        e.close();
    } catch (Exception e) {
    }
}

From source file:Main.java

public static void main(String[] args) {
    JFrame frame = new JFrame();
    frame.setSize(400, 400);
    frame.setVisible(true);//from  w  ww  . j  av  a  2s.c  o m
    String[] list = { "1", "2", "3", "4", };
    JComboBox<String> comb = new JComboBox<>(list);
    final JPopupMenu pop = new JPopupMenu();
    pop.add(comb);
    frame.addMouseListener(new MouseAdapter() {

        @Override
        public void mousePressed(MouseEvent e) {
            System.out.println("mousePressed");
            pop.show(e.getComponent(), e.getX(), e.getY());
        }
    });
}

From source file:Main.java

public static void main(String[] args) {
    JFrame frame = new JFrame("JLabel Test");

    frame.setSize(300, 200);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    ImageIcon imageIcon = new ImageIcon("icon.gif");
    JLabel label = new JLabel(imageIcon);

    frame.add(label);/*from w  w  w .  j a v  a  2  s.  com*/
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    DefaultTableModel model = new DefaultTableModel();
    JTable table = new JTable(model);
    model.addColumn("Col1");
    model.addRow(new Object[] { "r1" });
    model.addRow(new Object[] { "r2" });
    model.addRow(new Object[] { "r3" });

    // Get all the table data
    Vector data = model.getDataVector();
    // Copy the second row
    Vector row = (Vector) data.elementAt(1);
    row = (Vector) row.clone();/*w w w .  j a  va2 s.c o  m*/

    JFrame f = new JFrame();
    f.setSize(300, 300);
    f.add(new JScrollPane(table));
    f.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    JFrame f = new JFrame();
    f.setSize(800, 600);
    f.setLocationRelativeTo(null);/*  www  .  j  a  va2s.c o m*/

    JTabbedPane p = new JTabbedPane();
    p.addTab("T1", new JPanel());
    p.addTab("T2", new JPanel());
    p.addTab("T3", new JPanel());

    p.addChangeListener(e -> {
        System.out.println("" + p.getSelectedIndex());
        // Index starts at 0, so Index 2 = Tab3
        if (p.getSelectedIndex() == 2) {
            // do your stuff on Tab 3
        }
    });
    f.add(p);
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    JFrame aWindow = new JFrame();
    aWindow.setSize(400, 400);
    aWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    aWindow.add(new CardLayoutPanel());
    aWindow.setVisible(true);//www  .j av a2 s .  c  om
}