Java Code Examples for javax.swing.JToggleButton#setFocusable()
The following examples show how to use
javax.swing.JToggleButton#setFocusable() .
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: DrawingViewPlacardPanel.java From openAGV with Apache License 2.0 | 6 votes |
/** * Creates a button to toggle the grid in the drawing. * * @param view The DrawingView the button will belong to. * @return The created button. */ private JToggleButton toggleConstrainerButton(final OpenTCSDrawingView drawingView) { final JToggleButton toggleButton = new JToggleButton(); toggleButton.setToolTipText( labels.getString("drawingViewPlacardPanel.button_toggleGrid.tooltipText") ); toggleButton.setIcon(ImageDirectory.getImageIcon("/menu/view-split.png")); toggleButton.setMargin(new Insets(0, 0, 0, 0)); toggleButton.setFocusable(false); toggleButton.addItemListener( (ItemEvent event) -> drawingView.setConstrainerVisible(toggleButton.isSelected()) ); return toggleButton; }
Example 2
Source File: DrawingViewPlacardPanel.java From openAGV with Apache License 2.0 | 6 votes |
/** * Creates a button to toglle the labels. * * @param view The DrawingView the button will belong to. * @return The created button. */ private JToggleButton toggleLabelsButton(final OpenTCSDrawingView drawingView) { final JToggleButton toggleButton = new JToggleButton(); toggleButton.setToolTipText( labels.getString("drawingViewPlacardPanel.button_toggleLabels.tooltipText") ); toggleButton.setIcon(ImageDirectory.getImageIcon("/menu/comment-add.16.png")); toggleButton.setMargin(new Insets(0, 0, 0, 0)); toggleButton.setFocusable(false); toggleButton.addItemListener( (ItemEvent event) -> drawingView.setLabelsVisible(toggleButton.isSelected()) ); return toggleButton; }
Example 3
Source File: DrawingViewPlacardPanel.java From openAGV with Apache License 2.0 | 6 votes |
/** * Creates a button to toggle the blocks in the drawing. * * @param view The DrawingView the button will belong to. * @return The created button. */ private JToggleButton toggleBlocksButton(final OpenTCSDrawingView drawingView) { final JToggleButton toggleButton = new JToggleButton(); toggleButton.setToolTipText( labels.getString("drawingViewPlacardPanel.button_toggleBlocks.tooltipText") ); toggleButton.setIcon(ImageDirectory.getImageIcon("/tree/block.18x18.png")); toggleButton.setMargin(new Insets(0, 0, 0, 0)); toggleButton.setFocusable(false); toggleButton.addItemListener( (ItemEvent event) -> drawingView.setBlocksVisible(toggleButton.isSelected()) ); return toggleButton; }
Example 4
Source File: VariablesViewButtons.java From netbeans with Apache License 2.0 | 6 votes |
private static JToggleButton createToggleButton (final String id, String iconPath, String tooltip) { Icon icon = ImageUtilities.loadImageIcon(iconPath, false); boolean isSelected = isButtonSelected(id); final JToggleButton toggleButton = new JToggleButton(icon, isSelected); // ensure small size, just for the icon Dimension size = new Dimension(icon.getIconWidth() + 8, icon.getIconHeight() + 8); toggleButton.setPreferredSize(size); toggleButton.setMargin(new Insets(1, 1, 1, 1)); if (!"Aqua".equals(UIManager.getLookAndFeel().getID())) { //NOI18N // We do not want an ugly border with the exception of Mac, where it paints the toggle state! toggleButton.setBorder(new EmptyBorder(toggleButton.getBorder().getBorderInsets(toggleButton))); } toggleButton.setToolTipText(tooltip); toggleButton.setFocusable(false); return toggleButton; }
Example 5
Source File: VariablesViewButtons.java From netbeans with Apache License 2.0 | 6 votes |
private static JToggleButton createToggleButton (final String id, String iconName, String tooltip) { Icon icon = loadIcon(iconName); boolean isSelected = isButtonSelected(id); final JToggleButton toggleButton = new JToggleButton(icon, isSelected); // ensure small size, just for the icon Dimension size = new Dimension(icon.getIconWidth() + 8, icon.getIconHeight() + 8); toggleButton.setPreferredSize(size); toggleButton.setMargin(new Insets(1, 1, 1, 1)); if (!"Aqua".equals(UIManager.getLookAndFeel().getID())) { //NOI18N // We do not want an ugly border with the exception of Mac, where it paints the toggle state! toggleButton.setBorder(new EmptyBorder(toggleButton.getBorder().getBorderInsets(toggleButton))); } toggleButton.setToolTipText(tooltip); toggleButton.setFocusable(false); return toggleButton; }
Example 6
Source File: RuleEditorViews.java From netbeans with Apache License 2.0 | 6 votes |
public RuleEditorViews(RuleEditorPanel ruleEditorPanel) { this.ruleEditorPanel = ruleEditorPanel; updatedOnlyToggleButton = new JToggleButton(new ViewActionSupport.UpdatedOnlyViewAction(this)); updatedOnlyToggleButton.setToolTipText(updatedOnlyToggleButton.getText()); updatedOnlyToggleButton.setText(null); updatedOnlyToggleButton.setSelected(getViewMode() == ViewMode.UPDATED_ONLY); updatedOnlyToggleButton.setFocusable(false); categorizedToggleButton = new JToggleButton(new ViewActionSupport.CategorizedViewAction(this)); categorizedToggleButton.setToolTipText(categorizedToggleButton.getText()); categorizedToggleButton.setText(null); categorizedToggleButton.setSelected(getViewMode() == ViewMode.CATEGORIZED); categorizedToggleButton.setFocusable(false); allToggleButton = new JToggleButton(new ViewActionSupport.AllViewAction(this)); allToggleButton.setToolTipText(allToggleButton.getText()); allToggleButton.setText(null); allToggleButton.setSelected(getViewMode() == ViewMode.ALL); allToggleButton.setFocusable(false); }
Example 7
Source File: VariablesViewButtons.java From netbeans with Apache License 2.0 | 6 votes |
private static JToggleButton createToggleButton (final String id, String iconName, String tooltip) { Icon icon = loadIcon(iconName); boolean isSelected = isButtonSelected(id); final JToggleButton toggleButton = new JToggleButton(icon, isSelected); // ensure small size, just for the icon Dimension size = new Dimension(icon.getIconWidth() + 8, icon.getIconHeight() + 8); toggleButton.setPreferredSize(size); toggleButton.setMargin(new Insets(1, 1, 1, 1)); if (!"Aqua".equals(UIManager.getLookAndFeel().getID())) { //NOI18N // We do not want an ugly border with the exception of Mac, where it paints the toggle state! toggleButton.setBorder(new EmptyBorder(toggleButton.getBorder().getBorderInsets(toggleButton))); } toggleButton.setToolTipText(tooltip); toggleButton.setFocusable(false); return toggleButton; }
Example 8
Source File: BreakpointsViewButtons.java From netbeans with Apache License 2.0 | 6 votes |
@NbBundle.Messages({"CTL_DeactivateAllBreakpoints=Deactivate all breakpoints in current session", "CTL_ActivateAllBreakpoints=Activate all breakpoints in current session", "CTL_NoDeactivation=The current session does not allow to deactivate breakpoints", "CTL_NoSession=No debugger session"}) public static AbstractButton createActivateBreakpointsActionButton() { ImageIcon icon = ImageUtilities.loadImageIcon(DEACTIVATED_LINE_BREAKPOINT, false); final JToggleButton button = new JToggleButton(icon); // ensure small size, just for the icon Dimension size = new Dimension(icon.getIconWidth() + 8, icon.getIconHeight() + 8); button.setPreferredSize(size); button.setMargin(new Insets(1, 1, 1, 1)); button.setBorder(new EmptyBorder(button.getBorder().getBorderInsets(button))); button.setToolTipText(Bundle.CTL_DeactivateAllBreakpoints()); button.setFocusable(false); final BreakpointsActivator ba = new BreakpointsActivator(button); button.addActionListener(ba); DebuggerManager.getDebuggerManager().addDebuggerListener(DebuggerManager.PROP_CURRENT_ENGINE, new DebuggerManagerAdapter() { @Override public void propertyChange(PropertyChangeEvent evt) { DebuggerEngine de = (DebuggerEngine) evt.getNewValue(); ba.setCurrentEngine(de); } }); ba.setCurrentEngine(DebuggerManager.getDebuggerManager().getCurrentEngine()); return button; }
Example 9
Source File: DrawingViewPlacardPanel.java From openAGV with Apache License 2.0 | 5 votes |
/** * Creates a button to toggle the rulers in the drawing. * * @return The created button. */ private JToggleButton toggleRulersButton() { final JToggleButton toggleButton = new JToggleButton(); toggleButton.setToolTipText( labels.getString("drawingViewPlacardPanel.button_toggleRulers.tooltipText") ); toggleButton.setIcon(ImageDirectory.getImageIcon("/toolbar/document-page-setup.16x16.png")); toggleButton.setMargin(new Insets(0, 0, 0, 0)); toggleButton.setFocusable(false); return toggleButton; }
Example 10
Source File: ToolBar.java From Dayon with GNU General Public License v3.0 | 5 votes |
public void addToggleAction(Action action) { final JToggleButton button = new JToggleButton(); button.setMargin(zeroInsets); button.setHideActionText(true); button.setAction(action); if (action.getValue(Action.SMALL_ICON) == null) { button.setText((String) action.getValue("DISPLAY_NAME")); } button.setFocusable(false); add(button); }
Example 11
Source File: MainMenuJPanel.java From defense-solutions-proofs-of-concept with Apache License 2.0 | 5 votes |
/** * Called when a waypoint is added. This implementation adds a waypoint button. * @param graphic the waypoint graphic, whose ID may or may not be populated. * @param graphicUid the waypoint graphic's ID. * @see RouteListener#waypointAdded(com.esri.core.map.Graphic, int) */ public void waypointAdded(Graphic graphic, int graphicUid) { final JToggleButton button = new JToggleButton((String) graphic.getAttributeValue("name")); waypointButtonToGraphicId.put(button, graphicUid); graphicIdToWaypointButton.put(graphicUid, button); Font font = new Font("Arial", Font.PLAIN, 18); button.setFont(font); button.setFocusable(false); button.setSelected(false); button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (button == selectedWaypointButton) { //Unselect buttonGroup_waypoints.remove(button); button.setSelected(false); buttonGroup_waypoints.add(button); selectedWaypointButton = null; routeController.setSelectedWaypoint(null); } else { selectedWaypointButton = button; routeController.setSelectedWaypoint(waypointButtonToGraphicId.get(button)); } } }); button.setMaximumSize(new Dimension(Integer.MAX_VALUE, 60)); button.setMinimumSize(new Dimension(0, 60)); jPanel_waypointsList.add(button); buttonGroup_waypoints.add(button); }
Example 12
Source File: Controler.java From brModelo with GNU General Public License v3.0 | 5 votes |
private JToggleButton arrume(JToggleButton btn) { Dimension btnDim = new Dimension(40, 40); btn.setHideActionText(true); btn.setFocusable(false); btn.setPreferredSize(btnDim); btn.setDoubleBuffered(true); //btn.setMargin(new Insets(2, 5, 2, 5)); btn.setRolloverEnabled(false); return btn; }
Example 13
Source File: Desing$CodeSwitcherPane.java From DroidUIBuilder with Apache License 2.0 | 5 votes |
private void initGUI() { // 实例化按钮 ButtonGroup bg = new ButtonGroup(); btnLeft = new JToggleButton(""); btnRight = new JToggleButton(""); btnLeft.setContentAreaFilled(false); btnLeft.setFocusable(false); btnLeft.setBorder(null); btnLeft.setPreferredSize(new Dimension(64,25)); btnRight.setContentAreaFilled(false); btnRight.setFocusable(false); btnRight.setBorder(null); btnRight.setPreferredSize(new Dimension(64,25)); // 加入到ButtonGroup(实现RadioButton的形为) bg.add(btnLeft); bg.add(btnRight); // 主面板布局 FlowLayout mainLayout = new FlowLayout(FlowLayout.CENTER); mainLayout.setHgap(0); mainLayout.setVgap(2); this.setLayout(mainLayout); // 此处的border的设置是为了背景上部的装饰而做哦 this.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 0)); // 实例化按钮面板 btnPane = new BtnPane(); btnPane.add(btnLeft); btnPane.add(btnRight); // 添加到总体布局中 this.add(btnPane); }
Example 14
Source File: PrintPreviewComponent.java From ramus with GNU General Public License v3.0 | 5 votes |
public JToolBar createToolBar() { JToolBar bar = new JToolBar(); JComboBox zoom = createZoomComboBox(); for (Action action : getFileActions()) { if (action == null) bar.addSeparator(); else bar.add(action).setFocusable(false); } bar.addSeparator(); JToggleButton grid = new JToggleButton(layoutGridAction); grid.setText(null); grid.setFocusable(false); JToggleButton col = new JToggleButton(layoutColAction); col.setText(null); col.setFocusable(false); ButtonGroup bg = new ButtonGroup(); bg.add(col); bg.add(grid); bar.add(grid); bar.add(col); bar.addSeparator(); JPanel panel = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0)); panel.add(zoom); bar.add(panel); return bar; }
Example 15
Source File: InfoPanel.java From netbeans with Apache License 2.0 | 5 votes |
private JToggleButton createToggle (FiltersDescriptor filtersDesc, int index) { boolean isSelected = filtersDesc.isSelected(index); Icon icon = filtersDesc.getSelectedIcon(index); // ensure small size, just for the icon JToggleButton toggleButton = new JToggleButton(icon, isSelected); // Dimension size = new Dimension(icon.getIconWidth(), icon.getIconHeight()); // toggleButton.setPreferredSize(size); toggleButton.setMargin(new Insets(2, 2, 2, 2)); toggleButton.setToolTipText(filtersDesc.getTooltip(index)); toggleButton.setFocusable(false); filtersDesc.connectToggleButton(index, toggleButton); return toggleButton; }
Example 16
Source File: TaskListTopComponent.java From netbeans with Apache License 2.0 | 5 votes |
private void rebuildToolbar() { toolbar.removeAll(); toolbar.setFocusable( false ); //scope buttons List<TaskScanningScope> scopes = ScanningScopeList.getDefault().getTaskScanningScopes(); for( TaskScanningScope scope : scopes ) { final ScopeButton scopeButton = new ScopeButton( taskManager, scope ); scopeButton.setSelected(scope.equals(Settings.getDefault().getActiveScanningScope())); toolbar.add(scopeButton); } toolbar.add( new JToolBar.Separator() ); //filter JToggleButton toggleFilter = new FiltersMenuButton( filters.getActive() ); toolbar.add( toggleFilter ); //grouping & other butons toolbar.addSeparator(); final JToggleButton toggleGroups = new JToggleButton( ImageUtilities.loadImageIcon("org/netbeans/modules/tasklist/ui/resources/groups.png", false)); //NOI18N toggleGroups.addItemListener( new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { switchTableModel( e.getStateChange() == ItemEvent.SELECTED ); Settings.getDefault().setGroupTasksByCategory( toggleGroups.isSelected() ); toggleGroups.setToolTipText( toggleGroups.isSelected() ? NbBundle.getMessage( TaskListTopComponent.class, "HINT_TasksAsList" ) //NOI18N : NbBundle.getMessage( TaskListTopComponent.class, "HINT_GrouppedTasks" ) ); //NOI18N } }); toggleGroups.setSelected( Settings.getDefault().getGroupTasksByCategory() ); toggleGroups.setToolTipText( toggleGroups.isSelected() ? NbBundle.getMessage( TaskListTopComponent.class, "HINT_TasksAsList" ) //NOI18N : NbBundle.getMessage( TaskListTopComponent.class, "HINT_GrouppedTasks" ) ); //NOI18N toggleGroups.setFocusable( false ); toolbar.add( toggleGroups ); }
Example 17
Source File: NotificationCenterTopComponent.java From netbeans with Apache License 2.0 | 5 votes |
private void init() { initComponents(); detailsPanel = new JPanel(new GridLayout(1, 1)); Color color = Utils.getTextBackground(); detailsPanel.setBackground(new Color(color.getRed(), color.getGreen(), color.getBlue())); lblEmptyDetails = new JLabel(NbBundle.getMessage(NotificationCenterTopComponent.class, "LBL_EmptyDetails"), JLabel.CENTER); lblEmptyDetails.setFont(italicFont); lblEmptyDetails.setEnabled(false); JScrollPane scrollPane = new JScrollPane(detailsPanel); splitPane.setRightComponent(scrollPane); toolBar.setFocusable(false); toolBar.setFloatable(false); btnSearch = new JToggleButton(ImageUtilities.loadImageIcon("org/netbeans/modules/notifications/resources/find16.png", true)); btnSearch.setToolTipText(NbBundle.getMessage(NotificationCenterTopComponent.class, "LBL_SearchToolTip")); btnSearch.setFocusable(false); btnSearch.setSelected(NotificationSettings.isSearchVisible()); //TODO delete 2 lines then quick search API clear text correctly // btnSearch.setToolTipText("Disabled due to Quick Search API defects"); // btnSearch.setEnabled(false); btnSearch.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { setSearchVisible(btnSearch.isSelected()); } }); toolBar.add(btnSearch); toolBar.add(new FiltersMenuButton(notificationManager.getActiveFilter())); initLeft(); showDetails(); }
Example 18
Source File: FiltersManager.java From netbeans with Apache License 2.0 | 5 votes |
private JToggleButton createToggle (Map<String,Boolean> fStates, int index) { boolean isSelected = getPreferences().getBoolean( filtersDesc.getName(index), filtersDesc.isSelected(index) ); Icon icon = filtersDesc.getSelectedIcon(index); // ensure small size, just for the icon JToggleButton result = new JToggleButton(icon, isSelected); Dimension size = new Dimension(icon.getIconWidth() + 6, icon.getIconHeight() + 4); result.setPreferredSize(size); result.setMargin(new Insets(2,3,2,3)); result.setToolTipText(filtersDesc.getTooltip(index)); result.setFocusable(false); fStates.put(filtersDesc.getName(index), Boolean.valueOf(isSelected)); return result; }
Example 19
Source File: CollapsiblePanel.java From netbeans with Apache License 2.0 | 4 votes |
public FilesPanel(VCSCommitPanel master, Map<String, VCSCommitFilter> filters, int preferedHeight) { super(master, master.getModifier().getMessage(VCSCommitPanelModifier.BundleMessage.FILE_PANEL_TITLE), DEFAULT_DISPLAY_FILES); this.filters = filters; master.getCommitTable().labelFor(filesLabel); JComponent table = master.getCommitTable().getComponent(); Mnemonics.setLocalizedText(filesLabel, getMessage("CTL_CommitForm_FilesToCommit")); // NOI18N filesLabel.setMaximumSize(new Dimension(Integer.MAX_VALUE, filesLabel.getMaximumSize().height)); table.setPreferredSize(new Dimension(0, preferedHeight)); ButtonGroup bg = new ButtonGroup(); toolbar = new JToolBar(); toolbar.setFloatable(false); for (VCSCommitFilter filter : filters.values()) { JToggleButton tgb = new JToggleButton(); tgb.setIcon(filter.getIcon()); tgb.setToolTipText(filter.getTooltip()); tgb.setFocusable(false); tgb.setSelected(filter.isSelected()); tgb.addActionListener(this); tgb.putClientProperty(TOOLBAR_FILTER, filter); bg.add(tgb); toolbar.add(tgb); } toolbar.setAlignmentX(LEFT_ALIGNMENT); sectionPanel.add(toolbar); sectionPanel.add(table); sectionPanel.add(VCSCommitPanel.makeVerticalStrut(filesLabel, table, RELATED, sectionPanel)); sectionPanel.add(filesLabel); sectionPanel.setAlignmentX(LEFT_ALIGNMENT); filesLabel.setAlignmentX(LEFT_ALIGNMENT); table.setAlignmentX(LEFT_ALIGNMENT); }
Example 20
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(); }