List of usage examples for javax.swing JSplitPane HORIZONTAL_SPLIT
int HORIZONTAL_SPLIT
To view the source code for javax.swing JSplitPane HORIZONTAL_SPLIT.
Click Source Link
Component
s are split along the x axis. From source file:Main.java
public static void main(String args[]) { JFrame frame = new JFrame("Use TextAction"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); final JTextArea leftArea = new JTextArea(); final JTextArea rightArea = new JTextArea(); JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, new JScrollPane(leftArea), new JScrollPane(rightArea)); splitPane.setDividerLocation(.5);/*from ww w . ja v a2 s . c o m*/ JMenuBar menuBar = new JMenuBar(); frame.setJMenuBar(menuBar); JMenu menu = new JMenu("Options"); menuBar.add(menu); JMenuItem menuItem; Action readAction = leftArea.getActionMap().get(DefaultEditorKit.readOnlyAction); menuItem = menu.add(readAction); menuItem.setText("Make read-only"); Action writeAction = leftArea.getActionMap().get(DefaultEditorKit.writableAction); menuItem = menu.add(writeAction); menuItem.setText("Make writable"); menu.addSeparator(); Action cutAction = leftArea.getActionMap().get(DefaultEditorKit.cutAction); menuItem = menu.add(cutAction); menuItem.setText("Cut"); Action copyAction = leftArea.getActionMap().get(DefaultEditorKit.copyAction); menuItem = menu.add(copyAction); menuItem.setText("Copy"); Action pasteAction = leftArea.getActionMap().get(DefaultEditorKit.pasteAction); menuItem = menu.add(pasteAction); menuItem.setText("Paste"); frame.add(splitPane, BorderLayout.CENTER); frame.setSize(400, 250); frame.setVisible(true); }
From source file:UseActions.java
public static void main(String args[]) { JFrame frame = new JFrame("Use TextAction"); Container contentPane = frame.getContentPane(); Dimension empty = new Dimension(0, 0); final JTextArea leftArea = new JTextArea(); JScrollPane leftScrollPane = new JScrollPane(leftArea); leftScrollPane.setPreferredSize(empty); final JTextArea rightArea = new JTextArea(); JScrollPane rightScrollPane = new JScrollPane(rightArea); rightScrollPane.setPreferredSize(empty); JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, leftScrollPane, rightScrollPane); JMenuBar menuBar = new JMenuBar(); frame.setJMenuBar(menuBar);/*from w w w .j ava 2 s . c o m*/ JMenu menu = new JMenu("Options"); menuBar.add(menu); JMenuItem menuItem; Action readAction = leftArea.getActionMap().get(DefaultEditorKit.readOnlyAction); menuItem = menu.add(readAction); menuItem.setText("Make read-only"); Action writeAction = leftArea.getActionMap().get(DefaultEditorKit.writableAction); menuItem = menu.add(writeAction); menuItem.setText("Make writable"); menu.addSeparator(); Action cutAction = leftArea.getActionMap().get(DefaultEditorKit.cutAction); menuItem = menu.add(cutAction); menuItem.setText("Cut"); Action copyAction = leftArea.getActionMap().get(DefaultEditorKit.copyAction); menuItem = menu.add(copyAction); menuItem.setText("Copy"); Action pasteAction = leftArea.getActionMap().get(DefaultEditorKit.pasteAction); menuItem = menu.add(pasteAction); menuItem.setText("Paste"); contentPane.add(splitPane, BorderLayout.CENTER); frame.setSize(400, 250); frame.setVisible(true); splitPane.setDividerLocation(.5); }
From source file:Main.java
public static void main(String args[]) { JFrame frame = new JFrame(); Container contentPane = frame.getContentPane(); ComponentListener comp = new ComponentListener() { public void componentHidden(ComponentEvent e) { dump("Hidden", e); }//from w ww . j ava2s . c o m public void componentMoved(ComponentEvent e) { dump("Moved", e); } public void componentResized(ComponentEvent e) { dump("Resized", e); } public void componentShown(ComponentEvent e) { dump("Shown", e); } private void dump(String type, ComponentEvent e) { System.out.println(e.getComponent().getName() + " : " + type); } }; JButton left = new JButton("Left"); left.setName("Left"); left.addComponentListener(comp); final JButton right = new JButton("Right"); right.setName("Right"); right.addComponentListener(comp); ActionListener action = new ActionListener() { public void actionPerformed(ActionEvent e) { right.setVisible(!right.isVisible()); } }; left.addActionListener(action); JSplitPane pane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, left, right); contentPane.add(pane, BorderLayout.CENTER); frame.setSize(300, 200); frame.show(); }
From source file:TreeTester.java
public static void main(String args[]) { JFrame f = new JFrame("Tree Dragging Tester"); DndTree tree1 = new DndTree(); JScrollPane leftPane = new JScrollPane(tree1); DndTree tree2 = new DndTree(); JScrollPane rightPane = new JScrollPane(tree2); JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, leftPane, rightPane); f.getContentPane().add(splitPane, BorderLayout.CENTER); f.setSize(300, 200);/*from www .j a v a 2 s. co m*/ f.setVisible(true); }
From source file:com.googlecode.sarasvati.visual.jung.JungVisualizer.java
@SuppressWarnings("serial") public static void main(String[] args) throws Exception { TestSetup.init();/*from www. j a v a 2 s . c o m*/ Session session = TestSetup.openSession(); HibEngine engine = new HibEngine(session); JFrame frame = new JFrame("Workflow Visualizer"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setMinimumSize(new Dimension(800, 600)); JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); frame.getContentPane().add(splitPane); DefaultListModel listModel = new DefaultListModel(); for (Graph g : engine.getRepository().getGraphs()) { listModel.addElement(g); } ListCellRenderer cellRenderer = new DefaultListCellRenderer() { @Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); Graph g = (Graph) value; setText(g.getName() + "." + g.getVersion() + " "); return this; } }; final JList graphList = new JList(listModel); graphList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); graphList.setCellRenderer(cellRenderer); JScrollPane listScrollPane = new JScrollPane(graphList); listScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); listScrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); splitPane.add(listScrollPane); //TreeLayout<NodeRef, Arc> layout = new TreeLayout<NodeRef, Arc>(); DirectedSparseMultigraph<Node, Arc> graph = new DirectedSparseMultigraph<Node, Arc>(); //final SpringLayout2<HibNodeRef, HibArc> layout = new SpringLayout2<HibNodeRef, HibArc>(graph); //final KKLayout<HibNodeRef, HibArc> layout = new KKLayout<HibNodeRef, HibArc>(graph); final TreeLayout layout = new TreeLayout(graph); final BasicVisualizationServer<Node, Arc> vs = new BasicVisualizationServer<Node, Arc>(layout); //vs.getRenderContext().setVertexLabelTransformer( new NodeLabeller() ); //vs.getRenderContext().setEdgeLabelTransformer( new ArcLabeller() ); vs.getRenderContext().setVertexShapeTransformer(new NodeShapeTransformer()); vs.getRenderContext().setVertexFillPaintTransformer(new NodeColorTransformer()); vs.getRenderContext().setLabelOffset(5); vs.getRenderContext().setVertexIconTransformer(new Transformer<Node, Icon>() { @Override public Icon transform(Node node) { return "task".equals(node.getType()) ? new TaskIcon(node) : null; } }); Transformer<Arc, Paint> edgeColorTrans = new Transformer<Arc, Paint>() { private Color darkRed = new Color(128, 0, 0); @Override public Paint transform(Arc arc) { return "reject".equals(arc.getName()) ? darkRed : Color.black; } }; vs.getRenderContext().setEdgeDrawPaintTransformer(edgeColorTrans); vs.getRenderContext().setArrowDrawPaintTransformer(edgeColorTrans); final JScrollPane scrollPane = new JScrollPane(vs); scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED); splitPane.add(scrollPane); scrollPane.setBackground(Color.white); graphList.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (e.getValueIsAdjusting()) { return; } final Graph g = (Graph) graphList.getSelectedValue(); if ((g == null && currentGraph == null) || (g != null && g.equals(currentGraph))) { return; } currentGraph = g; DirectedSparseMultigraph<Node, Arc> jungGraph = new DirectedSparseMultigraph<Node, Arc>(); for (Node ref : currentGraph.getNodes()) { jungGraph.addVertex(ref); } for (Arc arc : currentGraph.getArcs()) { jungGraph.addEdge(arc, arc.getStartNode(), arc.getEndNode()); } GraphTree graphTree = new GraphTree(g); layout.setGraph(jungGraph); layout.setInitializer(new NodeLocationTransformer(graphTree)); scrollPane.repaint(); } }); frame.setVisible(true); }
From source file:ws.moor.bt.grapher.Grapher.java
public static void main(String[] args) throws IOException { if (args.length != 1) { System.err.println("Please specify a tab-separated values file"); System.exit(1);//from w w w . j ava 2 s . c o m } File file = new File(args[0]); final CSVMapCollector collector = new CSVMapCollector( new CSVSkipFilter(new CSVInputStream(new FileInputStream(file)), 0 * 1000)); JFrame window = new JFrame("Grapher"); window.setSize(1100, 800); window.setLayout(new BorderLayout()); final ChartPanel chartPanel = new ChartPanel(null); List<String> possibleNames = collector.getAvailableStreams(); Collections.sort(possibleNames); TreeNode root = convertToTree(possibleNames); final JTree tree = new JTree(root); tree.getSelectionModel().addTreeSelectionListener(new TreeSelectionListener() { public void valueChanged(TreeSelectionEvent e) { List<String> names = new ArrayList<String>(); final TreePath[] paths = tree.getSelectionModel().getSelectionPaths(); if (paths == null) { chartPanel.setChart(null); return; } for (TreePath path : paths) { Object lastPath = path.getLastPathComponent(); if (lastPath instanceof DefaultMutableTreeNode) { Object value = ((DefaultMutableTreeNode) lastPath).getUserObject(); if (value instanceof NodeValue) { names.add(value.toString()); } } } chartPanel.setChart(createChart(collector, names.toArray(new String[names.size()]))); } }); Font font = tree.getFont(); tree.setFont(font.deriveFont(10.0f)); JScrollPane scrollPane = new JScrollPane(tree); JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); splitPane.setLeftComponent(scrollPane); splitPane.setRightComponent(chartPanel); splitPane.setDividerLocation(200); window.setContentPane(splitPane); window.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;//w w w .j a v a 2s .c o m 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 static float getDividerProportion(JSplitPane splitPane) { if (splitPane == null) return 0; int size = splitPane.getOrientation() == JSplitPane.HORIZONTAL_SPLIT ? splitPane.getWidth() : splitPane.getHeight();//from w w w.j av a 2s. c o m int divLoc = splitPane.getDividerLocation(); return size == 0 ? 0 : (float) divLoc / ((float) size - splitPane.getDividerSize()); }
From source file:MainClass.java
public MainClass() { super("Simple SplitPane Frame"); setSize(450, 200);// ww w . j a va2 s. c o m setDefaultCloseOperation(EXIT_ON_CLOSE); JTextArea jt1 = new JTextArea(sometext); JTextArea jt2 = new JTextArea(sometext); jt1.setLineWrap(true); jt2.setLineWrap(true); jt1.setMinimumSize(new Dimension(150, 150)); jt2.setMinimumSize(new Dimension(150, 150)); jt1.setPreferredSize(new Dimension(250, 200)); JSplitPane sp = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, jt1, jt2); getContentPane().add(sp, BorderLayout.CENTER); }
From source file:Test.java
public Test() { setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel panel1 = new JPanel(new GridLayout(1, 5)); for (int i = 0; i < 5; i++) { panel1.add(new JLabel("Left " + i)); }/* w w w .ja v a 2 s . com*/ panel1.setPreferredSize(new Dimension(250, 50)); JPanel panel2 = new JPanel(new GridLayout(1, 5)); for (int i = 0; i < 5; i++) { panel2.add(new JLabel("Right " + i)); } panel2.setPreferredSize(new Dimension(250, 50)); final JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, panel1, panel2); split.setContinuousLayout(true); getContentPane().add(split, BorderLayout.CENTER); pack(); setSize(500, 100); }