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) { final JTextPane pane = new JTextPane(); pane.setText("Some text"); JButton buttonButton = new JButton("Insert label"); buttonButton.addActionListener(e -> { JLabel label = new JLabel("label"); label.setAlignmentY(0.85f);// w ww . j ava2 s . c om pane.insertComponent(label); }); JPanel panel = new JPanel(new BorderLayout()); panel.add(buttonButton, BorderLayout.SOUTH); panel.add(pane, BorderLayout.CENTER); JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(panel); frame.setSize(400, 200); frame.setVisible(true); }
From source file:Text.java
public static void main(String[] args) { Text text = new Text(); JFrame frame = new JFrame("Sonnet 55"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(text); frame.setSize(500, 470);/*from w ww . ja v a 2 s.c om*/ frame.setLocationRelativeTo(null); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JProgressBar progressBar = new JProgressBar(); JButton button = new JButton("Start"); JFrame f = new JFrame(); f.setLayout(new FlowLayout()); f.add(progressBar); f.add(button);/*ww w . j a v a 2s . co m*/ ActionListener updateProBar = new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { int val = progressBar.getValue(); if (val >= 100) { // timer.stop(); button.setText("End"); return; } progressBar.setValue(++val); } }; Timer timer = new Timer(50, updateProBar); button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (timer.isRunning()) { timer.stop(); button.setText("Start"); } else if (button.getText() != "End") { timer.start(); button.setText("Stop"); } } }); f.pack(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame("Basic Shapes"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(new Main()); frame.setSize(350, 250);/*from w ww .j av a 2s . c om*/ frame.setLocationRelativeTo(null); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { final JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(new Main()); frame.pack();/*from w w w . j ava2s . c o m*/ frame.setVisible(true); }
From source file:Main.java
public static void main(String[] a) { JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.add(new JScrollPaneDemo()); f.setSize(500, 500);//from w w w. j av a2 s .c om f.setVisible(true); }
From source file:GradientsLine.java
public static void main(String[] args) { JFrame frame = new JFrame("GradientsLine"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(new GradientsLine()); frame.setSize(350, 350);//from ww w. jav a 2 s .c o m frame.setLocationRelativeTo(null); frame.setVisible(true); }
From source file:TreeSingleSelection.java
public static void main(String[] argv) { JTree tree = new JTree(); tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); JFrame frame = new JFrame("Tree single selection"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(new JScrollPane(tree)); frame.setSize(380, 320);/* w ww. ja v a 2s .c om*/ frame.setLocationRelativeTo(null); frame.setVisible(true); }
From source file:TreeNodeRemove.java
public static void main(String[] argv) { Vector<String> v = new Vector<String>(); v.add("a");/*from www.jav a 2s .c o m*/ v.add("b"); v.add("c"); JTree tree = new JTree(v); DefaultTreeModel model = (DefaultTreeModel) tree.getModel(); int startRow = 0; String prefix = "b"; TreePath path = tree.getNextMatch(prefix, startRow, Position.Bias.Forward); MutableTreeNode node = (MutableTreeNode) path.getLastPathComponent(); model.removeNodeFromParent(node); JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(new JScrollPane(tree)); frame.setSize(380, 320); frame.setLocationRelativeTo(null); frame.setVisible(true); }
From source file:BasicShapes.java
public static void main(String[] args) { JFrame frame = new JFrame("Basic Shapes"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(new BasicShapes()); frame.setSize(350, 250);/* w w w. jav a 2 s. c o m*/ frame.setLocationRelativeTo(null); frame.setVisible(true); }