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 s[]) {
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setContentPane(new Main());
    frame.pack();/*  w  w w . j a  v a  2  s . c  o  m*/
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    JPanel panel = new JPanel(new BorderLayout());
    String[] values = new String[] { "One", "Two", "Three" };
    JComboBox<String> comboBox = new JComboBox<>(values);
    panel.add(comboBox, BorderLayout.NORTH);
    JTextArea textArea = new JTextArea(2, 2);
    panel.add(textArea, BorderLayout.CENTER);
    JButton button = new JButton("Action");
    button.addActionListener(new ActionListener() {
        @Override//from   ww w. j a v  a2 s.  c  o  m
        public void actionPerformed(ActionEvent e) {
            textArea.setText((String) comboBox.getSelectedItem());
            comboBox.setSelectedIndex(0);
        }
    });
    panel.add(button, BorderLayout.SOUTH);
    JFrame frame = new JFrame();
    frame.add(panel);
    frame.pack();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String... s) {

    DefaultTableModel model = new DefaultTableModel(4, 4) {
        @Override//from w  w w  .  java 2 s .c  o  m
        public boolean isCellEditable(int row, int column) {
            return column == 3;
        }

        @Override
        public Class<?> getColumnClass(int columnIndex) {
            if (columnIndex == 3) {
                return Boolean.class;
            }
            return super.getColumnClass(columnIndex);
        }
    };

    JTable t = new JTable(model);
    JFrame f = new JFrame();
    f.add(new JScrollPane(t));

    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.pack();
    f.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    JFrame frame = new JFrame();
    frame.add(new Main());
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.pack();/*from  ww  w. j av  a  2s  .  co m*/
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    Image image = new BufferedImage(32, 32, BufferedImage.TYPE_INT_RGB);

    JFrame f = new JFrame();
    f.setIconImage(image);/* www . j  av  a  2 s. com*/
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.pack();
    f.setSize(600, 400);
    f.setVisible(true);

    JFileChooser chooser = new JFileChooser();
    chooser.showOpenDialog(f);
}

From source file:Main.java

public static void main(String[] args) {
    Main mainPanel = new Main();
    JFrame f = new JFrame();
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.getContentPane().add(mainPanel);//from   ww w  .java2  s  .c o m
    f.pack();
    f.setVisible(true);
}

From source file:Main.java

public static void main(String[] argv) {
    JEditorPane jep = new JEditorPane();
    jep.setContentType("text/html");
    StringBuilder sb = new StringBuilder();
    sb.append("<b>Welcome</b>:<br><hr>");
    for (int i = 1; i <= 3; i++) {
        sb.append(create(i));// w w  w  . j ava  2s .  com
    }
    sb.append("<hr>");
    jep.setText(sb.toString());
    jep.setEditable(false);
    jep.addHyperlinkListener(e -> {
        if (HyperlinkEvent.EventType.ACTIVATED.equals(e.getEventType())) {
            System.out.println(e.getURL());
            Desktop desktop = Desktop.getDesktop();
            try {
                desktop.browse(e.getURL().toURI());
            } catch (Exception ex) {
                ex.printStackTrace();
            }
        }
    });

    JFrame f = new JFrame();
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.add(jep);
    f.pack();
    f.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    JFrame frame = new JFrame("Window cannot be moved to hide part of it");
    frame.setSize(300, 300);/*  w  w  w.  j ava  2 s  .  c  o m*/

    frame.addComponentListener(new Main());
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    JComboBox<String> combo = new JComboBox<>(new String[] { "One", "Two", "Three" });
    JButton arrowBtn = getButtonSubComponent(combo);
    if (arrowBtn != null) {
        arrowBtn.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                System.out.println("arrow button pressed");
            }//from  w w w  .j a  va2 s .c o m
        });
    }
    JFrame f = new JFrame();
    f.getContentPane().add(combo);
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.pack();
    f.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    Color myBlack = new Color(0, 0, 0, 0.5F); // Color black
    //  Color myWhite = new Color(255,255,255);     // Color white
    //  Color myGreen = new Color(0,200,0);         // A shade of green

    JLabel label = new JLabel("First Name");
    label.setForeground(myBlack);//from  w w w. ja  va  2s  . c  o  m

    JFrame frame = new JFrame();
    frame.add(label);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setBounds(20, 20, 500, 500);
    frame.setVisible(true);

}