List of usage examples for javax.swing JFrame add
public Component add(Component comp)
From source file:Main.java
public static void main(String[] args) { Main cicd = new Main(); JFrame f = new JFrame("Chooser In Current Dir"); f.add(cicd.getGui()); f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); f.pack();/*w w w. j a va2s. c o m*/ f.setVisible(true); }
From source file:Main.java
public static final void main(String[] args) { JFrame frame = new JFrame(); JTabbedPane tabbedPane = new JTabbedPane(); frame.add(tabbedPane); JButton addButton = new JButton("Add tab"); addButton.addActionListener(e -> { JPanel newTabComponent = new JPanel(); int tabCount = tabbedPane.getTabCount(); newTabComponent.add(new JLabel("I'm tab " + tabCount)); tabbedPane.addTab("Tab " + tabCount, newTabComponent); });//from ww w. j av a 2s . c o m frame.add(addButton, BorderLayout.SOUTH); addButton.doClick(); frame.setSize(800, 300); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] argv) throws Exception { JTextField component = new JTextField(10); JTextField component1 = new JTextField(10); component.addFocusListener(new MyFocusListener()); component1.addFocusListener(new MyFocusListener()); JFrame f = new JFrame(); f.setLayout(new FlowLayout()); f.add(component1); f.add(component);/*from w w w .j a v a 2 s . com*/ f.pack(); f.setVisible(true); }
From source file:PanelWithComponents.java
public static void main(String[] a) { JPanel panel = new JPanel(); JButton okButton = new JButton("OK"); panel.add(okButton);/*from w w w . java 2 s. c o m*/ JButton cancelButton = new JButton("Cancel"); panel.add(cancelButton); JFrame frame = new JFrame("Oval Sample"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(panel); frame.setSize(300, 200); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] argv) { DefaultTableModel model = new DefaultTableModel() { public Class getColumnClass(int mColIndex) { int rowIndex = 0; Object o = getValueAt(rowIndex, mColIndex); if (o == null) { return Object.class; } else { return o.getClass(); }/*from w ww. j a v a 2 s . c om*/ } }; JTable table = new JTable(model); model.addColumn("Col1", new Object[] { Color.red }); model.addRow(new Object[] { Color.green }); model.addRow(new Object[] { Color.blue }); table.setDefaultRenderer(Color.class, new ColorTableCellRenderer()); JFrame f = new JFrame(); f.setSize(300, 300); f.add(new JScrollPane(table)); f.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(pb); f.pack();//from ww w. j av a 2s . c o m f.setVisible(true); Timer timer = new Timer(50, new ActionListener() { @Override public void actionPerformed(ActionEvent e) { progress += 1; if (progress >= 100) { progress = 100; ((Timer) e.getSource()).stop(); } pb.setValue(progress); } }); timer.start(); }
From source file:Main.java
public static void main(String args[]) { JFrame frame = new JFrame("Oval Sample"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(new Main()); frame.setSize(300, 200);/*from www . j a v a 2 s . c o m*/ frame.setVisible(true); }
From source file:OvalPanelCanvas.java
public static void main(String args[]) { JFrame frame = new JFrame("Oval Sample"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(new OvalPanelCanvas()); frame.setSize(300, 200);/*ww w .j a va 2 s .co m*/ frame.setVisible(true); }
From source file:Rotate.java
public static void main(String[] args) { JFrame frame = new JFrame("Rotation"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(new Rotate()); frame.setSize(300, 200);//from w ww. jav a 2s.c om frame.setVisible(true); }
From source file:TreeRowHeightCache.java
public static void main(String[] argv) { JTree tree = new JTree(); if (tree.getRowHeight() <= 0) { tree.setRowHeight(1);/*w w w.ja v a2s .c o m*/ } tree.setRowHeight(0); 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); }