List of usage examples for javax.swing JToolBar add
public JButton add(Action a)
JButton
which dispatches the action. From source file:edu.ucla.stat.SOCR.chart.SuperPowerChart.java
protected void createActionComponents(JToolBar toolBar) { JButton button = null;/*from w w w . j a v a 2 s . c o m*/ toolBar.setFloatable(false); /**************** Demo Tab****************/ if (useStaticExample) { exampleStaticAction = new AbstractAction() { public void actionPerformed(ActionEvent e) { // Create First Example reset(); resetTable(); resetMappingList(); resetExample(); if (tabbedPanelContainer.getTitleAt(tabbedPanelContainer.getSelectedIndex()) == ALL) setMixPanel(); updateStatus(url); validate(); } }; button = toolBar.add(exampleStaticAction); button.setText(EXAMPLE); button.setToolTipText(chartDescription); } /**************** DO-CHART Tab ****************/ computeAction = new AbstractAction() { public void actionPerformed(ActionEvent e) { doChart(); } }; button = toolBar.add(computeAction); button.setText(DOCHART); button.setToolTipText("Press this Button to Generate the Chart"); /**************** CLEAR Tab****************/ clearAction = new AbstractAction() { public void actionPerformed(ActionEvent e) { /* somehow reset has to be called more than once to set to the correct header. I'll leave it like this before I figure out why. annie che 20051123 -_- */ reset(); // Need to work out what this means // reset(); resetTable(); resetMappingList(); resetChart(); ChartExampleData exampleNull = new ChartExampleData(0, 0); /* A Null Example (with no data) is used here to reset the table so that when "CLEAR" button is pressed, the cells of dataTable is NOT null. annieche 20060110. */ updateExample(exampleNull); if (tabbedPanelContainer.getTitleAt(tabbedPanelContainer.getSelectedIndex()) == ALL) setMixPanel(); updateStatus("The Chart has been reset!"); //updateExample(exampleNull); } }; button = toolBar.add(clearAction); button.setText(CLEAR); button.setToolTipText("Clears All Windows"); /**************** wiki Tab ****************/ Action linkAction = new AbstractAction() { public void actionPerformed(ActionEvent e) { try { //popInfo("SOCRChart: About", new java.net.URL("http://wiki.stat.ucla.edu/socr/index.php/SOCR_EduMaterials_Activities_PowerTransformFamily_Graphs"), "SOCR: Power Transform Graphing Activity"); parentApplet.getAppletContext().showDocument(new java.net.URL( "http://wiki.stat.ucla.edu/socr/index.php/SOCR_EduMaterials_Activities_PowerTransformFamily_Graphs"), "SOCR: Power Transform Graphing Activity"); } catch (MalformedURLException Exc) { JOptionPane.showMessageDialog(null, Exc, "MalformedURL Error", JOptionPane.ERROR_MESSAGE); Exc.printStackTrace(); } } }; button = toolBar.add(linkAction); //button.setMinimumSize(new Dimension(110, 20)); button.setText(" WIKI_Activity "); button.setToolTipText("Press this Button to go to SOCR_POWER_Activity wiki page"); /**************** TEST Tab ****************/ testAction = new AbstractAction() { public void actionPerformed(ActionEvent e) { doTest(); } }; if (TEST_API) { button = toolBar.add(testAction); button.setText(TEST); button.setToolTipText("Press this Button to test the API"); } }
From source file:daylightchart.gui.DaylightChartGui.java
private void createFileMenu(final JMenuBar menuBar, final JToolBar toolBar) { final GuiAction openLocationsFile = new OpenLocationsFileAction(this); final GuiAction saveLocationsFile = new SaveLocationsFileAction(this); final GuiAction saveChart = new SaveChartAction(this); final GuiAction printChart = new PrintChartAction(locationsTabbedPane); final ExitAction exit = new ExitAction(this, Messages.getString("DaylightChartGui.Menu.File.Exit")); //$NON-NLS-1$ final JMenu menu = new JMenu(Messages.getString("DaylightChartGui.Menu.File")); //$NON-NLS-1$ menu.setMnemonic('F'); recentLocationsMenu = new JMenu(Messages.getString("DaylightChartGui.Menu.File.RecentLocations")); //$NON-NLS-1$ menu.setMnemonic('R'); menu.add(openLocationsFile);//from w w w .j av a 2 s .c om menu.add(saveLocationsFile); menu.addSeparator(); menu.add(saveChart); if (!isSlimUi()) { menu.add(printChart); } menu.addSeparator(); menu.add(recentLocationsMenu); menu.addSeparator(); menu.add(exit); menuBar.add(menu); toolBar.add(openLocationsFile); toolBar.add(saveLocationsFile); toolBar.addSeparator(); toolBar.add(saveChart); toolBar.add(printChart); toolBar.addSeparator(); }
From source file:edu.ucla.stat.SOCR.chart.demo.PowerTransformationFamilyChart.java
protected void createActionComponents(JToolBar toolBar) { super.createActionComponents(toolBar); JButton button;/* www . j a v a 2 s .c om*/ /**************** wiki Tab ****************/ Action linkAction = new AbstractAction() { public void actionPerformed(ActionEvent e) { try { //popInfo("SOCRChart: About", new java.net.URL("http://wiki.stat.ucla.edu/socr/index.php/SOCR_EduMaterials_Activities_PowerTransformFamily_Graphs"), "SOCR: Power Transform Graphing Activity"); parentApplet.getAppletContext().showDocument(new java.net.URL( "http://wiki.stat.ucla.edu/socr/index.php/SOCR_EduMaterials_Activities_PowerTransformFamily_Graphs"), "SOCR: Power Transform Graphing Activity"); } catch (MalformedURLException Exc) { JOptionPane.showMessageDialog(null, Exc, "MalformedURL Error", JOptionPane.ERROR_MESSAGE); Exc.printStackTrace(); } } }; button = toolBar.add(linkAction); button.setText(" WIKI_Activity "); button.setToolTipText("Press this Button to go to SOCR_POWER_Activity wiki page"); }
From source file:com.mgmtp.perfload.loadprofiles.ui.AppFrame.java
private void initToolBar(final JToolBar toolBar) { toolBar.add(fileNewLoadProfileConfigAction); toolBar.add(fileOpenLoadProfileConfigAction); toolBar.add(fileSaveLoadProfileConfigAction); toolBar.addSeparator();/*from ww w .j a v a 2 s . c o m*/ toolBar.add(toolsAddStairsAction); toolBar.add(toolsAddOneTimeAction); toolBar.add(toolsAddMarkerAction); toolBar.add(toolsDeleteLoadProfileEntityAction); toolBar.addSeparator(); toolBar.add(toolsExportEventListAction); toolBar.addSeparator(); toolBar.add(toolsSettingsAction); toolBar.addSeparator(); toolBar.add(helpAboutAction); }
From source file:ch.fork.AdHocRailway.ui.AdHocRailway.java
private void initToolbar() { /* FILE *///w w w . j a v a 2 s .co m final JToolBar fileToolBar = new JToolBar(); final JButton newFileToolBarButton = new SmallToolbarButton(new NewFileAction()); final JButton openFileToolBarButton = new SmallToolbarButton(new OpenFileAction()); final JButton openDatabaseToolBarButton = new SmallToolbarButton(new OpenDatabaseAction()); final JButton saveToolBarButton = new SmallToolbarButton(new SaveAction()); final JButton exitToolBarButton = new SmallToolbarButton(new ExitAction()); fileToolBar.add(newFileToolBarButton); fileToolBar.add(openFileToolBarButton); fileToolBar.add(openDatabaseToolBarButton); fileToolBar.add(saveToolBarButton); fileToolBar.add(exitToolBarButton); /* DIGITAL */ final JToolBar digitalToolBar = new JToolBar(); turnoutsToolBarButton = new SmallToolbarButton(new TurnoutAction()); routesToolBarButton = new SmallToolbarButton(new RoutesAction()); locomotivesToolBarButton = new SmallToolbarButton(new LocomotivesAction()); preferencesToolBarButton = new SmallToolbarButton(new PreferencesAction()); digitalToolBar.add(turnoutsToolBarButton); digitalToolBar.add(routesToolBarButton); digitalToolBar.add(locomotivesToolBarButton); digitalToolBar.add(preferencesToolBarButton); /* SRCP / AdHoc-Brain */ final JToolBar daemonToolBar = new JToolBar(); railwayDeviceLabelLabel = new JLabel(); setRailwayDeviceLabelText(); connectToolBarButton = new SmallToolbarButton(new ConnectAction()); disconnectToolBarButton = new SmallToolbarButton(new DisconnectAction()); disconnectToolBarButton.setEnabled(false); daemonToolBar.add(railwayDeviceLabelLabel); daemonToolBar.addSeparator(); daemonToolBar.add(connectToolBarButton); daemonToolBar.add(disconnectToolBarButton); /* VIEWS */ final JToolBar viewToolBar = new JToolBar(); final JButton refreshButton = new SmallToolbarButton(new RefreshAction()); toggleFullscreenButton = new SmallToolbarButton(new ToggleFullscreenAction()); viewToolBar.add(refreshButton); viewToolBar.add(toggleFullscreenButton); /* ERROR */ final ErrorPanel errorPanel = new ErrorPanel(); ExceptionProcessor.getInstance(errorPanel); toolbarPanel = new JPanel(new FlowLayout(FlowLayout.LEADING, 0, 0)); addToolBar(fileToolBar); addToolBar(digitalToolBar); addToolBar(daemonToolBar); addToolBar(viewToolBar); final JPanel toolbarErrorPanel = new JPanel(new BorderLayout(10, 10)); toolbarErrorPanel.add(toolbarPanel, BorderLayout.WEST); toolbarErrorPanel.add(errorPanel, BorderLayout.EAST); add(toolbarErrorPanel, BorderLayout.PAGE_START); }
From source file:daylightchart.gui.DaylightChartGui.java
private void createOptionsMenu(final JMenuBar menuBar, final JToolBar toolBar) { final JMenu menu = new JMenu(Messages.getString("DaylightChartGui.Menu.Options")); //$NON-NLS-1$ menu.setMnemonic('O'); final GuiAction options = new OptionsAction(this); menu.add(options);/*from w w w . j ava 2 s. co m*/ final GuiAction chartOptions = new ChartOptionsAction(this); menu.add(chartOptions); final GuiAction resetAll = new ResetAllAction(this); menu.add(resetAll); menu.addSeparator(); final JCheckBoxMenuItem slimUiMenuItem = new JCheckBoxMenuItem( Messages.getString("DaylightChartGui.Menu.Options.SlimUi")); //$NON-NLS-1$ slimUiMenuItem.setState(isSlimUi()); slimUiMenuItem.addItemListener(new ItemListener() { @Override public void itemStateChanged(final ItemEvent e) { final boolean slimUi = e.getStateChange() == ItemEvent.SELECTED; final Options options = UserPreferences.optionsFile().getData(); options.setSlimUi(slimUi); UserPreferences.optionsFile().save(options); ResetAllAction.restart(DaylightChartGui.this, slimUi); } }); menu.add(slimUiMenuItem); menuBar.add(menu); toolBar.add(options); toolBar.add(chartOptions); toolBar.addSeparator(); }
From source file:net.schweerelos.parrot.CombinedParrotApp.java
private void initGUI(Properties properties) { try {/*from w w w . j a v a 2 s. c o m*/ this.setTitle(APP_TITLE); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { for (MainViewComponent mainViewComponent : mainViews) { if (mainViewComponent instanceof ParrotStateListener) { ((ParrotStateListener) mainViewComponent).parrotExiting(); } } } }); setSize(920, 690); getContentPane().setLayout(new BorderLayout()); UserInterfaceManager uiManager = new UserInterfaceManager(properties); navigators = new ArrayList<NavigatorComponent>(4); // main view listView = uiManager.createMainViewComponent(Style.TABLE); graphView = uiManager.createMainViewComponent(Style.GRAPH); mainViews.add(listView); mainViews.add(graphView); final JTabbedPane mainPanel = new JTabbedPane(); mainPanel.add(graphView.getTitle(), graphView.asJComponent()); mainPanel.add(listView.getTitle(), listView.asJComponent()); mainPanel.setSelectedIndex(0); activeMainView = graphView; mainPanel.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { if (e.getSource() != mainPanel) { return; } int selectedIndex = mainPanel.getSelectedIndex(); if (selectedIndex == 0) { activeMainView = graphView; } else if (selectedIndex == 1) { activeMainView = listView; } else { Logger logger = Logger.getLogger(CombinedParrotApp.class); logger.warn("unknown tab index selected: " + selectedIndex); } } }); add(mainPanel, BorderLayout.CENTER); // navigators JToolBar navigatorsBar = new JToolBar(JToolBar.HORIZONTAL); navigatorsBar.setMargin(new Insets(0, 11, 0, 0)); navigatorsBar.setFloatable(false); getContentPane().add(navigatorsBar, BorderLayout.PAGE_START); // timeline NavigatorComponent timelineNavigator = uiManager.createTimelineNavigationComponent(); navigators.add(timelineNavigator); JFrame timelineFrame = new JFrame(timelineNavigator.getNavigatorName() + " " + APP_TITLE); timelineFrame.getContentPane().add(timelineNavigator.asJComponent()); timelineFrame.pack(); Point preferredLocation = new Point(0, 0); preferredFrameLocations.put(timelineFrame, preferredLocation); if (timelineNavigator.hasShowHideListener()) { timelineFrame.addComponentListener(timelineNavigator.getShowHideListener()); } timelineFrame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); JToggleButton timelineButton = setupNavigatorButton(timelineNavigator.getNavigatorName(), timelineNavigator.getAcceleratorKey(), timelineNavigator); navigatorsBar.add(timelineButton); // map NavigatorComponent mapNavigator = uiManager.createMapNavigationComponent(); navigators.add(mapNavigator); JFrame mapFrame = new JFrame(mapNavigator.getNavigatorName() + " " + APP_TITLE); mapFrame.getContentPane().add(mapNavigator.asJComponent()); mapFrame.pack(); preferredLocation = new Point(0, Toolkit.getDefaultToolkit().getScreenSize().height - mapFrame.getHeight()); preferredFrameLocations.put(mapFrame, preferredLocation); if (mapNavigator.hasShowHideListener()) { mapFrame.addComponentListener(mapNavigator.getShowHideListener()); } mapFrame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); JToggleButton mapButton = setupNavigatorButton(mapNavigator.getNavigatorName(), mapNavigator.getAcceleratorKey(), mapNavigator); navigatorsBar.add(mapButton); // search NavigatorComponent searchNavigator = uiManager.createSearchComponent(); navigators.add(searchNavigator); JFrame searchFrame = new JFrame(searchNavigator.getNavigatorName() + " " + APP_TITLE); searchFrame.getContentPane().add(searchNavigator.asJComponent()); searchFrame.pack(); preferredLocation = new Point( Toolkit.getDefaultToolkit().getScreenSize().width - searchFrame.getWidth(), 0); preferredFrameLocations.put(searchFrame, preferredLocation); if (searchNavigator.hasShowHideListener()) { searchFrame.addComponentListener(searchNavigator.getShowHideListener()); } searchFrame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); JToggleButton searchButton = setupNavigatorButton(searchNavigator.getNavigatorName(), searchNavigator.getAcceleratorKey(), searchNavigator); navigatorsBar.add(searchButton); // connections NavigatorComponent chainNavigator = uiManager.createChainNavigationComponent(); navigators.add(chainNavigator); if (chainNavigator instanceof PickListener) { for (MainViewComponent mainViewComponent : mainViews) { mainViewComponent.addPickListener((PickListener) chainNavigator); } } if (chainNavigator.hasShowHideListener()) { chainNavigator.asJComponent().addComponentListener(chainNavigator.getShowHideListener()); } JToggleButton connectionsButton = setupNavigatorButton(chainNavigator.getNavigatorName(), chainNavigator.getAcceleratorKey(), chainNavigator); navigatorsBar.add(connectionsButton); add(chainNavigator.asJComponent(), BorderLayout.PAGE_END); chainNavigator.asJComponent().setVisible(false); } catch (RuntimeException e) { e.printStackTrace(System.err); System.exit(1); } catch (UnknownStyleException e) { e.printStackTrace(System.err); System.exit(1); } }
From source file:net.sf.jabref.EntryEditor.java
/** * Create toolbar for entry editor.//from ww w . j a v a 2s. co m */ private void setupToolBar() { JToolBar tlb = new JToolBar(JToolBar.VERTICAL); CloseAction closeAction = new CloseAction(); ; StoreFieldAction storeFieldAction = new StoreFieldAction(); DeleteAction deleteAction = new DeleteAction(); UndoAction undoAction = new UndoAction(); RedoAction redoAction = new RedoAction(); tlb.setBorder(null); tlb.setRollover(true); tlb.setMargin(new Insets(0, 0, 0, 2)); tlb.setFloatable(false); tlb.addSeparator(); tlb.add(deleteAction); tlb.addSeparator(); tlb.add(prevEntryAction); tlb.add(nextEntryAction); tlb.addSeparator(); tlb.add(helpAction); for (Component comp : tlb.getComponents()) { ((JComponent) comp).setOpaque(false); } // The toolbar carries all the key bindings that are valid for the whole window. ActionMap am = tlb.getActionMap(); InputMap im = tlb.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); im.put(prefs.getKey("Close entry editor"), "close"); am.put("close", closeAction); im.put(prefs.getKey("Entry editor, store field"), "store"); am.put("store", storeFieldAction); im.put(prefs.getKey("Entry editor, previous entry"), "prev"); am.put("prev", prevEntryAction); im.put(prefs.getKey("Entry editor, next entry"), "next"); am.put("next", nextEntryAction); im.put(prefs.getKey("Undo"), "undo"); am.put("undo", undoAction); im.put(prefs.getKey("Redo"), "redo"); am.put("redo", redoAction); im.put(prefs.getKey("Help"), "help"); am.put("help", helpAction); // Add actions (and thus buttons) JButton closeBut = new JButton(closeAction); closeBut.setText(null); closeBut.setBorder(null); // Create type-label TypeLabel typeLabel = new TypeLabel(entry.getType().getName()); JPanel leftPan = new JPanel(); leftPan.setLayout(new BorderLayout()); leftPan.add(closeBut, BorderLayout.NORTH); leftPan.add(typeLabel, BorderLayout.CENTER); leftPan.add(tlb, BorderLayout.SOUTH); add(leftPan, BorderLayout.WEST); }
From source file:com.mightypocket.ashot.Mediator.java
private JToolBar createToolBar() { ApplicationActionMap actionMap = getActionMap(); JToolBar bar = new JToolBar(); bar.setRollover(true);//from ww w . ja va 2 s . c o m toolBarMap.clear(); final boolean hideText = !p.getBoolean(PREF_GUI_SHOW_TEXT_IN_TOOLBAR, true); for (String actionName : TOOLBAR) { if (TOOLBAR_SEPARATOR.equals(actionName)) { bar.addSeparator(); } else { AbstractButton bt; if (actionName.startsWith(TOOLBAR_TOGGLE_BUTTON)) { actionName = StringUtils.substring(actionName, TOOLBAR_TOGGLE_BUTTON.length()); bt = new JToggleButton(actionMap.get(actionName)); } else { bt = new JButton(actionMap.get(actionName)); } bt.setFocusable(false); bt.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); bt.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); bt.setHideActionText(hideText); bar.add(bt); toolBarMap.put(actionName, bt); } } return bar; }
From source file:com.nbt.TreeFrame.java
protected JToolBar createToolBar() { JToolBar toolBar = new JToolBar(); toolBar.setFloatable(false);/*from w w w . j a va 2s. c o m*/ Action[] actions = { /* newAction, */browseAction, saveAction, /* saveAsAction, */refreshAction, null, deleteAction, null, openAction, null, addByteAction, addShortAction, addIntAction, addLongAction, addFloatAction, addDoubleAction, addByteArrayAction, addStringAction, addListAction, addCompoundAction }; for (Action action : actions) { if (action == null) { toolBar.addSeparator(); } else { ToolBarButton button = new ToolBarButton(action); toolBar.add(button); } } return toolBar; }