List of usage examples for javax.swing JToolBar add
public JButton add(Action a)
JButton
which dispatches the action. From source file:ec.util.chart.swing.JTimeSeriesRendererSupportDemo.java
private Component createToolBar() { JToolBar result = new JToolBar(); result.setFloatable(false);//from w w w.j a v a 2s. c o m result.add(RANDOM_DATA.toAction(chart)).setIcon(FontAwesome.FA_RANDOM.getIcon(getForeground(), 16f)); JComboBox<RendererType> types = new JComboBox<>( support.getSupportedRendererTypes().toArray(new RendererType[0])); types.setMaximumSize(new Dimension(150, 100)); types.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { RendererType type = (RendererType) e.getItem(); chart.getXYPlot().setRenderer(support.createRenderer(type)); chart.getXYPlot().setBackgroundPaint(support.getPlotColor()); chart.setBackgroundPaint(colorSchemeSupport.getBackColor()); } }); types.setSelectedIndex(1); result.add(types); return result; }
From source file:com.intuit.tank.proxy.ProxyApp.java
private JToolBar createToolBar() { JToolBar ret = new JToolBar(); // ret.setBackground(new Color(111,167,209)); ret.add(Box.createHorizontalStrut(5)); ret.add(createButton(openAction));/*ww w . j a va2s . c om*/ ret.add(Box.createHorizontalStrut(5)); ret.add(createButton(saveAction)); ret.addSeparator(); ret.add(Box.createHorizontalStrut(5)); ret.add(createButton(startAction)); ret.add(Box.createHorizontalStrut(5)); ret.add(createButton(stopAction)); ret.add(Box.createHorizontalStrut(5)); ret.add(createButton(pauseAction)); ret.add(Box.createHorizontalStrut(5)); ret.addSeparator(); ret.add(Box.createHorizontalStrut(5)); ret.add(createButton(filterAction)); ret.add(createButton(settingsAction)); ret.addSeparator(); ret.add(Box.createHorizontalStrut(5)); ret.add(createButton(showHostsAction)); ret.add(Box.createHorizontalGlue()); return ret; }
From source file:livecanvas.mesheditor.MeshEditor.java
private JToolBar createTools() { JToolBar toolbar = new JToolBar(JToolBar.VERTICAL); ButtonGroup toolsBg = new ButtonGroup(); JToggleButton toolsButton;// w w w.j a va 2s . c om toolbar.add(toolsButton = Utils.createToolBarToggleButton("Brush", new ImageIcon(clazz.getResource("res/brush.png")), ButtonType.ICON_ONLY, TOOLS_BRUSH, "Brush", toolsBg, this)); toolsButton.setSelected(true); toolbar.add(toolsButton = Utils.createToolBarToggleButton("Pen", new ImageIcon(clazz.getResource("res/pen.png")), ButtonType.ICON_ONLY, TOOLS_PEN, "Pen", toolsBg, this)); toolbar.add(toolsButton = Utils.createToolBarToggleButton("MagicWand", new ImageIcon(clazz.getResource("res/wand.png")), ButtonType.ICON_ONLY, TOOLS_MAGICWAND, "Magic Wand", toolsBg, this)); toolbar.add(toolsButton = Utils.createToolBarToggleButton("SetControlPoints", new ImageIcon(clazz.getResource("res/set_controls.png")), ButtonType.ICON_ONLY, TOOLS_SETCONTROLPOINTS, "Set Control Points", toolsBg, this)); toolbar.add(toolsButton = Utils.createToolBarToggleButton("Pointer", new ImageIcon(clazz.getResource("res/pointer.png")), ButtonType.ICON_ONLY, TOOLS_POINTER, "Pointer", toolsBg, this)); toolbar.add(toolsButton = Utils.createToolBarToggleButton("PanZoom", new ImageIcon(clazz.getResource("res/panzoom.png")), ButtonType.ICON_ONLY, TOOLS_PANZOOM, "Pan or Zoom Canvas", toolsBg, this)); // toolsButton.setSelected(true); return toolbar; }
From source file:cl.almejo.vsim.gui.SimWindow.java
private void addMainToolbar() { JToolBar toolBar = new JToolBar(); toolBar.add(newToolbarButton(NEW_ACTION)); toolBar.add(newToolbarButton(OPEN_ACTION)); toolBar.add(newToolbarButton(SAVE_ACTION)); toolBar.addSeparator();/* w w w .j ava 2 s.co m*/ toolBar.add(newToolbarButton(UNDO_ACTION)); toolBar.add(newToolbarButton(REDO_ACTION)); toolBar.add(newToolbarButton(CUT_ACTION)); toolBar.add(newToolbarButton(COPY_ACTION)); toolBar.add(newToolbarButton(PASTE_ACTION)); toolBar.addSeparator(); ButtonGroup group = new ButtonGroup(); toolBar.add(newGrouppedButton(START_ACTION, group)); toolBar.add(newGrouppedButton(PAUSE_ACTION, group)); getContentPane().add(toolBar, BorderLayout.NORTH); }
From source file:com.opendoorlogistics.studio.scripts.list.ScriptsPanel.java
/** * Create the panel.// w w w .j a v a 2s. c om */ public ScriptsPanel(ODLApi api, File directory, ScriptUIManager launchScriptEditor) { this.scriptUIManager = launchScriptEditor; this.api = api; // find a sensible directory if (directory == null) { directory = new File(ScriptConstants.DIRECTORY); if (!directory.exists()) { directory = new File(""); } } this.directory = directory; setLayout(new BorderLayout(0, 0)); // Add directory browser and label at the top in their own panel. // Label is wrapped in a panel because alignment is being ignored and this at least makes it properly centred. // See http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4275005 boolean lockedDir = scriptUIManager.getAppPermissions().isScriptDirectoryLocked(); if (!lockedDir) { JLabel lblLabel = new JLabel("Scripts directory"); JPanel labelPanel = new JPanel(new BorderLayout()); labelPanel.add(lblLabel, BorderLayout.CENTER); labelPanel.setMaximumSize(lblLabel.getMinimumSize()); dirChooser = new FileBrowserPanel(directory.getAbsolutePath(), new FilenameChangeListener() { @Override public void filenameChanged(String newFilename) { ScriptsPanel.this.directory = new File(newFilename); onDirectoryChanged(ScriptsPanel.this.directory); } }, true, "Select"); JPanel topPanel = LayoutUtils.createVerticalBoxLayout(labelPanel, dirChooser); add(topPanel, BorderLayout.NORTH); } else { dirChooser = null; } // add toolbar at the bottom JToolBar toolBar = new JToolBar(); toolBar.setFloatable(false); add(toolBar, BorderLayout.SOUTH); // create all actions and add as buttons and menu items popup = new JPopupMenu(); actions = createActions(launchScriptEditor.getAppPermissions()); for (Action action : actions) { toolBar.add(action); popup.add(action); } // add list in the centre scriptsTree = new ScriptsTree(scriptUIManager, popup); scriptsTree.addTreeSelectionListener(new TreeSelectionListener() { @Override public void valueChanged(TreeSelectionEvent e) { ScriptsPanel.this.updateAppearance(); } }); add(scriptsTree.getScrollPane(), BorderLayout.CENTER); // // create selection changed listener on the list // listControl.addListSelectionListener(new ListSelectionListener() { // // @Override // public void valueChanged(ListSelectionEvent e) { // updateAppearance(); // } // }); // finally file the list onDirectoryChanged(directory); }
From source file:org.eurocarbdb.application.glycoworkbench.plugin.AnnotationReportApplet.java
private JToolBar createToolBar() { JToolBar toolbar = new JToolBar(); toolbar.setFloatable(false);//from w w w .ja v a 2s . c om toolbar.add(theActionManager.get("print")); toolbar.addSeparator(); toolbar.add(theActionManager.get("undo")); toolbar.add(theActionManager.get("redo")); toolbar.addSeparator(); toolbar.add(theActionManager.get("cut")); toolbar.add(theActionManager.get("copy")); toolbar.add(theActionManager.get("delete")); toolbar.add(theActionManager.get("screenshot")); toolbar.addSeparator(); toolbar.add(theActionManager.get("enlarge")); toolbar.add(theActionManager.get("resetsize")); toolbar.add(theActionManager.get("shrink")); toolbar.addSeparator(); toolbar.add(theActionManager.get("zoomnone")); toolbar.add(theActionManager.get("zoomin")); toolbar.add(theActionManager.get("zoomout")); toolbar.addSeparator(); toolbar.add(theActionManager.get("orientation")); return toolbar; }
From source file:lab4.YouQuiz.java
private void switchToQuizMode() { JToolBar toolbar = new JToolBar(); toolbar.setFloatable(false);//from w ww . j ava 2 s . c o m backButton.setFocusable(false); toolbar.add(backButton); toolbar.setAlignmentX(0); backButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { contentPanel.setQuestion(questionsArray.get(--questionIndex)); forwardButton.setEnabled(true); if (questionIndex - 1 < 0) { backButton.setEnabled(false); } updateAnswerForm(); } }); forwardButton.setFocusable(false); toolbar.add(forwardButton); toolbar.setAlignmentX(0); forwardButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { contentPanel.setQuestion(questionsArray.get(++questionIndex)); backButton.setEnabled(true); if (questionsArray.size() == questionIndex + 1) { forwardButton.setEnabled(false); } updateAnswerForm(); } }); speakButton.setFocusable(false); toolbar.add(speakButton); toolbar.setAlignmentX(0); speakButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { Audio audio = Audio.getInstance(); InputStream sound = null; try { sound = audio.getAudio(questionsArray.get(questionIndex).getQuestion(), Language.ENGLISH); } catch (IOException ex) { Logger.getLogger(YouQuiz.class.getName()).log(Level.SEVERE, null, ex); } try { audio.play(sound); } catch (JavaLayerException ex) { Logger.getLogger(YouQuiz.class.getName()).log(Level.SEVERE, null, ex); } } }); refreshButton.setFocusable(false); toolbar.add(refreshButton); toolbar.setAlignmentX(0); refreshButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { shuffleQuestions(); questionIndex = 0; backButton.setEnabled(false); if (questionsArray.size() == 1) { forwardButton.setEnabled(false); } else { forwardButton.setEnabled(true); } contentPanel.setQuestion(questionsArray.get(questionIndex)); updateAnswerForm(); } }); micButton.setFocusable(false); toolbar.add(micButton); toolbar.setAlignmentX(0); micButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { GSpeechDuplex dup = new GSpeechDuplex(); dup.addResponseListener(new GSpeechResponseListener() { @Override public void onResponse(GoogleResponse gr) { if (questionsArray.get(questionIndex).checkAnswer(gr.getResponse())) { JOptionPane.showMessageDialog(null, "Thats Great, Correct Answer", "Excellent", JOptionPane.INFORMATION_MESSAGE); } else { JOptionPane.showMessageDialog(null, "Oops! '" + gr.getResponse() + "' is a wrong Answer. Its '" + questionsArray.get(questionIndex).getAnswer().get(0) + "'", "Sorry", JOptionPane.ERROR_MESSAGE); } } }); Microphone mic = new Microphone(FLACFileWriter.FLAC); File file = new File("CRAudioTest.flac"); try { mic.captureAudioToFile(file); Thread.sleep(5000); mic.close(); byte[] data = Files.readAllBytes(mic.getAudioFile().toPath()); dup.recognize(data, (int) mic.getAudioFormat().getSampleRate()); mic.getAudioFile().delete(); } catch (LineUnavailableException | InterruptedException | IOException ex) { } } }); contentPanel = new ContentPanel(); contentPanel.add(Box.createRigidArea(new Dimension(0, 10))); contentPanel.add(toolbar, BorderLayout.NORTH); contentPanel.add(Box.createRigidArea(new Dimension(0, 50))); contentPanel.add(contentPanel.questionLabel); add(contentPanel, BorderLayout.CENTER); if (questionsArray.isEmpty()) { refreshButton.setEnabled(false); backButton.setEnabled(false); forwardButton.setEnabled(false); speakButton.setEnabled(false); } else { questionIndex = 0; backButton.setEnabled(false); if (questionsArray.size() == 1) { forwardButton.setEnabled(false); } contentPanel.setQuestion(questionsArray.get(questionIndex)); contentPanel.add(Box.createRigidArea(new Dimension(0, 20))); contentPanel.add(contentPanel.answerPanel); contentPanel.add(Box.createRigidArea(new Dimension(0, 10))); contentPanel.add(contentPanel.checkButton); updateAnswerForm(); } }
From source file:com.employee.scheduler.common.swingui.SolverAndPersistenceFrame.java
private JComponent createToolBar() { JToolBar toolBar = new JToolBar("File operations"); toolBar.setFloatable(false);//from w w w. j av a 2s . c om importAction = new ImportAction(); importAction.setEnabled(solutionBusiness.hasImporter()); toolBar.add(new JButton(importAction)); openAction = new OpenAction(); openAction.setEnabled(true); toolBar.add(new JButton(openAction)); saveAction = new SaveAction(); saveAction.setEnabled(false); toolBar.add(new JButton(saveAction)); exportAction = new ExportAction(); exportAction.setEnabled(false); toolBar.add(new JButton(exportAction)); toolBar.addSeparator(); progressBar = new JProgressBar(0, 100); progressBar.setMaximumSize(new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE)); toolBar.add(progressBar); toolBar.addSeparator(); solveAction = new SolveAction(); solveAction.setEnabled(false); solveButton = new JButton(solveAction); terminateSolvingEarlyAction = new TerminateSolvingEarlyAction(); terminateSolvingEarlyAction.setEnabled(false); terminateSolvingEarlyButton = new JButton(terminateSolvingEarlyAction); terminateSolvingEarlyButton.setVisible(false); toolBar.add(solveButton, "solveAction"); toolBar.add(terminateSolvingEarlyButton, "terminateSolvingEarlyAction"); solveButton.setMinimumSize(terminateSolvingEarlyButton.getMinimumSize()); solveButton.setPreferredSize(terminateSolvingEarlyButton.getPreferredSize()); return toolBar; }
From source file:com.eviware.soapui.impl.wsdl.panels.request.AbstractWsdlRequestDesktopPanel.java
protected JComponent buildToolbar() { endpointCombo = new JComboBox(endpointsModel); endpointCombo.setToolTipText(endpointsModel.getSelectedItem().toString()); endpointCombo.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { Object item = endpointCombo.getSelectedItem(); if (item == null) { endpointCombo.setToolTipText("- no endpoint set for request -"); } else { String selectedItem = item.toString(); endpointCombo.setToolTipText(selectedItem); }/* w w w. j ava2 s . c o m*/ submitButton.setEnabled(submit == null && request.getEndpoint() != null && request.getEndpoint().trim().length() > 0); } }); JToolBar toolbar = UISupport.createToolbar(); toolbar.add(submitButton); insertButtons(toolbar); toolbar.add(recreateButton); toolbar.add(createEmptyButton); toolbar.add(cloneButton); toolbar.add(cancelButton); toolbar.addSeparator(); toolbar.add(endpointCombo); toolbar.add(Box.createHorizontalGlue()); toolbar.add(tabsButton); toolbar.add(splitButton); toolbar.add(UISupport.createToolbarButton(new ShowOnlineHelpAction(getHelpUrl()))); return toolbar; }
From source file:daylightchart.gui.DaylightChartGui.java
private void createHelpMenu(final JMenuBar menuBar, final JToolBar toolBar) { final GuiAction onlineHelp = new OnlineHelpAction(); final GuiAction about = new AboutAction(DaylightChartGui.this); final JMenu menuHelp = new JMenu(Messages.getString("DaylightChartGui.Menu.Help")); //$NON-NLS-1$ menuHelp.setMnemonic('H'); menuHelp.add(onlineHelp);/*from w w w.ja va 2s . c o m*/ menuHelp.add(about); menuBar.add(menuHelp); toolBar.addSeparator(); toolBar.add(onlineHelp); }