List of usage examples for java.awt BorderLayout PAGE_START
String PAGE_START
To view the source code for java.awt BorderLayout PAGE_START.
Click Source Link
From source file:Main.java
public static void main(String[] args) { JPanel ui = new JPanel(new BorderLayout(2, 2)); ui.setBorder(new EmptyBorder(4, 4, 4, 4)); JPanel controls = new JPanel(new BorderLayout(2, 2)); ui.add(controls, BorderLayout.PAGE_START); String s = new String(Character.toChars(8594)); String[] items = { "Choice: right " + s + " arrow" }; JComboBox cb = new JComboBox(items); controls.add(cb, BorderLayout.CENTER); controls.add(new JButton("Button"), BorderLayout.LINE_END); JSplitPane sp = new JSplitPane(JSplitPane.VERTICAL_SPLIT, new JTextArea(4, 40), new JTextArea(4, 40)); ui.add(sp, BorderLayout.CENTER); JFrame f = new JFrame("Stretch Combo Layout"); f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); f.setContentPane(ui);/*from w ww .j a v a 2 s .c o m*/ f.pack(); f.setLocationByPlatform(true); f.setVisible(true); }
From source file:Main.java
public static void main(String[] a) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel outerPanel = new JPanel(new BorderLayout()); JPanel topPanel = new JPanel(new BorderLayout()); JLabel label = new JLabel("Name:"); JTextField text = new JTextField(); topPanel.add(label, BorderLayout.PAGE_START); topPanel.add(text, BorderLayout.CENTER); outerPanel.add(topPanel, BorderLayout.AFTER_LAST_LINE); frame.add(outerPanel);/*from w w w.j a v a 2 s . com*/ frame.setSize(300, 200); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JPanel gui = new JPanel(new BorderLayout()); gui.setBorder(new EmptyBorder(2, 3, 2, 3)); JPanel textPanel = new JPanel(new BorderLayout(5, 5)); textPanel.add(new JScrollPane(new JTextArea("Top Text", 3, 20)), BorderLayout.PAGE_START); textPanel.add(new JScrollPane(new JTextArea("Main Text", 10, 10))); gui.add(textPanel, BorderLayout.CENTER); JPanel buttonCenter = new JPanel(new GridBagLayout()); buttonCenter.setBorder(new EmptyBorder(5, 5, 5, 5)); JPanel buttonPanel = new JPanel(new GridLayout(0, 1, 5, 5)); for (int ii = 1; ii < 6; ii++) { buttonPanel.add(new JButton("Button " + ii)); }//w w w . ja va2s. c om buttonCenter.add(buttonPanel); gui.add(buttonCenter, BorderLayout.LINE_END); JFrame f = new JFrame("Demo"); f.add(gui); f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); f.setLocationByPlatform(true); f.pack(); f.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JPanel gui = new JPanel(new BorderLayout(5, 5)); int sz = 4;/* www .jav a 2 s . co m*/ Container content = new JPanel(new GridLayout(sz, 0, 2, 2)); for (int f = 0; f < sz * sz; f++) { content.add(new JButton()); } gui.add(content, BorderLayout.CENTER); Container info = new JPanel(new FlowLayout(FlowLayout.CENTER, 50, 5)); info.add(new JLabel("Flow")); info.add(new JLabel("Layout")); gui.add(info, BorderLayout.PAGE_START); gui.add(new JLabel("Label"), BorderLayout.LINE_END); JOptionPane.showMessageDialog(null, gui); }
From source file:Main.java
public static void main(String[] args) { showFrameWithToolBar(BorderLayout.PAGE_START); showFrameWithToolBar(BorderLayout.PAGE_END); showFrameWithToolBar(BorderLayout.LINE_START); showFrameWithToolBar(BorderLayout.LINE_END); showFrameWithToolBar(BorderLayout.CENTER); }
From source file:Main.java
public static void main(String[] args) { JPanel ui = new JPanel(new BorderLayout(4, 4)); ui.setBorder(new EmptyBorder(6, 6, 6, 6)); JPanel controls = new JPanel(new FlowLayout(FlowLayout.LEADING)); ui.add(controls, BorderLayout.PAGE_START); int s = 100;//from w w w .ja va 2s. c om Dimension[] sizes = { new Dimension(s * 4, s * 2), new Dimension(s * 6, s * 3), new Dimension(s * 8, s * 4) }; final JComboBox cb = new JComboBox(sizes); controls.add(cb); final JPanel[] panels = new JPanel[sizes.length]; for (int ii = 0; ii < sizes.length; ii++) { Dimension d = sizes[ii]; BufferedImage bi = new BufferedImage(d.width, d.height, BufferedImage.TYPE_INT_RGB); JPanel p = new JPanel(new GridLayout()); JLabel l = new JLabel(new ImageIcon(bi)); p.add(l); panels[ii] = p; } ItemListener sizeListener = new ItemListener() { JPanel current = panels[0]; @Override public void itemStateChanged(ItemEvent e) { JPanel next = panels[cb.getSelectedIndex()]; swapComponentsAndResizeUI(ui, current, next); current = next; } }; cb.addItemListener(sizeListener); ui.add(panels[0], BorderLayout.CENTER); JFrame f = new JFrame("Three Sized Panels"); f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); f.setContentPane(ui); f.pack(); f.setLocationByPlatform(true); f.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JPanel gui = new JPanel(new BorderLayout()); gui.setPreferredSize(new Dimension(400, 100)); JDesktopPane dtp = new JDesktopPane(); gui.add(dtp, BorderLayout.CENTER); JButton newFrame = new JButton("Add Frame"); ActionListener listener = new ActionListener() { private int disp = 10; @Override// w w w . ja v a 2 s. c om public void actionPerformed(ActionEvent e) { JInternalFrame jif = new JInternalFrame(); dtp.add(jif); jif.setLocation(disp, disp); jif.setSize(100, 100); disp += 10; jif.setVisible(true); } }; newFrame.addActionListener(listener); gui.add(newFrame, BorderLayout.PAGE_START); JFrame f = new JFrame(); f.add(gui); f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); f.setLocationByPlatform(true); f.pack(); f.setVisible(true); }
From source file:Main.java
public Main() { comboBox = new JComboBox(new String[] { "Select Pet", "Bird", "Cat", "Dog", "Rabbit", "Pig", "Other" }); add(comboBox, BorderLayout.PAGE_START); JFrame frame = new JFrame("Main"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(comboBox);//from www . j a va 2s . c o m frame.pack(); frame.setVisible(true); comboBox.showPopup(); Object child = comboBox.getAccessibleContext().getAccessibleChild(0); BasicComboPopup popup = (BasicComboPopup) child; popup.setName("BasicComboPopup"); JList list = popup.getList(); Container c = SwingUtilities.getAncestorOfClass(JScrollPane.class, list); JScrollPane scrollPane = (JScrollPane) c; Window mainFrame = SwingUtilities.windowForComponent(comboBox); System.out.println(mainFrame.getName()); Window popupWindow = SwingUtilities.windowForComponent(popup); System.out.println(popupWindow); Window popupWindowa = SwingUtilities.windowForComponent(c); System.out.println(popupWindowa); Window mainFrame1 = SwingUtilities.getWindowAncestor(comboBox); System.out.println(mainFrame1); Window popupWindow1 = SwingUtilities.getWindowAncestor(popup); System.out.println(popupWindow1); Component mainFrame2 = SwingUtilities.getRoot(comboBox); System.out.println(mainFrame2.getName()); Component popupWindow2 = SwingUtilities.getRoot(popup); System.out.println(popupWindow2); if (popupWindow != mainFrame) { popupWindow.pack(); } }
From source file:Main.java
Main() { JPanel p = new JPanel(new BorderLayout(2, 2)); JTextField find = new JTextField("food:pizza"); find.addActionListener(e -> {//w w w . j a v a2 s .c om boolean found = findText(find.getText()); System.out.println(find.getText() + " found " + found); }); p.add(find, BorderLayout.PAGE_START); tree.setVisibleRowCount(8); for (int row = tree.getRowCount(); row >= 0; row--) { tree.expandRow(row); } p.add(new JScrollPane(tree), BorderLayout.CENTER); JOptionPane.showMessageDialog(null, p); }
From source file:Main.java
public Main() { tabbedPane.add(new JScrollPane(createTabbedPanel()), "Tab " + i); add.addActionListener(e -> {/*ww w.ja va 2 s. c o m*/ i++; tabbedPane.add(new JScrollPane(createTabbedPanel()), "Tab " + i); }); JFrame frame = new JFrame(); JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.LEADING)); buttonPanel.add(add); frame.add(buttonPanel, BorderLayout.PAGE_START); frame.add(tabbedPane); frame.pack(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setLocationRelativeTo(null); frame.setVisible(true); }