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) {
    String[] items = { "A", "B", "C" };
    JComboBox<String> comboBox1 = new MyComboBox1<>(items);
    JPanel p = new JPanel();
    p.add(comboBox1);// www.j  av a  2  s  .c  om

    JFrame f = new JFrame();
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.getContentPane().add(p);
    f.setSize(320, 240);
    f.setVisible(true);
}

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);//  www.java2  s .co m
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    InputStream is = new BufferedInputStream(new FileInputStream("s.gif"));
    Image image = ImageIO.read(is);

    JFrame frame = new JFrame();
    JLabel label = new JLabel(new ImageIcon(image));
    frame.getContentPane().add(label, BorderLayout.CENTER);
    frame.pack();//from  w  w  w .j  a  va 2s.  com
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    File sourceimage = new File("source.gif");
    Image image = ImageIO.read(sourceimage);

    JFrame frame = new JFrame();
    JLabel label = new JLabel(new ImageIcon(image));
    frame.getContentPane().add(label, BorderLayout.CENTER);
    frame.pack();//w  ww. j  a va 2  s. c  o  m
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    JPanel panel = new JPanel();
    panel.setLayout(new OverlayLayout(panel));

    JTabbedPane tabbedPane = new JTabbedPane();
    tabbedPane.add("1", new JTextField("one"));
    tabbedPane.add("2", new JTextField("two"));
    tabbedPane.setAlignmentX(1.0f);//from w  w  w  . j av a  2  s . c  om
    tabbedPane.setAlignmentY(0.0f);

    JCheckBox checkBox = new JCheckBox("Add tab");
    checkBox.setOpaque(false);
    checkBox.setAlignmentX(1.0f);
    checkBox.setAlignmentY(0.0f);

    panel.add(checkBox);
    panel.add(tabbedPane);

    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.add(panel);
    frame.setSize(400, 100);
    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.add(new TestPane());
    frame.pack();/*  www . j av a  2 s  .c  o m*/
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) throws IOException {
    BufferedImage original = ImageIO.read(new URL("http://www.java2s.com/style/download.png"));

    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice gd = ge.getDefaultScreenDevice();
    GraphicsConfiguration gc = gd.getDefaultConfiguration();

    BufferedImage rotated1 = create(original, -Math.PI / 2, gc);
    BufferedImage rotated2 = create(original, +Math.PI / 4, gc);
    BufferedImage rotated3 = create(original, Math.PI, gc);

    JPanel cp = new JPanel();
    cp.add(new JLabel(new ImageIcon(original)));
    cp.add(new JLabel(new ImageIcon(rotated1)));
    cp.add(new JLabel(new ImageIcon(rotated2)));
    cp.add(new JLabel(new ImageIcon(rotated3)));

    JFrame f = new JFrame();
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.setContentPane(cp);/*ww  w  . j  a  v  a2s . co  m*/
    f.pack();
    f.setVisible(true);

}

From source file:Main.java

public static void main(String[] args) {
    JProgressBar pb = new JProgressBar(0, 100);
    ReadFileWorker worker = new ReadFileWorker();
    worker.addPropertyChangeListener(new PropertyChangeListener() {
        @Override/*  w  ww.j  av a2s  .c om*/
        public void propertyChange(PropertyChangeEvent evt) {
            if ("progress".equalsIgnoreCase(evt.getPropertyName())) {
                pb.setValue(worker.getProgress());
            }
        }
    });
    JFrame f = new JFrame();
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.add(pb);
    f.pack();
    f.setVisible(true);
    worker.execute();
}

From source file:Main.java

public static void main(String[] args) {
    JTabbedPane tabbedPane = new JTabbedPane();
    for (int i = 0; i < 5; i++) {
        tabbedPane.add("Tab " + i, new JLabel("Label " + i, SwingConstants.CENTER));
    }/*from   w  w w . ja va  2s . c  o  m*/

    tabbedPane.getModel().addChangeListener(e -> {
        JLabel label = (JLabel) tabbedPane.getSelectedComponent();
        System.out.println(label.getText());
    });

    tabbedPane.setPreferredSize(new Dimension(500, 300));

    JFrame frame = new JFrame();
    frame.getContentPane().add(tabbedPane);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.pack();
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    //Read from an input stream
    InputStream is = new BufferedInputStream(new FileInputStream("source.gif"));
    Image image = ImageIO.read(is);

    JFrame frame = new JFrame();
    JLabel label = new JLabel(new ImageIcon(image));
    frame.getContentPane().add(label, BorderLayout.CENTER);
    frame.pack();//ww  w .  ja v a2 s. c om
    frame.setVisible(true);
}