List of usage examples for javax.swing JToolBar setLayout
public void setLayout(LayoutManager mgr)
From source file:com.declarativa.interprolog.gui.ListenerWindow.java
private void graphComponents() throws IOException { Forest<String, Integer> forest = new DelegateForest<>(); Forest<String, Integer> forest2 = new DelegateForest<>(); Forest<String, Integer> forest3 = new DelegateForest<>(); //ObservableGraph g = new ObservableGraph(new BalloonLayoutDemo().createTree(forest)); ObservableGraph g = new ObservableGraph(new GraphGenerator().createTree(forest)); ObservableGraph g2 = new ObservableGraph(new GraphGenerator().createTree2(forest2)); ObservableGraph g3 = new ObservableGraph(new GraphGenerator().createTree3(forest3)); //Layout layout = new BalloonLayout(forest); Layout layout = new BalloonLayout(forest); Layout layout2 = new BalloonLayout(forest2); Layout layout3 = new TreeLayout(forest3, 70, 70); final BaseJungScene scene = new SceneImpl(g, layout); final BaseJungScene scene2 = new SceneImpl(g2, layout2); final BaseJungScene scene3 = new SceneImpl(g3, layout3); jLayeredPane1.setLayout(new BorderLayout()); //jf.setLayout(new BorderLayout()); jLayeredPane5.setLayout(new BorderLayout()); jLayeredPane8.setLayout(new BorderLayout()); jLayeredPane1.add(new JScrollPane(scene.createView()), BorderLayout.CENTER); //jf.add(new JScrollPane(scene2.createView()), BorderLayout.CENTER); jLayeredPane5.add(new JScrollPane(scene2.createView()), BorderLayout.CENTER); jLayeredPane8.add(new JScrollPane(scene3.createView()), BorderLayout.CENTER); JToolBar bar = new JToolBar(); bar.setMargin(new Insets(5, 5, 5, 5)); bar.setLayout(new FlowLayout(5)); DefaultComboBoxModel<Layout> mdl = new DefaultComboBoxModel<>(); mdl.addElement(new KKLayout(g)); mdl.addElement(layout);/* ww w.j a v a 2s . c o m*/ mdl.addElement(new BalloonLayout(forest)); mdl.addElement(new RadialTreeLayout(forest)); mdl.addElement(new CircleLayout(g)); mdl.addElement(new FRLayout(g)); mdl.addElement(new FRLayout2(g)); mdl.addElement(new ISOMLayout(g)); mdl.addElement(new edu.uci.ics.jung.algorithms.layout.SpringLayout(g)); mdl.addElement(new SpringLayout2(g)); mdl.addElement(new DAGLayout(g)); mdl.addElement(new XLayout(g)); mdl.setSelectedItem(layout); final JCheckBox checkbox = new JCheckBox("Animate iterative layouts"); scene.setLayoutAnimationFramesPerSecond(48); scene2.setLayoutAnimationFramesPerSecond(48); scene3.setLayoutAnimationFramesPerSecond(48); final JComboBox<Layout> layouts = new JComboBox(mdl); layouts.setRenderer(new DefaultListCellRenderer() { @Override public Component getListCellRendererComponent(JList<?> jlist, Object o, int i, boolean bln, boolean bln1) { o = o.getClass().getSimpleName(); return super.getListCellRendererComponent(jlist, o, i, bln, bln1); //To change body of generated methods, choose Tools | Templates. } }); bar.add(new JLabel(" Layout Type")); bar.add(layouts); layouts.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { Layout layout = (Layout) layouts.getSelectedItem(); // These two layouts implement IterativeContext, but they do // not evolve toward anything, they just randomly rearrange // themselves. So disable animation for these. if (layout instanceof ISOMLayout || layout instanceof DAGLayout) { checkbox.setSelected(false); } scene.setGraphLayout(layout, true); } }); bar.add(new JLabel(" Connection Shape")); DefaultComboBoxModel<Transformer<Context<Graph<String, Number>, Number>, Shape>> shapes = new DefaultComboBoxModel<>(); shapes.addElement(new EdgeShape.QuadCurve<String, Number>()); shapes.addElement(new EdgeShape.BentLine<String, Number>()); shapes.addElement(new EdgeShape.CubicCurve<String, Number>()); shapes.addElement(new EdgeShape.Line<String, Number>()); shapes.addElement(new EdgeShape.Box<String, Number>()); shapes.addElement(new EdgeShape.Orthogonal<String, Number>()); shapes.addElement(new EdgeShape.Wedge<String, Number>(10)); final JComboBox<Transformer<Context<Graph<String, Number>, Number>, Shape>> shapesBox = new JComboBox<>( shapes); shapesBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { Transformer<Context<Graph<String, Number>, Number>, Shape> xform = (Transformer<Context<Graph<String, Number>, Number>, Shape>) shapesBox .getSelectedItem(); scene.setConnectionEdgeShape(xform); } }); shapesBox.setRenderer(new DefaultListCellRenderer() { @Override public Component getListCellRendererComponent(JList<?> jlist, Object o, int i, boolean bln, boolean bln1) { o = o.getClass().getSimpleName(); return super.getListCellRendererComponent(jlist, o, i, bln, bln1); //To change body of generated methods, choose Tools | Templates. } }); shapesBox.setSelectedItem(new EdgeShape.QuadCurve<>()); bar.add(shapesBox); //jf.add(bar, BorderLayout.NORTH); bar.add(new ListenerWindow.MinSizePanel(scene.createSatelliteView())); bar.setFloatable(false); bar.setRollover(true); final JLabel selectionLabel = new JLabel("<html> </html>"); System.out.println("LOOKUP IS " + scene.getLookup()); Lookup.Result<String> selectedNodes = scene.getLookup().lookupResult(String.class); LookupListener listener = new LookupListener() { @Override public void resultChanged(LookupEvent le) { System.out.println("RES CHANGED"); Lookup.Result<String> res = (Lookup.Result<String>) le.getSource(); StringBuilder sb = new StringBuilder("<html>"); List<String> l = new ArrayList<>(res.allInstances()); Collections.sort(l); for (String s : l) { if (sb.length() != 0) { sb.append(", "); } sb.append(s); } sb.append("</html>"); selectionLabel.setText(sb.toString()); System.out.println("LOOKUP EVENT " + sb); } }; selectedNodes.addLookupListener(listener); selectedNodes.allInstances(); bar.add(selectionLabel); checkbox.setSelected(true); checkbox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { scene.setAnimateIterativeLayouts(checkbox.isSelected()); } }); bar.add(checkbox); jLayeredPane3.setLayout(new BorderLayout()); jLayeredPane6.setLayout(new BorderLayout()); jLayeredPane3.add(bar); jLayeredPane6.add(bar); // jf.setSize(jf.getGraphicsConfiguration().getBounds().width - 120, 700); // jf.setSize(new Dimension(1280, 720)); // jf.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); this.addWindowListener(new WindowAdapter() { @Override public void windowOpened(WindowEvent we) { scene.relayout(true); scene.validate(); scene2.relayout(true); scene2.validate(); scene3.relayout(true); scene3.validate(); } }); }
From source file:edu.ku.brc.specify.Specify.java
/** * * @return the toolbar for the app//from w ww . j a v a 2 s . c o m */ public JToolBar createToolBar() { JToolBar toolBar; SkinItem skinItem = SkinsMgr.getSkinItem("ToolBar"); if (SkinsMgr.hasSkins() && skinItem != null && (skinItem.getBGImage() != null || skinItem.getBgColor() != null)) { JTiledToolbar ttb = new JTiledToolbar(skinItem.getBGImage()); if (skinItem.getBgColor() != null) { ttb.setBackground(skinItem.getBgColor()); ttb.setOpaque(true); } else { ttb.setOpaque(false); } toolBar = ttb; } else { toolBar = new JToolBar(); } toolBar.setLayout(new ToolbarLayoutManager(2, 2)); appIcon = new JLabel(" "); //$NON-NLS-1$ setAppIcon(AppPreferences.getRemote().get("ui.formatting.user_icon_image", null)); //$NON-NLS-1$ CommandDispatcher.register("Preferences", new CommandListener() { //$NON-NLS-1$ public void doCommand(CommandAction cmdAction) { if (cmdAction.isAction("Updated")) //$NON-NLS-1$ { setAppIcon(AppPreferences.getRemote().get("ui.formatting.user_icon_image", null)); //$NON-NLS-1$ } } }); return toolBar; }
From source file:org.zeromeaner.gui.reskin.StandaloneFrame.java
private JToolBar createToolbar() { JToolBar t = new JToolBar(JToolBar.VERTICAL); t.setFloatable(false);/* w ww . java2s . co m*/ t.setLayout(new GridLayout(0, 1)); ButtonGroup g = new ButtonGroup(); AbstractButton b; b = playButton = new JToggleButton(new ToolbarAction("toolbar.play") { @Override public void actionPerformed(ActionEvent e) { super.actionPerformed(e); if (CARD_PLAY.equals(currentCard)) playCardSelected(); } }); add(t, g, b); b = new JToggleButton(new ToolbarAction("toolbar.modeselect")); add(t, g, b); b = netplayButton = new JToggleButton(new ToolbarAction("toolbar.netplay") { @Override public void actionPerformed(ActionEvent e) { if (CARD_NETPLAY.equals(currentCard)) return; super.actionPerformed(e); netplayCardSelected(); } }); add(t, g, b); /* b = new JToggleButton(new ToolbarAction("toolbar.rule_1p")); add(t, g, b); */ b = new JToggleButton(new ToolbarAction("toolbar.keys_1p")); add(t, g, b); b = new JToggleButton(new ToolbarAction("toolbar.tuning_1p")); add(t, g, b); b = new JToggleButton(new ToolbarAction("toolbar.ai_1p")); add(t, g, b); /* b = new JToggleButton(new ToolbarAction("toolbar.rule_2p")); add(t, g, b); */ b = new JToggleButton(new ToolbarAction("toolbar.keys_2p")); add(t, g, b); b = new JToggleButton(new ToolbarAction("toolbar.tuning_2p")); add(t, g, b); b = new JToggleButton(new ToolbarAction("toolbar.ai_2p")); add(t, g, b); b = new JToggleButton(new ToolbarAction("toolbar.general")); add(t, g, b); b = new JToggleButton(new ToolbarAction("toolbar.open")); add(t, g, b); b = new JToggleButton(new ToolbarAction(CARD_FEEDBACK)); add(t, g, b); b = new JToggleButton(new ToolbarAction("toolbar.close") { @Override public void actionPerformed(ActionEvent e) { StandaloneMain.saveConfig(); System.exit(0); } }); add(t, g, b); return t; }
From source file:verdandi.ui.ProjectViewerPanel.java
private JToolBar getToolbar() { // JPanel toolbar = new JPanel(); // toolbar.setLayout(new BoxLayout(toolbar, BoxLayout.LINE_AXIS)); JToolBar toolbar = new JToolBar(SwingConstants.HORIZONTAL); toolbar.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.gridx = 0;//from ww w . j a v a 2 s . c o m c.gridy = 0; c.fill = GridBagConstraints.NONE; c.anchor = GridBagConstraints.WEST; c.weightx = 0.0; c.weighty = 0.0; URL imageURL = null; imageURL = Thread.currentThread().getContextClassLoader() .getResource(THEME_RC.getString("icon.project.add")); ImageIcon addProjectIcon = new ImageIcon(imageURL, "add"); JButton addProject = new JButton(addProjectIcon); addProject.setActionCommand(CMD_ADD_PROJECT); addProject.setToolTipText(RB.getString("projectviewer.add.tooltip")); addProject.addActionListener(this); toolbar.add(addProject, c); c.gridx++; imageURL = getClass().getClassLoader().getResource(THEME_RC.getString("icon.project.edit")); ImageIcon editProjectIcon = new ImageIcon(imageURL, "edit"); JButton editProject = new JButton(editProjectIcon); editProject.setActionCommand(CMD_EDIT_PROJECT); editProject.setToolTipText(RB.getString("projectviewer.edit.tooltip")); editProject.addActionListener(this); toolbar.add(editProject, c); c.gridx++; imageURL = getClass().getClassLoader().getResource(THEME_RC.getString("icon.projects.import")); ImageIcon importProjectIcon = new ImageIcon(imageURL, "import"); JButton importProject = new JButton(importProjectIcon); importProject.setActionCommand(CMD_IMPORT_PROJECT); importProject.setToolTipText(RB.getString("projectviewer.import.tooltip")); importProject.addActionListener(this); toolbar.add(importProject, c); c.gridx++; // THEME_RC.getString("") imageURL = getClass().getClassLoader().getResource(THEME_RC.getString("icon.projects.export")); ImageIcon exportProjectIcon = new ImageIcon(imageURL, "export"); JButton exportProject = new JButton(exportProjectIcon); exportProject.setActionCommand(CMD_EXPORT_PROJECT); exportProject.setToolTipText(RB.getString("projectviewer.export.tooltip")); exportProject.addActionListener(this); toolbar.add(exportProject, c); c.gridx++; toolbar.add(new JToolBar.Separator(), c); c.gridx++; imageURL = getClass().getClassLoader().getResource(THEME_RC.getString("icon.project.hide.active")); hideActiveIcon = new ImageIcon(imageURL, "hide active"); imageURL = getClass().getClassLoader().getResource(THEME_RC.getString("icon.project.show.active")); showActiveIcon = new ImageIcon(imageURL, "show active"); toggleShowActive = new JToggleButton(hideActiveIcon); toggleShowActive.setActionCommand(CMD_TOGGLE_SHOW_ACTIVE); toggleShowActive.setToolTipText(RB.getString("projectviewer.toggleshowactive.tooltip")); toggleShowActive.addActionListener(this); toolbar.add(toggleShowActive, c); c.gridx++; c.weightx = 0.5; toolbar.add(Box.createHorizontalGlue(), c); c.weightx = 0.0; c.gridx++; c.insets = new Insets(0, 5, 0, 5); toolbar.add(new JLabel("Filter"), c); c.gridx++; c.insets = new Insets(0, 0, 0, 0); searchField = new JTextField(10); searchField.getDocument().addDocumentListener(this); searchField.setToolTipText(RB.getString("projectviewer.searchfield.tooltip")); toolbar.add(searchField, c); toolbar.setFloatable(false); return toolbar; }