Example usage for javax.swing JFrame setVisible

List of usage examples for javax.swing JFrame setVisible

Introduction

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

Prototype

public void setVisible(boolean b) 

Source Link

Document

Shows or hides this Window depending on the value of parameter b .

Usage

From source file:Main.java

public static void main(String[] args) {
    EventQueue.invokeLater(new Runnable() {
        @Override/*  ww  w.  jav  a2 s  .c o  m*/
        public void run() {
            JFrame f = new JFrame();
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.add(new LoadImage());
            f.pack();
            f.setVisible(true);
        }
    });
}

From source file:ImageFlip.java

public static void main(String[] args) {
    JFrame frame = new JFrame("Flip image");
    frame.add(new ImageFlip());
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setSize(570, 230);//from ww  w.  j  av a 2  s .  com
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {

    JTextPane textPane = new JTextPane();
    textPane.setText("This is a test string");

    StyleConstants.setBold(BOLD, true);

    StyleConstants.setItalic(ITALIC, true);

    int start = 5;
    int end = 10;

    textPane.getStyledDocument().setCharacterAttributes(start, end - start, BOLD, false);
    textPane.getStyledDocument().setCharacterAttributes(start, end - start, ITALIC, false);
    for (int i = start; i < end; i++)
        System.out.println(//ww  w .  ja v  a2s. c o  m
                textPane.getStyledDocument().getCharacterElement(i).getAttributes().containsAttributes(BOLD)); // all now print true

    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.add(new JScrollPane(textPane));
    frame.pack();
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    JFrame frame = new JFrame("FormatDemo");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.add(new Main());
    frame.pack();//ww w. ja v  a2 s .  c o  m
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setContentPane(new Main(frame));
    frame.pack();/*from www .ja v a 2  s  .  c o  m*/
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    JFrame aWindow = new JFrame();
    aWindow.setSize(400, 400);//from   w w  w  .j  a va 2  s.  co m
    aWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    aWindow.add(new CardLayoutPanel());
    aWindow.setVisible(true);
}

From source file:JTableSortDemo.java

public static void main(String[] args) {
    Object[][] data = { { "A", 5 }, { "B", 2 }, { "C", 4 }, { "D", 8 } };
    String columnNames[] = { "Item", "Value" };
    TableModel model = new DefaultTableModel(data, columnNames) {
        public Class<?> getColumnClass(int column) {
            return getValueAt(0, column).getClass();
        }//w ww.  ja v  a 2s  .  c  o  m
    };
    JTable table = new JTable(model);

    TableRowSorter<TableModel> sorter = new TableRowSorter<TableModel>(model);
    table.setRowSorter(sorter);

    JScrollPane scrollPane = new JScrollPane(table);
    JFrame frame = new JFrame("Sorting Table");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.add(scrollPane);
    frame.setSize(300, 200);
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    JDesktopPane dp = new JDesktopPane();
    JInternalFrame inf = new JInternalFrame("Help", true, true, true, true);
    inf.setSize(200, 200);/* ww  w.ja va  2s .com*/
    inf.setVisible(true);
    dp.add(inf);

    JButton btn = new JButton("Click");
    btn.addActionListener(e -> JOptionPane.showInternalInputDialog(inf, "Hit me"));
    inf.add(btn);

    JFrame f = new JFrame();
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.setLayout(new BorderLayout());
    f.add(dp);
    f.setSize(400, 400);
    f.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    Object[] items = new Object[] { "Dog", "Cat", "Other" };
    DefaultComboBoxModel dcbm = new DefaultComboBoxModel(items);
    JComboBox comboBox = new JComboBox(dcbm);
    comboBox.setPreferredSize(new Dimension(200, 20));
    comboBox.addItemListener(e -> {// w  ww .  j  a v  a2  s.co  m
        Object selectedItem = comboBox.getSelectedItem();
        boolean editable = selectedItem instanceof String && ((String) selectedItem).equals("Other");
        comboBox.setEditable(editable);
    });
    comboBox.getEditor().addActionListener(e -> {
        Object newItem = comboBox.getEditor().getItem();
        DefaultComboBoxModel d = (DefaultComboBoxModel) comboBox.getModel();
        d.addElement(newItem);
        d.setSelectedItem(newItem);

    });

    JPanel content = new JPanel(new FlowLayout());
    content.add(new JLabel("Test:"));
    content.add(comboBox);

    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setContentPane(content);
    frame.pack();
    frame.setVisible(true);
}

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);
    aWindow.setCursor(Cursor.getDefaultCursor());
    aWindow.setVisible(true);

    System.out.println(Cursor.getDefaultCursor().getName());
}