Java Code Examples for javax.swing.JToggleButton#setActionCommand()
The following examples show how to use
javax.swing.JToggleButton#setActionCommand() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WebORTable.java From Cognizant-Intelligent-Test-Scripter with Apache License 2.0 | 6 votes |
private void init() { setLayout(new javax.swing.BoxLayout(this, javax.swing.BoxLayout.X_AXIS)); setFloatable(false); add(new javax.swing.Box.Filler(new java.awt.Dimension(10, 0), new java.awt.Dimension(10, 0), new java.awt.Dimension(10, 32767))); JLabel label = new JLabel("Properties"); label.setFont(new Font("Default", Font.BOLD, 12)); add(label); add(new javax.swing.Box.Filler(new java.awt.Dimension(0, 0), new java.awt.Dimension(0, 0), new java.awt.Dimension(32767, 32767))); add(Utils.createButton("Add Row", "add", "Ctrl+Plus", WebORTable.this)); add(Utils.createButton("Delete Rows", "remove", "Ctrl+Minus", WebORTable.this)); addSeparator(); add(Utils.createButton("Move Rows Up", "up", "Ctrl+Up", WebORTable.this)); add(Utils.createButton("Move Rows Down", "down", "Ctrl+Down", WebORTable.this)); addSeparator(); frameToggle = new JToggleButton(Utils.getIconByResourceName("/ui/resources/or/web/propViewer")); frameToggle.addItemListener(WebORTable.this); frameToggle.setToolTipText("Show/Hide Frame Property"); frameToggle.setActionCommand("Toggle Frame"); add(frameToggle); }
Example 2
Source File: ObjectRepo.java From Cognizant-Intelligent-Test-Scripter with Apache License 2.0 | 5 votes |
private JToggleButton create(String text) { JToggleButton togg = new JToggleButton(); togg.setIcon(Utils.getIconByResourceName("/ui/resources/or/" + text.toLowerCase())); togg.setToolTipText(text); togg.setActionCommand(text); togg.addItemListener(ObjectRepo.this); bgroup.add(togg); return togg; }
Example 3
Source File: ImageORTable.java From Cognizant-Intelligent-Test-Scripter with Apache License 2.0 | 5 votes |
private void init() { add(new javax.swing.Box.Filler(new java.awt.Dimension(10, 0), new java.awt.Dimension(10, 0), new java.awt.Dimension(10, 32767))); JLabel label = new JLabel("Properties"); label.setFont(new Font("Default", Font.BOLD, 12)); add(label); add(new javax.swing.Box.Filler(new java.awt.Dimension(0, 0), new java.awt.Dimension(0, 0), new java.awt.Dimension(32767, 32767))); toggleImage = new JToggleButton(Utils.getIconByResourceName("/ui/resources/or/image/image")); toggleImage.addItemListener(ImageORTable.this); toggleImage.setActionCommand("ToggleImage"); toggleImage.setToolTipText("Show/Hide Image"); add(toggleImage); JButton offset = new JButton(Utils.getIconByResourceName("/ui/resources/or/image/findOffset")); offset.addActionListener(ImageORTable.this); offset.setToolTipText("Show Offset"); offset.setActionCommand("Show Offset"); add(offset); JButton findOn = new JButton(Utils.getIconByResourceName("/ui/resources/or/image/findOnScreen")); findOn.addActionListener(ImageORTable.this); findOn.setToolTipText("Find on Screen"); findOn.setActionCommand("Find on Screen"); add(findOn); JButton editor = new JButton(Utils.getIconByResourceName("/ui/resources/or/image/propViewer")); editor.addActionListener(ImageORTable.this); editor.setToolTipText("Show Property Editor"); editor.setActionCommand("Show Property Editor"); add(editor); }
Example 4
Source File: TestSetToolBar.java From Cognizant-Intelligent-Test-Scripter with Apache License 2.0 | 5 votes |
private JToggleButton createToggleButton() { JToggleButton console = new JToggleButton(Utils.getIconByResourceName("/ui/resources/toolbar/console")); console.setActionCommand("Console"); console.setToolTipText("Show/Hide Console Box"); console.addActionListener(actionListener); return console; }
Example 5
Source File: TabSelector.java From magarena with GNU General Public License v3.0 | 5 votes |
public void addTab(MagicPlayerZone zone, int player) { final JToggleButton button = new JToggleButton(); button.setToolTipText(null); button.setBackground(this.backgroundColor); button.setFocusable(false); button.setPreferredSize(buttonDimension); button.setActionCommand(zone.name() + DELIM + player + DELIM + buttons.size()); button.addActionListener(this); buttons.add(button); buttonPanel.add(button); if (buttons.size() == 1) { showTab(button); } }
Example 6
Source File: DivergingColorPalettePanel.java From colorbrewer with GNU Lesser General Public License v2.1 | 5 votes |
protected JToggleButton createPalette(ColorBrewer brewer, Border normalBorder) { JToggleButton palette = new JToggleButton(); palette.setActionCommand(brewer.name()); palette.addActionListener(this); Icon icon = new PaletteIcon(brewer, 5, 15, 15); palette.setIcon(icon); palette.setToolTipText(brewer.getPaletteDescription()); palette.setBorder(normalBorder); return palette; }
Example 7
Source File: QualitativeColorPalettePanel.java From colorbrewer with GNU Lesser General Public License v2.1 | 5 votes |
protected JToggleButton createPalette(ColorBrewer brewer, Border normalBorder) { JToggleButton palette = new JToggleButton(); palette.setActionCommand(brewer.name()); palette.addActionListener(this); Icon icon = new PaletteIcon(brewer, 5, 15, 15); palette.setIcon(icon); palette.setToolTipText(brewer.getPaletteDescription()); palette.setBorder(normalBorder); return palette; }
Example 8
Source File: Compass.java From jclic with GNU General Public License v2.0 | 5 votes |
/** Creates new Compass */ public Compass() { super(new java.awt.GridLayout(3, 3)); setOpaque(false); direction = -1; ActionListener lst = new ActionListener() { public void actionPerformed(ActionEvent ev) { String c = ev.getActionCommand(); for (int i = 0; i < 9; i++) { if (BT_NAMES[i].equals(c)) { setDirection(i); break; } } } }; ButtonGroup bg = new ButtonGroup(); buttons = new JToggleButton[9]; for (int i = 0; i < 9; i++) { JToggleButton btn = new JToggleButton( new ImageIcon(getClass().getResource("/edu/xtec/resources/icons/" + BT_NAMES[i] + ".gif"))); btn.setPreferredSize(BT_DIMENSION); bg.add(btn); btn.setActionCommand(BT_NAMES[i]); btn.addActionListener(lst); btn.setFocusPainted(false); add(btn); buttons[i] = btn; } }
Example 9
Source File: CssStylesPanel.java From netbeans with Apache License 2.0 | 4 votes |
private void updateToolbar(FileObject file, Collection<CssStylesPanelProvider> activeProviders) { toolBar.removeAll(); if (activeProviders.size() <= 1) { //remove the whole toolbar, if there's one or zero providers removeToolbar(); } else { addToolbar(); } // Button group for document and source buttons ButtonGroup buttonGroup = new ButtonGroup(); boolean first = true; CssStylesPanelProvider selected = (file == null) ? null : selectedTabs.get(file.getMIMEType()); //do the active providers contain the pre-selected provider for this mimetype? boolean containsPreselected = selected == null ? false : activeProviders.contains(selected); for (CssStylesPanelProvider provider : activeProviders) { JToggleButton button = new JToggleButton(); button.setText(provider.getPanelDisplayName()); button.setActionCommand(provider.getPanelID()); button.addActionListener(toolbarListener); button.setFocusable(true); button.setFocusPainted(false); button.setRolloverEnabled(true); //copied from org.netbeans.core.multiview.TabsComponent.createButton to make the look //similar to the editor tabs Border b = (getButtonBorder()); if (b != null) { button.setBorder(b); } if (AQUA) { button.putClientProperty("JButton.buttonType", "square"); //NOI18N button.putClientProperty("JComponent.sizeVariant", "small"); //NOI18N } buttonGroup.add(button); toolBar.add(button); if (containsPreselected) { //one of the active providers is already pre-selected by user if (provider == selected) { //the selected one - activate it button.setSelected(true); setActiveProvider(provider); } else { button.setSelected(false); } } else { //no provider has been explicitly selected by the user yet button.setSelected(first); if (first) { setActiveProvider(provider); first = false; } } } revalidate(); repaint(); }
Example 10
Source File: EditorRootPane.java From libGDX-Path-Editor with Apache License 2.0 | 4 votes |
private JToolBar createToolbar() { JToolBar toolBar = new JToolBar(JToolBar.HORIZONTAL); toolBar.setFloatable(false); ImageIcon newProjectIcon = new ImageIcon(this.getClass().getResource(ResourcesConsts.ic_toolbar_newProject)); newProjectButton = new JButton(newProjectIcon); newProjectButton.setActionCommand(MenuConsts.newProject); newProjectButton.setToolTipText(MenuConsts.newProject); newProjectButton.addActionListener(menuHandler); ImageIcon openProjectIcon = new ImageIcon(this.getClass().getResource(ResourcesConsts.ic_toolbar_openProject)); openProjectButton = new JButton(openProjectIcon); openProjectButton.setActionCommand(MenuConsts.openProject); openProjectButton.setToolTipText(MenuConsts.openProject); openProjectButton.addActionListener(menuHandler); ImageIcon saveProjectIcon = new ImageIcon(this.getClass().getResource(ResourcesConsts.ic_toolbar_saveProject)); saveProjectButton = new JButton(saveProjectIcon); saveProjectButton.setActionCommand(MenuConsts.saveProhect); saveProjectButton.setToolTipText(MenuConsts.saveProhect); saveProjectButton.addActionListener(menuHandler); ImageIcon closeProjectIcon = new ImageIcon(this.getClass().getResource(ResourcesConsts.ic_toolbar_closeProject)); closeProjectButton = new JButton(closeProjectIcon); closeProjectButton.setActionCommand(MenuConsts.closeProject); closeProjectButton.setToolTipText(MenuConsts.closeProject); closeProjectButton.addActionListener(menuHandler); ImageIcon addScreenIcon = new ImageIcon(this.getClass().getResource(ResourcesConsts.ic_toolbar_addScreen)); addScreenButton = new JButton(addScreenIcon); addScreenButton.setActionCommand(MenuConsts.addScreen); addScreenButton.setToolTipText(MenuConsts.addScreen); addScreenButton.addActionListener(menuHandler); ImageIcon addBGIcon = new ImageIcon(this.getClass().getResource(ResourcesConsts.ic_toolbar_addBG)); addBGButton = new JButton(addBGIcon); addBGButton.setActionCommand(MenuConsts.addBG); addBGButton.setToolTipText(MenuConsts.addBG); addBGButton.addActionListener(menuHandler); ImageIcon addVertexIcon = new ImageIcon(this.getClass().getResource(ResourcesConsts.ic_toolbar_addVertex)); addVertexButton = new JToggleButton(addVertexIcon); addVertexButton.setActionCommand(MenuConsts.addVertex); addVertexButton.setToolTipText(MenuConsts.addVertex); addVertexButton.addActionListener(menuHandler); ImageIcon editVertexIcon = new ImageIcon(this.getClass().getResource(ResourcesConsts.ic_toolbar_editVertex)); editVertexButton = new JToggleButton(editVertexIcon); editVertexButton.setActionCommand(MenuConsts.moveVertex); editVertexButton.setToolTipText(MenuConsts.moveVertex); editVertexButton.addActionListener(menuHandler); ImageIcon insertVertexIcon = new ImageIcon(this.getClass().getResource(ResourcesConsts.ic_toolbar_insertVertex)); insertVertexButton = new JToggleButton(insertVertexIcon); insertVertexButton.setActionCommand(MenuConsts.insertVertex); insertVertexButton.setToolTipText(MenuConsts.insertVertex); insertVertexButton.addActionListener(menuHandler); ImageIcon removeVertexIcon = new ImageIcon(this.getClass().getResource(ResourcesConsts.ic_toolbar_removeVertex)); removeVertexButton = new JToggleButton(removeVertexIcon); removeVertexButton.setActionCommand(MenuConsts.removeVertex); removeVertexButton.setToolTipText(MenuConsts.removeVertex); removeVertexButton.addActionListener(menuHandler); ImageIcon clearPathIcon = new ImageIcon(this.getClass().getResource(ResourcesConsts.ic_toolbar_clearPath)); clearPathButton = new JButton(clearPathIcon); clearPathButton.setActionCommand(MenuConsts.clearPath); clearPathButton.setToolTipText(MenuConsts.clearPath); clearPathButton.addActionListener(menuHandler); toolBar.add(newProjectButton); toolBar.add(openProjectButton); toolBar.add(saveProjectButton); toolBar.add(closeProjectButton); toolBar.addSeparator(new Dimension(10, 32)); toolBar.add(addScreenButton); toolBar.addSeparator(new Dimension(10, 32)); toolBar.add(addBGButton); toolBar.addSeparator(new Dimension(10, 32)); toolBar.add(addVertexButton); toolBar.add(editVertexButton); toolBar.add(insertVertexButton); toolBar.add(removeVertexButton); toolBar.add(clearPathButton); return toolBar; }