List of usage examples for javax.swing JFrame JFrame
public JFrame(String title) throws HeadlessException
Frame
with the specified title. From source file:Main.java
public static void main(String args[]) { JFrame frame = new JFrame("Property Split"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT); splitPane.setContinuousLayout(true); splitPane.setOneTouchExpandable(true); JComponent topComponent = new JButton("A"); splitPane.setTopComponent(topComponent); JComponent bottomComponent = new JButton("B"); splitPane.setBottomComponent(bottomComponent); frame.add(splitPane, BorderLayout.CENTER); frame.setSize(300, 150);/*from w w w .j a v a 2 s . com*/ frame.setVisible(true); }
From source file:Main.java
public static void main(String[] a) { JFrame frame = new JFrame("Alignment Example"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); String labels[] = { "--", "----", "--------", "------------" }; JPanel container = new JPanel(); BoxLayout layout = new BoxLayout(container, BoxLayout.Y_AXIS); layout.layoutContainer(container);// w ww .j a v a2 s .c o m container.setLayout(layout); for (int i = 0; i < labels.length; i++) { JButton button = new JButton(labels[i]); container.add(button); } frame.add(container, BorderLayout.CENTER); frame.setSize(300, 200); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame("GroupLayout"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container contentPane = frame.getContentPane(); GroupLayout groupLayout = new GroupLayout(contentPane); contentPane.setLayout(groupLayout);//from w w w .j ava2s .co m JLabel label = new JLabel("Label"); JButton b2 = new JButton("Second Button"); groupLayout.setHorizontalGroup( groupLayout.createSequentialGroup().addComponent(label).addGap(5, 10, 50).addComponent(b2)); groupLayout.setVerticalGroup(groupLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(label).addComponent(b2)); frame.pack(); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] a) { JFrame frame = new JFrame("Alignment Example"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); String labels[] = { "--", "----", "--------", "------------" }; JPanel container = new JPanel(); BoxLayout layout = new BoxLayout(container, BoxLayout.Y_AXIS); System.out.println(layout.minimumLayoutSize(container)); container.setLayout(layout);/*from w w w. j a v a 2 s . c om*/ for (int i = 0; i < labels.length; i++) { JButton button = new JButton(labels[i]); container.add(button); } frame.add(container, BorderLayout.CENTER); frame.setSize(300, 200); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] a) { JFrame frame = new JFrame("Alignment Example"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); String labels[] = { "--", "----", "--------", "------------" }; JPanel container = new JPanel(); BoxLayout layout = new BoxLayout(container, BoxLayout.Y_AXIS); System.out.println(layout.maximumLayoutSize(container)); container.setLayout(layout);// w ww . j a v a2 s. c o m for (int i = 0; i < labels.length; i++) { JButton button = new JButton(labels[i]); container.add(button); } frame.add(container, BorderLayout.CENTER); frame.setSize(300, 200); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] a) { JFrame frame = new JFrame("Alignment Example"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); String labels[] = { "--", "----", "--------", "------------" }; JPanel container = new JPanel(); BoxLayout layout = new BoxLayout(container, BoxLayout.Y_AXIS); System.out.println(layout.getAxis() == BoxLayout.Y_AXIS); container.setLayout(layout);/*from w w w. j a v a 2 s .c om*/ for (int i = 0; i < labels.length; i++) { JButton button = new JButton(labels[i]); container.add(button); } frame.add(container, BorderLayout.CENTER); frame.setSize(300, 200); frame.setVisible(true); }
From source file:AddingToJScrollPane.java
public static void main(String args[]) { JFrame frame = new JFrame("Tabbed Pane Sample"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JLabel label = new JLabel("Label"); label.setPreferredSize(new Dimension(1000, 1000)); JScrollPane jScrollPane = new JScrollPane(label); frame.add(jScrollPane, BorderLayout.CENTER); frame.setSize(400, 150);//from w w w . ja v a 2 s . c om frame.setVisible(true); }
From source file:SpinnerDemo.java
public static void main(String[] args) { JFrame jf = new JFrame("It Spins"); Container cp = jf.getContentPane(); cp.setLayout(new GridLayout(0, 1)); // Create a JSpinner using one of the pre-defined SpinnerModels JSpinner dates = new JSpinner(new SpinnerDateModel()); cp.add(dates);/*w w w . j a v a 2s . co m*/ // Create a JSPinner using a SpinnerListModel. String[] data = { "One", "Two", "Three" }; JSpinner js = new JSpinner(new SpinnerListModel(data)); cp.add(js); jf.setSize(100, 80); jf.setVisible(true); }
From source file:ActiveSample.java
public static void main(String args[]) { JFrame frame = new JFrame("Active Example"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); UIManager.put(LABEL_FACTORY, new ActiveLabel()); final JPanel panel = new JPanel(); JButton button = new JButton("Get"); ActionListener actionListener = new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { JLabel label = (JLabel) UIManager.get(LABEL_FACTORY); panel.add(label);//from w w w.ja v a 2 s . c o m panel.revalidate(); } }; button.addActionListener(actionListener); frame.add(panel, BorderLayout.CENTER); frame.add(button, BorderLayout.SOUTH); frame.setSize(200, 200); frame.setVisible(true); }
From source file:TreeRowHeight15.java
public static void main(String[] argv) { JTree tree = new JTree(); tree.setRowHeight(15);//www . j a v a2s . c o 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); }