Java Code Examples for javax.swing.JToggleButton#setText()
The following examples show how to use
javax.swing.JToggleButton#setText() .
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: ToolBarManager.java From openAGV with Apache License 2.0 | 6 votes |
/** * Method addSelectionToolButton must have been invoked prior to this on the * JToolBar. * * @param toolBar * @param editor * @param tool * @param toolTipText * @param labels * @return */ private JToggleButton addToolButton(JToolBar toolBar, DrawingEditor editor, Tool tool, String toolTipText, ImageIcon iconBase) { JToggleButton toggleButton = new JToggleButton(); toggleButton.setIcon(iconBase); toggleButton.setText(null); toggleButton.setToolTipText(toolTipText); toggleButton.addItemListener(new ToolButtonListener(tool, editor)); // toggleButton.setFocusable(false); ToolListener toolHandler = (ToolListener) toolBar.getClientProperty("toolHandler"); tool.addToolListener(toolHandler); ButtonGroup group = (ButtonGroup) toolBar.getClientProperty("toolButtonGroup"); group.add(toggleButton); toolBar.add(toggleButton); return toggleButton; }
Example 2
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 3
Source File: ShowWorkspacePlugin.java From ramus with GNU General Public License v3.0 | 6 votes |
public void createWorkspaceToolBar() { JToolBar workspaceToolBar = new JToolBar(); workspaceToolBar.setFloatable(false); for (ActionDescriptor descriptor : getActionDescriptors()) { final Action action = descriptor.getAction(); if (action instanceof ShowWorkspaceAction) { JToggleButton button = new JToggleButton(action); button.setText(cut((String) action .getValue(Action.ACTION_COMMAND_KEY))); button.setToolTipText((String) action .getValue(Action.ACTION_COMMAND_KEY)); button.addActionListener(new java.awt.event.ActionListener() { @Override public void actionPerformed(ActionEvent e) { action.actionPerformed(e); } }); button.setFocusable(false); workspaceToolBar.add(button); } } factory.setNorthEastCornerComponent(workspaceToolBar); }
Example 4
Source File: SeaGlassDesktopIconUI.java From seaglass with Apache License 2.0 | 6 votes |
public void propertyChange(PropertyChangeEvent evt) { if (evt.getSource() instanceof JInternalFrame.JDesktopIcon) { if (SeaGlassLookAndFeel.shouldUpdateStyle(evt)) { updateStyle((JInternalFrame.JDesktopIcon) evt.getSource()); } } else if (evt.getSource() instanceof JInternalFrame) { JInternalFrame frame = (JInternalFrame) evt.getSource(); if (iconPane instanceof JToggleButton) { JToggleButton button = (JToggleButton) iconPane; String prop = evt.getPropertyName(); if (prop == "title") { button.setText((String) evt.getNewValue()); } else if (prop == "frameIcon") { button.setIcon((Icon) evt.getNewValue()); } else if (prop == JInternalFrame.IS_ICON_PROPERTY || prop == JInternalFrame.IS_SELECTED_PROPERTY) { button.setSelected(!frame.isIcon() && frame.isSelected()); } } } }
Example 5
Source File: GtkSlidingButtonUI.java From netbeans with Apache License 2.0 | 5 votes |
public void installDefaults (AbstractButton b) { super.installDefaults(b); if(!defaults_initialized) { hiddenToggle = new JToggleButton(); hiddenToggle.setText(""); JToolBar bar = new JToolBar(); bar.setRollover(true); bar.add(hiddenToggle); defaults_initialized = true; } }
Example 6
Source File: NimbusSlidingButtonUI.java From netbeans with Apache License 2.0 | 5 votes |
@Override public void installDefaults (AbstractButton b) { super.installDefaults(b); if(!defaults_initialized) { hiddenToggle = new JToggleButton(); hiddenToggle.setText(""); JToolBar bar = new JToolBar(); bar.setRollover(true); bar.add(hiddenToggle); defaults_initialized = true; } }
Example 7
Source File: MetalSlidingButtonUI.java From netbeans with Apache License 2.0 | 5 votes |
public void installDefaults (AbstractButton b) { super.installDefaults(b); if(!defaults_initialized) { hiddenToggle = new JToggleButton(); hiddenToggle.setText(""); JToolBar bar = new JToolBar(); bar.setRollover(true); bar.add(hiddenToggle); defaults_initialized = true; } }
Example 8
Source File: WinXPSlidingButtonUI.java From netbeans with Apache License 2.0 | 5 votes |
@Override public void installDefaults (AbstractButton b) { super.installDefaults(b); if(!defaults_initialized) { hiddenToggle = new JToggleButton(); hiddenToggle.setText(""); JToolBar bar = new JToolBar(); bar.add(hiddenToggle); defaults_initialized = true; } }
Example 9
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 10
Source File: Schematic.java From iBioSim with Apache License 2.0 | 5 votes |
/** * toolbar for when you're looking at a grid * @return */ private JToolBar buildGridToolbar() { JToolBar toolBar = new JToolBar(); ButtonGroup modeButtonGroup = new ButtonGroup(); selectButton = makeRadioToolButton("select_mode.png", "", "Select (" + KeyEvent.getKeyText(KeyEvent.VK_ESCAPE) + ")", this, modeButtonGroup); toolBar.add(selectButton); selectButton.setSelected(true); addComponentButton = makeRadioToolButton("add_component.png", "", "Add Modules (M)", this, modeButtonGroup); toolBar.add(addComponentButton); toolBar.add(makeToolButton("", "editGridSize", "Edit Grid Size", this)); toolBar.addSeparator(); zoomButton = new JToggleButton(); zoomButton.setText("Zoom"); panButton = new JToggleButton(); panButton.setText("Pan"); toolBar.add(zoomButton); toolBar.add(makeToolButton("", "unZoom", "Un-Zoom", this)); toolBar.add(panButton); toolBar.addSeparator(); modelPanel = new ModelPanel(bioModel, modelEditor); toolBar.add(modelPanel); toolBar.setFloatable(false); /* compartmentList.setSelectedItem(bioModel.getDefaultCompartment()); compartmentList.addActionListener(this); */ return toolBar; }
Example 11
Source File: ExitsDialog.java From megamek with GNU General Public License v2.0 | 5 votes |
/** * Sets up JToggleButtons */ JToggleButton setupTButton(String iconName, String buttonName) { JToggleButton button = new JToggleButton(buttonName); // Get the normal icon File file = new MegaMekFile(Configuration.widgetsDir(), "/MapEditor/"+iconName+".png").getFile(); //$NON-NLS-1$ //$NON-NLS-2$ Image imageButton = ImageUtil.loadImageFromFile(file.getAbsolutePath()); if (imageButton != null) { button.setIcon(new ImageIcon(imageButton)); // When there is an icon, then the text can be removed button.setText(""); } // Get the hover icon file = new MegaMekFile(Configuration.widgetsDir(), "/MapEditor/"+iconName+"_H.png").getFile(); //$NON-NLS-1$ //$NON-NLS-2$ imageButton = ImageUtil.loadImageFromFile(file.getAbsolutePath()); if (imageButton != null) button.setRolloverIcon(new ImageIcon(imageButton)); // Get the selected icon file = new MegaMekFile(Configuration.widgetsDir(), "/MapEditor/"+iconName+"_S.png").getFile(); //$NON-NLS-1$ //$NON-NLS-2$ imageButton = ImageUtil.loadImageFromFile(file.getAbsolutePath()); if (imageButton != null) button.setSelectedIcon(new ImageIcon(imageButton)); button.setMargin(new Insets(0,0,0,0)); button.setBorder(BorderFactory.createEmptyBorder()); return button; }
Example 12
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 13
Source File: BoardEditor.java From megamek with GNU General Public License v2.0 | 5 votes |
/** * Sets up JToggleButtons */ private JToggleButton addTerrainTButton(String iconName, String buttonName, ArrayList<JToggleButton> bList) { JToggleButton button = new JToggleButton(buttonName); button.addActionListener(this); // Get the normal icon File file = new MegaMekFile(Configuration.widgetsDir(), "/MapEditor/"+iconName+".png").getFile(); //$NON-NLS-1$ //$NON-NLS-2$ Image imageButton = ImageUtil.loadImageFromFile(file.getAbsolutePath()); if (imageButton != null) { button.setIcon(new ImageIcon(imageButton)); // When there is an icon, then the text can be removed button.setText(""); } // Get the hover icon file = new MegaMekFile(Configuration.widgetsDir(), "/MapEditor/"+iconName+"_H.png").getFile(); //$NON-NLS-1$ //$NON-NLS-2$ imageButton = ImageUtil.loadImageFromFile(file.getAbsolutePath()); if (imageButton != null) button.setRolloverIcon(new ImageIcon(imageButton)); // Get the selected icon file = new MegaMekFile(Configuration.widgetsDir(), "/MapEditor/"+iconName+"_S.png").getFile(); //$NON-NLS-1$ //$NON-NLS-2$ imageButton = ImageUtil.loadImageFromFile(file.getAbsolutePath()); if (imageButton != null) button.setSelectedIcon(new ImageIcon(imageButton)); button.setToolTipText(Messages.getString("BoardEditor."+iconName+"TT")); //$NON-NLS-1$ //$NON-NLS-2$ if (bList != null) bList.add(button); return button; }
Example 14
Source File: ToolAction.java From snap-desktop with GNU General Public License v3.0 | 4 votes |
@Override public Component getToolbarPresenter() { JToggleButton toggleButton = new JToggleButton(this); toggleButton.setText(null); return toggleButton; }
Example 15
Source File: AbstractOverlayAction.java From snap-desktop with GNU General Public License v3.0 | 4 votes |
@Override public Component getToolbarPresenter() { JToggleButton toggleButton = new JToggleButton(this); toggleButton.setText(null); return toggleButton; }
Example 16
Source File: PropertySheetPanel.java From CodenameOne with GNU General Public License v2.0 | 4 votes |
private void buildUI() { LookAndFeelTweaks.setBorderLayout(this); LookAndFeelTweaks.setBorder(this); actionPanel = new JPanel(new FlowLayout(FlowLayout.LEADING, 2, 0)); actionPanel.setBorder(BorderFactory.createEmptyBorder(2, 0, 2, 0)); actionPanel.setOpaque(false); add("North", actionPanel); sortButton = new JToggleButton(new ToggleSortingAction()); sortButton.setUI(new BlueishButtonUI()); sortButton.setText(null); sortButton.setOpaque(false); actionPanel.add(sortButton); asCategoryButton = new JToggleButton(new ToggleModeAction()); asCategoryButton.setUI(new BlueishButtonUI()); asCategoryButton.setText(null); asCategoryButton.setOpaque(false); actionPanel.add(asCategoryButton); descriptionButton = new JToggleButton(new ToggleDescriptionAction()); descriptionButton.setUI(new BlueishButtonUI()); descriptionButton.setText(null); descriptionButton.setOpaque(false); actionPanel.add(descriptionButton); split = new JSplitPane(JSplitPane.VERTICAL_SPLIT); split.setBorder(null); split.setResizeWeight(1.0); split.setContinuousLayout(true); add("Center", split); tableScroll = new JScrollPane(); tableScroll.setBorder(BorderFactory.createEmptyBorder()); split.setTopComponent(tableScroll); descriptionPanel = new JEditorPane("text/html", "<html>"); descriptionPanel.setBorder(BorderFactory.createEmptyBorder()); descriptionPanel.setEditable(false); descriptionPanel.setBackground(UIManager.getColor("Panel.background")); LookAndFeelTweaks.htmlize(descriptionPanel); selectionListener = new SelectionListener(); descriptionScrollPane = new JScrollPane(descriptionPanel); descriptionScrollPane.setBorder(LookAndFeelTweaks.addMargin(BorderFactory .createLineBorder(UIManager.getColor("controlDkShadow")))); descriptionScrollPane.getViewport().setBackground( descriptionPanel.getBackground()); descriptionScrollPane.setMinimumSize(new Dimension(50, 50)); split.setBottomComponent(descriptionScrollPane); // by default description is not visible, toolbar is visible. setDescriptionVisible(false); setToolBarVisible(true); }
Example 17
Source File: Schematic.java From iBioSim with Apache License 2.0 | 4 votes |
/** * create the toolbar. * @return */ private JToolBar buildLEMAToolBar(){ JToolBar toolBar = new JToolBar(); ButtonGroup modeButtonGroup = new ButtonGroup(); selectButton = makeRadioToolButton("select_mode.png", "", "Select (" + KeyEvent.getKeyText(KeyEvent.VK_ESCAPE) + ")", this, modeButtonGroup); toolBar.add(selectButton); selectButton.setSelected(true); addComponentButton = makeRadioToolButton("add_component.png", "", "Add Modules (M)", this, modeButtonGroup); toolBar.add(addComponentButton); addBooleanButton = makeRadioToolButton("boolean_mode.png", "", "Add Booleans (B)", this, modeButtonGroup); toolBar.add(addBooleanButton); addVariableButton = makeRadioToolButton("variable_mode.png", "", "Add Variables (V)", this, modeButtonGroup); toolBar.add(addVariableButton); addPlaceButton = makeRadioToolButton("add_place.png", "", "Add Places (P)", this, modeButtonGroup); toolBar.add(addPlaceButton); addTransitionButton = makeRadioToolButton("add_transition.png", "", "Add Transitions (T)", this, modeButtonGroup); toolBar.add(addTransitionButton); addRuleButton = makeRadioToolButton("rule_mode.png", "", "Add Rules (" + KeyEvent.getKeyText(KeyEvent.VK_SHIFT) + " R)", this, modeButtonGroup); toolBar.add(addRuleButton); addConstraintButton = makeRadioToolButton("constraint_mode.png", "", "Add Constraints (" + KeyEvent.getKeyText(KeyEvent.VK_SHIFT) + " C)", this, modeButtonGroup); toolBar.add(addConstraintButton); //addEventButton = Utils.makeRadioToolButton("event_mode.png", "", "Add Events", this, modeButtonGroup); //toolBar.add(addEventButton); //toolBar.addSeparator(); ButtonGroup influenceButtonGroup = new ButtonGroup(); activationButton = makeRadioToolButton("activation.png", "", "Activation", this, influenceButtonGroup); activationButton.setSelected(true); //toolBar.add(activationButton); toolBar.addSeparator(); toolBar.add(makeToolButton("choose_layout.png", "showLayouts", "Apply Layout", this)); toolBar.addSeparator(); zoomButton = new JToggleButton(); zoomButton.setText("Zoom"); zoomButton.setToolTipText("Use the mouse wheel to zoom"); panButton = new JToggleButton(); panButton.setText("Pan"); panButton.setToolTipText("Use mouse dragging to pan"); toolBar.add(zoomButton); toolBar.add(makeToolButton("", "unZoom", "Un-Zoom", this)); toolBar.add(panButton); //toolBar.add(Utils.makeToolButton("", "saveSBOL", "Save SBOL", this)); //toolBar.add(Utils.makeToolButton("", "exportSBOL", "Export SBOL", this)); //toolBar.addSeparator(); //ModelPanel modelPanel = new ModelPanel(bioModel, modelEditor); //toolBar.add(modelPanel); toolBar.setFloatable(false); return toolBar; }
Example 18
Source File: Schematic.java From iBioSim with Apache License 2.0 | 4 votes |
/** * create the toolbar. * @return */ private JToolBar buildToolBar(){ JToolBar toolBar = new JToolBar(); ButtonGroup modeButtonGroup = new ButtonGroup(); selectButton = makeRadioToolButton("select_mode.png", "", "Select (" + KeyEvent.getKeyText(KeyEvent.VK_ESCAPE) + ")", this, modeButtonGroup); toolBar.add(selectButton); selectButton.setSelected(true); addCompartmentButton = makeRadioToolButton("add_compartment.png", "", "Add Compartment (" + KeyEvent.getKeyText(KeyEvent.VK_ALT) + " C)", this, modeButtonGroup); toolBar.add(addCompartmentButton); addSpeciesButton = makeRadioToolButton("add_species.png", "", "Add Species (S)", this, modeButtonGroup); toolBar.add(addSpeciesButton); addReactionButton = makeRadioToolButton("add_reaction.png", "", "Add Reactions (R)", this, modeButtonGroup); toolBar.add(addReactionButton); addComponentButton = makeRadioToolButton("add_component.png", "", "Add Modules (M)", this, modeButtonGroup); toolBar.add(addComponentButton); addPromoterButton = makeRadioToolButton("promoter_mode.png", "", "Add Promoters (" + KeyEvent.getKeyText(KeyEvent.VK_SHIFT) + " P)", this, modeButtonGroup); toolBar.add(addPromoterButton); addVariableButton = makeRadioToolButton("variable_mode.png", "", "Add Variables (V)", this, modeButtonGroup); toolBar.add(addVariableButton); addBooleanButton = makeRadioToolButton("boolean_mode.png", "", "Add Booleans (B)", this, modeButtonGroup); toolBar.add(addBooleanButton); addPlaceButton = makeRadioToolButton("add_place.png", "", "Add Places (P)", this, modeButtonGroup); toolBar.add(addPlaceButton); addTransitionButton = makeRadioToolButton("add_transition.png", "", "Add Transitions (T)", this, modeButtonGroup); toolBar.add(addTransitionButton); addRuleButton = makeRadioToolButton("rule_mode.png", "", "Add Rules (" + KeyEvent.getKeyText(KeyEvent.VK_SHIFT) + " R)", this, modeButtonGroup); toolBar.add(addRuleButton); addConstraintButton = makeRadioToolButton("constraint_mode.png", "", "Add Constraints (" + KeyEvent.getKeyText(KeyEvent.VK_SHIFT) + " C)", this, modeButtonGroup); toolBar.add(addConstraintButton); addEventButton = makeRadioToolButton("event_mode.png", "", "Add Events (E)", this, modeButtonGroup); toolBar.add(addEventButton); selfInfluenceButton = makeRadioToolButton("self_influence.png", "", "Add Self Influences (I)", this, modeButtonGroup); toolBar.add(selfInfluenceButton); toolBar.addSeparator(); ButtonGroup influenceButtonGroup = new ButtonGroup(); activationButton = makeRadioToolButton("activation.png", "", "Activation", this, influenceButtonGroup); activationButton.setSelected(true); toolBar.add(activationButton); inhibitionButton = makeRadioToolButton("inhibition.png", "", "Repression", this, influenceButtonGroup); toolBar.add(inhibitionButton); noInfluenceButton = makeRadioToolButton("no_influence.png", "", "No Influence", this, influenceButtonGroup); toolBar.add(noInfluenceButton); bioActivationButton = makeRadioToolButton("bio_activation.png", "", "Complex Formation", this, influenceButtonGroup); toolBar.add(bioActivationButton); reactionButton = makeRadioToolButton("reaction.png", "", "Reaction", this, influenceButtonGroup); toolBar.add(reactionButton); modifierButton = makeRadioToolButton("modifier.png", "", "Modifier", this, influenceButtonGroup); toolBar.add(modifierButton); toolBar.addSeparator(); toolBar.add(makeToolButton("choose_layout.png", "showLayouts", "Apply Layout", this)); toolBar.addSeparator(); zoomButton = new JToggleButton(); zoomButton.setText("Zoom"); zoomButton.setToolTipText("Use the mouse wheel to zoom"); panButton = new JToggleButton(); panButton.setText("Pan"); panButton.setToolTipText("Use mouse dragging to pan"); toolBar.add(zoomButton); toolBar.add(makeToolButton("", "unZoom", "Un-Zoom", this)); toolBar.add(panButton); //toolBar.add(Utils.makeToolButton("", "saveSBOL", "Save SBOL", this)); //toolBar.add(Utils.makeToolButton("", "exportSBOL", "Export SBOL", this)); toolBar.addSeparator(); modelPanel = new ModelPanel(bioModel, modelEditor); toolBar.add(modelPanel); // if (bioModel.getElementSBOLCount() == 0 && bioModel.getModelSBOLAnnotationFlag()) // sbolDescriptorsButton.setEnabled(false); toolBar.setFloatable(false); return toolBar; }
Example 19
Source File: PropertySheetPanel.java From orbit-image-analysis with GNU General Public License v3.0 | 4 votes |
private void buildUI() { LookAndFeelTweaks.setBorderLayout(this); LookAndFeelTweaks.setBorder(this); actionPanel = new JPanel(new FlowLayout(FlowLayout.LEADING, 2, 0)); actionPanel.setBorder(BorderFactory.createEmptyBorder(2, 0, 2, 0)); add("North", actionPanel); sortButton = new JToggleButton(new ToggleSortingAction()); sortButton.setUI(new BlueishButtonUI()); sortButton.setText(null); actionPanel.add(sortButton); asCategoryButton = new JToggleButton(new ToggleModeAction()); asCategoryButton.setUI(new BlueishButtonUI()); asCategoryButton.setText(null); actionPanel.add(asCategoryButton); descriptionButton = new JToggleButton(new ToggleDescriptionAction()); descriptionButton.setUI(new BlueishButtonUI()); descriptionButton.setText(null); actionPanel.add(descriptionButton); split = new JSplitPane(JSplitPane.VERTICAL_SPLIT); split.setBorder(null); split.setResizeWeight(1.0); split.setContinuousLayout(true); add("Center", split); tableScroll = new JScrollPane(); split.setTopComponent(tableScroll); descriptionPanel = new JEditorPane("text/html", "<html>"); descriptionPanel.setBorder(BorderFactory.createEmptyBorder()); descriptionPanel.setEditable(false); descriptionPanel.setBackground(UIManager.getColor("Panel.background")); LookAndFeelTweaks.htmlize(descriptionPanel); selectionListener = new SelectionListener(); descriptionScrollPane = new JScrollPane(descriptionPanel); descriptionScrollPane.setBorder(LookAndFeelTweaks.addMargin(BorderFactory .createLineBorder(UIManager.getColor("controlDkShadow")))); descriptionScrollPane.getViewport().setBackground( descriptionPanel.getBackground()); descriptionScrollPane.setMinimumSize(new Dimension(50, 50)); split.setBottomComponent(descriptionScrollPane); // by default description is not visible, toolbar is visible. setDescriptionVisible(false); setToolBarVisible(true); }
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(); }