Example usage for javax.swing JFrame add

List of usage examples for javax.swing JFrame add

Introduction

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

Prototype

public Component add(String name, Component comp) 

Source Link

Document

Adds the specified component to this container.

Usage

From source file:Main.java

public static void main(String[] a) {
    JFrame frame = new JFrame("JFileChooser Popup");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JFileChooser fileChooser = new JFileChooser(".");

    int mu = fileChooser.getApproveButtonMnemonic();

    frame.add(fileChooser, BorderLayout.CENTER);

    frame.pack();/*from  w w  w  .j av  a 2 s  .c  o m*/
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String[] a) {
    JFrame frame = new JFrame("JFileChooser Popup");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JFileChooser fileChooser = new JFileChooser(".");

    String name = fileChooser.getName(new File("."));
    frame.add(fileChooser, BorderLayout.CENTER);

    frame.pack();//from www  . jav  a2 s  . com
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String args[]) {
    JFrame frame = new JFrame("Caret Example");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JTextArea textArea = new JTextArea();
    JScrollPane scrollPane = new JScrollPane(textArea);
    frame.add(scrollPane, BorderLayout.CENTER);

    CaretListener listener = new CaretListener() {
        public void caretUpdate(CaretEvent caretEvent) {
            System.out.println("Dot: " + caretEvent.getDot());
            System.out.println("Mark: " + caretEvent.getMark());
        }/*from w ww  . j av a  2  s  . c  om*/
    };

    textArea.addCaretListener(listener);

    frame.setSize(250, 150);
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String[] a) {
    JFrame frame = new JFrame("JFileChooser Popup");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JFileChooser fileChooser = new JFileChooser(".");

    String text = fileChooser.getApproveButtonText();

    frame.add(fileChooser, BorderLayout.CENTER);

    frame.pack();/*from   w w  w  . ja va 2  s . com*/
    frame.setVisible(true);
}

From source file:JScrollPaneHeadersandCorners.java

public static void main(String args[]) {
    final Object rows[][] = { { "one", "1" }, { "two", "2" }, { "three", "3" }, { "four", "4" },

    };/*from  ww  w  .  j av  a2s.  co  m*/
    final Object headers[] = { "English", "#" };

    JFrame frame = new JFrame("Table Printing");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    final JTable table = new JTable(rows, headers);
    JScrollPane scrollPane = new JScrollPane(table);
    frame.add(scrollPane, BorderLayout.CENTER);
    scrollPane.setCorner(JScrollPane.UPPER_RIGHT_CORNER, new JButton("..."));

    frame.setSize(300, 150);
    frame.setVisible(true);
}

From source file:ButtonListener.java

public static void main(String[] a) {
    JFrame frame = new JFrame("Popup JComboBox");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JButton source = new JButton("Ring the bell!");
    source.addActionListener(new ButtonListener());
    frame.add(source, BorderLayout.SOUTH);

    source.addActionListener(new ButtonListener());

    frame.setSize(300, 200);//from w  ww  .j  a v  a2 s.c o  m
    frame.setVisible(true);
}

From source file:BoundedChangeListener.java

public static void main(String args[]) {
    JFrame frame = new JFrame("Tick Slider");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JSlider jSliderOne = new JSlider();
    jSliderOne.addChangeListener(new BoundedChangeListener());
    frame.add(jSliderOne, BorderLayout.NORTH);
    frame.setSize(300, 200);/*from  w  w  w .  ja  v a  2  s  . c o m*/
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String[] a) {
    JFrame frame = new JFrame("JFileChooser Popup");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JFileChooser fileChooser = new JFileChooser(".");
    String f = fileChooser.getDescription(new File("."));

    frame.add(fileChooser, BorderLayout.CENTER);

    frame.pack();/*from  w w  w  .  j  a  v  a  2 s  . c o m*/
    frame.setVisible(true);
}