List of usage examples for javax.swing JSplitPane VERTICAL_SPLIT
int VERTICAL_SPLIT
To view the source code for javax.swing JSplitPane VERTICAL_SPLIT.
Click Source Link
Component
s are split along the y axis. From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel gui = new JPanel(new BorderLayout(5, 5)); JPanel plafComponents = new JPanel(new FlowLayout(FlowLayout.RIGHT, 3, 3)); plafComponents.setBorder(new TitledBorder("FlowLayout(FlowLayout.RIGHT, 3,3)")); UIManager.LookAndFeelInfo[] plafInfos = UIManager.getInstalledLookAndFeels(); String[] plafNames = new String[plafInfos.length]; for (int ii = 0; ii < plafInfos.length; ii++) { plafNames[ii] = plafInfos[ii].getName(); }/*from w ww . j a va 2 s .c om*/ JComboBox plafChooser = new JComboBox(plafNames); plafComponents.add(plafChooser); JCheckBox pack = new JCheckBox("Pack on PLAF change", true); plafComponents.add(pack); plafChooser.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { int index = plafChooser.getSelectedIndex(); try { UIManager.setLookAndFeel(plafInfos[index].getClassName()); SwingUtilities.updateComponentTreeUI(frame); if (pack.isSelected()) { frame.pack(); frame.setMinimumSize(frame.getSize()); } } catch (Exception e) { e.printStackTrace(); } } }); gui.add(plafComponents, BorderLayout.NORTH); JPanel dynamicLabels = new JPanel(new BorderLayout(4, 4)); dynamicLabels.setBorder(new TitledBorder("BorderLayout(4,4)")); gui.add(dynamicLabels, BorderLayout.WEST); final JPanel labels = new JPanel(new GridLayout(0, 2, 3, 3)); labels.setBorder(new TitledBorder("GridLayout(0,2,3,3)")); JButton addNew = new JButton("Add Another Label"); dynamicLabels.add(addNew, BorderLayout.NORTH); addNew.addActionListener(new ActionListener() { private int labelCount = 0; public void actionPerformed(ActionEvent ae) { labels.add(new JLabel("Label " + ++labelCount)); frame.validate(); } }); dynamicLabels.add(new JScrollPane(labels), BorderLayout.CENTER); String[] header = { "Name", "Value" }; String[] a = new String[0]; String[] names = System.getProperties().stringPropertyNames().toArray(a); String[][] data = new String[names.length][2]; for (int ii = 0; ii < names.length; ii++) { data[ii][0] = names[ii]; data[ii][1] = System.getProperty(names[ii]); } DefaultTableModel model = new DefaultTableModel(data, header); JTable table = new JTable(model); JScrollPane tableScroll = new JScrollPane(table); Dimension tablePreferred = tableScroll.getPreferredSize(); tableScroll.setPreferredSize(new Dimension(tablePreferred.width, tablePreferred.height / 3)); JPanel imagePanel = new JPanel(new GridBagLayout()); JLabel imageLabel = new JLabel("test"); imagePanel.add(imageLabel, null); JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, tableScroll, new JScrollPane(imagePanel)); gui.add(splitPane, BorderLayout.CENTER); frame.setContentPane(gui); frame.pack(); frame.setVisible(true); }
From source file:SimpleClient.java
public static void main(String argv[]) { boolean usage = false; for (int optind = 0; optind < argv.length; optind++) { if (argv[optind].equals("-L")) { url.addElement(argv[++optind]); } else if (argv[optind].startsWith("-")) { usage = true;/*from ww w .ja v a 2 s .c om*/ break; } else { usage = true; break; } } if (usage || url.size() == 0) { System.out.println("Usage: SimpleClient -L url"); System.out.println(" where url is protocol://username:password@hostname/"); System.exit(1); } try { // Set up our Mailcap entries. This will allow the JAF // to locate our viewers. File capfile = new File("simple.mailcap"); if (!capfile.isFile()) { System.out.println("Cannot locate the \"simple.mailcap\" file."); System.exit(1); } CommandMap.setDefaultCommandMap(new MailcapCommandMap(new FileInputStream(capfile))); JFrame frame = new JFrame("Simple JavaMail Client"); frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); //frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); // Get a Store object SimpleAuthenticator auth = new SimpleAuthenticator(frame); Session session = Session.getDefaultInstance(System.getProperties(), auth); //session.setDebug(true); DefaultMutableTreeNode root = new DefaultMutableTreeNode("Root"); // create a node for each store we have for (Enumeration e = url.elements(); e.hasMoreElements();) { String urlstring = (String) e.nextElement(); URLName urln = new URLName(urlstring); Store store = session.getStore(urln); StoreTreeNode storenode = new StoreTreeNode(store); root.add(storenode); } DefaultTreeModel treeModel = new DefaultTreeModel(root); JTree tree = new JTree(treeModel); tree.addTreeSelectionListener(new TreePress()); /* Put the Tree in a scroller. */ JScrollPane sp = new JScrollPane(); sp.setPreferredSize(new Dimension(250, 300)); sp.getViewport().add(tree); /* Create a double buffered JPanel */ JPanel sv = new JPanel(new BorderLayout()); sv.add("Center", sp); fv = new FolderViewer(null); JSplitPane jsp = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, sv, fv); jsp.setOneTouchExpandable(true); mv = new MessageViewer(); JSplitPane jsp2 = new JSplitPane(JSplitPane.VERTICAL_SPLIT, jsp, mv); jsp2.setOneTouchExpandable(true); frame.getContentPane().add(jsp2); frame.pack(); frame.show(); } catch (Exception ex) { System.out.println("SimpletClient caught exception"); ex.printStackTrace(); System.exit(1); } }
From source file:Main.java
public Main() { setDefaultCloseOperation(EXIT_ON_CLOSE); setSize(400, 400);//ww w. ja v a 2s.c om JSplitPane split = new JSplitPane(JSplitPane.VERTICAL_SPLIT); split.setDividerLocation(200); add(split); JPanel panel1 = new JPanel(); panel1.setLayout(new BorderLayout()); panel1.add(new JLabel("top panel"), BorderLayout.NORTH); JPanel myDrawPanel = new JPanel(); myDrawPanel.setPreferredSize(new Dimension(100, 100)); myDrawPanel.add(new JLabel("draw panel here!")); panel1.add(new JScrollPane(myDrawPanel), BorderLayout.CENTER); split.setTopComponent(panel1); JPanel panel2 = new JPanel(); panel2.add(new JLabel("bottom panel")); split.setBottomComponent(panel2); setVisible(true); }
From source file:Main.java
public static void flattenSplitPane(JSplitPane jSplitPane) { UIDefaults defaults = javax.swing.UIManager.getDefaults(); final Color light = defaults.getColor("SplitPane.highlight"); final Color dark = defaults.getColor("SplitPane.darkShadow"); // *//www . j a va 2 s. c om jSplitPane.setUI(new BasicSplitPaneUI() { public BasicSplitPaneDivider createDefaultDivider() { BasicSplitPaneDivider divider = new BasicSplitPaneDivider(this) { private static final long serialVersionUID = 1L; @Override public int getDividerSize() { return 5; } @Override public void paint(Graphics g) { // super.paint(g); int orientation = this.getBasicSplitPaneUI().getOrientation(); Dimension size = this.getSize(); if (orientation == JSplitPane.VERTICAL_SPLIT) { int[] lines = new int[2]; lines[0] = 0; lines[1] = size.height - 2; for (int i = 0; i < size.width; i += 4) { for (int j = 0; j < lines.length; j++) { int y = lines[j]; g.setColor(light); g.fillRect(i, y, 2, 2); g.setColor(dark); g.fillRect(i, y, 1, 1); } } } else { int[] rows = new int[2]; rows[0] = 0; rows[1] = size.width - 2; for (int i = 0; i < size.height; i += 4) { for (int j = 0; j < rows.length; j++) { int x = rows[j]; g.setColor(light); g.fillRect(x, i, 2, 2); g.setColor(dark); g.fillRect(x, i, 1, 1); } } } } }; return divider; } }); jSplitPane.setBorder(null); // */ }
From source file:SplitSample.java
public SplitSample() { super("Simple Split Pane"); setSize(400, 400);/*from w ww . j ava2s . c o m*/ getContentPane().setLayout(new BorderLayout()); JSplitPane spLeft = new JSplitPane(JSplitPane.VERTICAL_SPLIT, new JPanel(), new JPanel()); spLeft.setDividerSize(8); spLeft.setContinuousLayout(true); JSplitPane spRight = new JSplitPane(JSplitPane.VERTICAL_SPLIT, new JPanel(), new JPanel()); spRight.setDividerSize(8); spRight.setContinuousLayout(true); split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, spLeft, spRight); split.setContinuousLayout(false); split.setOneTouchExpandable(true); getContentPane().add(split, BorderLayout.CENTER); WindowListener wndCloser = new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }; addWindowListener(wndCloser); setVisible(true); }
From source file:Main.java
public void build() { setSize(600, 600);/*from ww w . j ava 2 s . co m*/ JTextPane textPane = new JTextPane(); JScrollPane scrollPane = new JScrollPane(textPane); scrollPane.setPreferredSize(new Dimension(300, 300)); JTextArea changeLog = new JTextArea(5, 30); changeLog.setEditable(false); JScrollPane scrollPaneForLog = new JScrollPane(changeLog); JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, scrollPane, scrollPaneForLog); splitPane.setOneTouchExpandable(true); JPanel statusPane = new JPanel(new GridLayout(1, 1)); JLabel caretListenerLabel = new JLabel("Caret Status"); statusPane.add(caretListenerLabel); JToolBar toolBar = new JToolBar(); toolBar.add(new JButton("Btn1")); toolBar.add(new JButton("Btn2")); toolBar.add(new JButton("Btn3")); toolBar.add(new JButton("Btn4")); getContentPane().add(toolBar, BorderLayout.PAGE_START); getContentPane().add(splitPane, BorderLayout.CENTER); getContentPane().add(statusPane, BorderLayout.PAGE_END); JMenu editMenu = new JMenu("test"); JMenu styleMenu = new JMenu("test"); JMenuBar mb = new JMenuBar(); mb.add(editMenu); mb.add(styleMenu); setJMenuBar(mb); }
From source file:com.intuit.tank.tools.debugger.RequestResponsePanel.java
public void init() { JSplitPane pane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, true); pane.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); requestTA = new RTextArea(); requestTA.setEditable(false);/*from w ww . j av a 2s. c o m*/ requestTA.setAutoscrolls(true); requestTA.setHighlightCurrentLine(false); JScrollPane sp1 = new JScrollPane(requestTA, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); sp1.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); JPanel reqPane = new JPanel(new BorderLayout()); // JPanel titlePanel = new JPanel(new BorderLayout()); // titlePanel.add(BorderLayout.WEST, new JLabel("Request:")); // JButton saveBT = new JButton(parent.getDebuggerActions().getSaveReqResponseAction()); // saveBT.setText(""); // titlePanel.add(BorderLayout.EAST, saveBT); reqPane.add(BorderLayout.NORTH, new JLabel("Request:")); reqPane.add(BorderLayout.CENTER, sp1); pane.setTopComponent(reqPane); responseTA = new RTextArea(); responseTA.setEditable(false); responseTA.setAutoscrolls(true); responseTA.setHighlightCurrentLine(false); JScrollPane sp2 = new JScrollPane(responseTA, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); sp2.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); JPanel responsePane = new JPanel(new BorderLayout()); responsePane.add(BorderLayout.NORTH, new JLabel("Response:")); responsePane.add(BorderLayout.CENTER, sp2); pane.setBottomComponent(responsePane); pane.setDividerLocation(0.5D); pane.setResizeWeight(0.5D); add(pane, BorderLayout.CENTER); JPopupMenu popupMenu = new JPopupMenu(); popupMenu.add(parent.getDebuggerActions().getSaveReqResponseAction()); requestTA.setPopupMenu(popupMenu); responseTA.setPopupMenu(popupMenu); }
From source file:TestTree4.java
public TestTree4() { super("Custom Icon Example"); setSize(350, 450);//from w w w.ja v a2 s . c o m setDefaultCloseOperation(EXIT_ON_CLOSE); // Build the hierarchy of containers & objects String[] schoolyard = { "School", "Playground", "Parking Lot", "Field" }; String[] mainstreet = { "Grocery", "Shoe Shop", "Five & Dime", "Post Office" }; String[] highway = { "Gas Station", "Convenience Store" }; String[] housing = { "Victorian_blue", "Faux Colonial", "Victorian_white" }; String[] housing2 = { "Mission", "Ranch", "Condo" }; Hashtable homeHash = new Hashtable(); homeHash.put("Residential 1", housing); homeHash.put("Residential 2", housing2); Hashtable cityHash = new Hashtable(); cityHash.put("School grounds", schoolyard); cityHash.put("Downtown", mainstreet); cityHash.put("Highway", highway); cityHash.put("Housing", homeHash); Hashtable worldHash = new Hashtable(); worldHash.put("My First VRML World", cityHash); // Build our tree out of our big hashtable tree1 = new JTree(worldHash); tree2 = new JTree(worldHash); DefaultTreeCellRenderer renderer = (DefaultTreeCellRenderer) tree2.getCellRenderer(); renderer.setClosedIcon(new ImageIcon("door.closed.gif")); renderer.setOpenIcon(new ImageIcon("door.open.gif")); renderer.setLeafIcon(new ImageIcon("world.gif")); JSplitPane pane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, tree1, tree2); getContentPane().add(pane, BorderLayout.CENTER); }
From source file:de.unibayreuth.bayeos.goat.panels.timeseries.JPanelDetailMass.java
/** Creates a new instance of JPanelMassendaten */ public JPanelDetailMass(JMainFrame app) { super(app);//from w w w.j ava 2 s . c om panelChart = new JPanelChart(); panelMass = new JPanelTableEditMass(); splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, panelChart, panelMass); splitPane.setOneTouchExpandable(true); splitPane.setDividerLocation(450); add(splitPane, BorderLayout.CENTER); }
From source file:de.unibayreuth.bayeos.goat.panels.timeseries.JPanelDetailLab.java
/** Creates a new instance of JPanelMassendaten */ public JPanelDetailLab(JMainFrame app) { super(app);// www. j a v a2 s . co m panelChart = new JPanelChart(); panelLab = new JPanelTableEditLab(); splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, panelChart, panelLab); splitPane.setOneTouchExpandable(true); splitPane.setDividerLocation(0.3); add(splitPane, BorderLayout.CENTER); }