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(Component comp) 

Source Link

Document

Appends the specified component to the end of this container.

Usage

From source file:Main.java

public static void main(String[] argv) throws Exception {
    JTree tree = new JTree();

    JFrame f = new JFrame();
    f.add(new JScrollPane(tree));
    f.setSize(300, 300);/*from  w  w  w  . ja v a2 s  .  co m*/
    f.setVisible(true);

    // Get paths of all selected nodes
    TreePath[] paths = tree.getSelectionPaths();

}

From source file:Main.java

public static void main(String[] argv) {
    JTextField component = new JTextField(10);

    component.getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke(new Character(' '), 0), "none");

    JFrame f = new JFrame();
    f.add(component);

    f.setSize(300, 300);// w w  w  . j a  v  a2s. c o m

    f.setVisible(true);

}

From source file:Main.java

public static void main(String[] argv) {
    JTextField component = new JTextField(10);

    component.getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke("typed -"), "actionName");

    JFrame f = new JFrame();
    f.add(component);

    f.setSize(300, 300);//w w w .  ja  v a  2  s  . co  m

    f.setVisible(true);

}

From source file:Main.java

public static void main(String[] argv) {
    JTextField component = new JTextField(10);

    component.getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke("typed a"), "actionName");

    JFrame f = new JFrame();
    f.add(component);

    f.setSize(300, 300);//  ww  w .  j av a2s  .  c o m

    f.setVisible(true);

}

From source file:Main.java

public static void main(String[] argv) {
    JTextField component = new JTextField(10);

    component.getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke("typed X"), "none");

    JFrame f = new JFrame();
    f.add(component);

    f.setSize(300, 300);//from   ww  w.j a  v a2  s.com

    f.setVisible(true);

}

From source file:Main.java

public static void main(String[] argv) {
    JTextField component = new JTextField(10);

    component.getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke("typed $"), "actionName");

    JFrame f = new JFrame();
    f.add(component);

    f.setSize(300, 300);//from w ww .j  a v  a 2 s. c  o m

    f.setVisible(true);

}

From source file:Main.java

public static void main(String[] argv) {
    JTextField component = new JTextField(10);

    component.getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke(new Character(' '), 0),
            "actionName");

    JFrame f = new JFrame();
    f.add(component);

    f.setSize(300, 300);//from   w  w w. jav  a 2s . co m

    f.setVisible(true);

}

From source file:Main.java

public static void main(String[] a) {
    JFrame f = new JFrame();
    f.add(new Main());
    f.setSize(300, 300);//from w  w w .j a va  2  s  .com
    f.setVisible(true);
}

From source file:Main.java

public static void main(String[] argv) {
    JTextField component = new JTextField(10);

    component.getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke("shift pressed SPACE"),
            "actionName");

    JFrame f = new JFrame();
    f.add(component);

    f.setSize(300, 300);// w w w  . ja  va 2s  .  c om

    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.setSize(200, 200);/*from w ww.  ja v a2  s. c  om*/
    frame.setVisible(true);
}