List of usage examples for javax.swing JFrame add
public Component add(Component comp)
From source file:Main.java
static public void main(String args[]) throws Exception { JFrame frame = new JFrame(); Panel panel = new Main(); frame.add(panel); frame.setSize(400, 400);//from w w w. ja v a 2s.co m frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame(); MyTextPane textPane = new MyTextPane(); frame.add(textPane); frame.pack();/* www . j a v a2s.c o m*/ frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.add(new Main()); f.pack();/*w ww .j a v a2 s . c o m*/ f.setSize(400, 300); f.setVisible(true); }
From source file:ColorFadingAnimation.java
public static void main(String[] args) { JFrame frame = new JFrame("Color fading aniamtion"); frame.add(new ColorFadingAnimation()); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(250, 150);/*w ww. j a v a2 s. c om*/ frame.setLocationRelativeTo(null); frame.setVisible(true); }
From source file:TreeSelectionOption.java
public static void main(String[] argv) { JTree tree = new JTree(); tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); tree.getSelectionModel().setSelectionMode(TreeSelectionModel.CONTIGUOUS_TREE_SELECTION); tree.getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION); JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(new JScrollPane(tree)); frame.setSize(380, 320);/*w w w . j a v a2 s . c om*/ frame.setLocationRelativeTo(null); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] argv) throws Exception { JTextComponent textcomp = new JTextArea(); final UndoManager undo = new UndoManager(); Document doc = textcomp.getDocument(); JFrame f = new JFrame(); f.add(new JScrollPane(textcomp)); f.setSize(330, 300);//from w w w . j a v a 2 s . c o m f.setVisible(true); doc.addUndoableEditListener(new UndoableEditListener() { public void undoableEditHappened(UndoableEditEvent evt) { undo.addEdit(evt.getEdit()); } }); textcomp.getActionMap().put("Undo", new AbstractAction("Undo") { public void actionPerformed(ActionEvent evt) { try { if (undo.canUndo()) { undo.undo(); } } catch (CannotUndoException e) { } } }); textcomp.getInputMap().put(KeyStroke.getKeyStroke("control Z"), "Undo"); textcomp.getActionMap().put("Redo", new AbstractAction("Redo") { public void actionPerformed(ActionEvent evt) { try { if (undo.canRedo()) { undo.redo(); } } catch (CannotRedoException e) { } } }); textcomp.getInputMap().put(KeyStroke.getKeyStroke("control Y"), "Redo"); }
From source file:Main.java
public static void main(String[] argv) { DefaultTableModel model = new DefaultTableModel() { public Class getColumnClass(int columnIndex) { Object o = getValueAt(0, columnIndex); if (o == null) { return Object.class; } else { return o.getClass(); }/* w ww.ja va 2s.c o m*/ } }; JTable table = new JTable(model); model.addColumn("Boolean", new Object[] { Boolean.TRUE }); model.addColumn("Date", new Object[] { new Date() }); model.addColumn("Double", new Object[] { new Double(Math.PI) }); model.addColumn("Float", new Object[] { new Float(1.2) }); model.addColumn("Icon", new Object[] { new ImageIcon("icon.gif") }); model.addColumn("Number", new Object[] { new Integer(1) }); model.addColumn("Object", new Object[] { "object" }); Enumeration e = table.getColumnModel().getColumns(); TableColumn col = (TableColumn) e.nextElement(); col.setCellRenderer(table.getDefaultRenderer(Boolean.class)); col.setCellEditor(table.getDefaultEditor(Boolean.class)); JFrame f = new JFrame(); f.setSize(300, 300); f.add(new JScrollPane(table)); f.setVisible(true); }
From source file:TreeRowHeight15.java
public static void main(String[] argv) { JTree tree = new JTree(); tree.setRowHeight(15);//from ww w . j a v a2s .co m JFrame frame = new JFrame("Image"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(new JScrollPane(tree)); frame.setSize(380, 320); frame.setLocationRelativeTo(null); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.add(new Main()); f.pack();/* w ww.ja v a 2 s . c o m*/ f.setLocationRelativeTo(null); f.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JLabel l;/* ww w . java 2 s.c o m*/ JTextField t; JButton b; JFrame f = new JFrame("Text Accelerator"); f.add(l = new JLabel("Name:", SwingConstants.RIGHT)); l.setDisplayedMnemonic('n'); f.add(l = new JLabel("House/Street:", SwingConstants.RIGHT)); l.setDisplayedMnemonic('h'); f.add(l = new JLabel("City:", SwingConstants.RIGHT)); l.setDisplayedMnemonic('c'); f.add(l = new JLabel("State/County:", SwingConstants.RIGHT)); l.setDisplayedMnemonic('s'); f.add(l = new JLabel("Zip/Post code:", SwingConstants.RIGHT)); l.setDisplayedMnemonic('z'); f.add(l = new JLabel("Telephone:", SwingConstants.RIGHT)); l.setDisplayedMnemonic('t'); f.add(b = new JButton("Clear")); b.setMnemonic('l'); f.add(t = new JTextField(35)); t.setFocusAccelerator('n'); f.add(t = new JTextField(35)); t.setFocusAccelerator('h'); f.add(t = new JTextField(35)); t.setFocusAccelerator('c'); f.add(t = new JTextField(35)); t.setFocusAccelerator('s'); f.add(t = new JTextField(35)); t.setFocusAccelerator('z'); f.add(t = new JTextField(35)); t.setFocusAccelerator('t'); f.add(b = new JButton("OK")); b.setMnemonic('o'); f.pack(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setVisible(true); }