下面列出了怎么用javax.swing.JToggleButton的API类实例代码及写法,或者点击链接到github查看源代码。
private void addTool(final Tool t, JMenu menu, JToolBar toolbar, ButtonGroup menuGroup, ButtonGroup toolbarGroup) {
final JToggleButton toggle = new JToggleButton();
final JCheckBoxMenuItem check = new JCheckBoxMenuItem();
Action action = new AbstractAction(t.getName()) {
@Override
public void actionPerformed(ActionEvent e) {
if (currentTool != null) {
currentTool.deactivate();
}
currentTool = t;
toggle.setSelected(true);
check.setSelected(true);
currentTool.activate();
}
};
toggle.setAction(action);
check.setAction(action);
menu.add(check);
if (toolbar != null) {
toolbar.add(toggle);
toolbarGroup.add(toggle);
}
menuGroup.add(check);
}
@Override
public void actionPerformed(ActionEvent e) {
for (JToggleButton button : primaryButtons) {
if (button != e.getSource() && button.isSelected()) {
button.setSelected(false);
} else if (button == e.getSource() && !button.isSelected()) {
button.setSelected(true);
}
if (button.isSelected()) {
button.setFont(button.getFont().deriveFont(Font.BOLD));
} else {
button.setFont(button.getFont().deriveFont(Font.PLAIN));
}
}
if (secondaryButton != null) {
if (secondaryButton != e.getSource() && secondaryButton.isSelected()) {
secondaryButton.clearMenuSelection();
}
}
}
private void createToggleButtonPanel(SoundIdReader soundIdReader, int infoPanelWidth, CardLayout cardLayout, JPanel infoPanel) {
JPanel toggleButtonPanel = JPanelFactory.createBorderlessPanel();
toggleButtonPanel.setBounds(5, 5, infoPanelWidth, 40);
toggleButtonPanel.setLayout(new FlowLayout());
contentPanel.add(toggleButtonPanel);
ButtonGroup buttonGroup = new ButtonGroup();
JToggleButton familyButton = createToggleButton("Family", FAMILY_KEY, soundIdReader, cardLayout, infoPanel, buttonGroup, toggleButtonPanel, "Shows family members of the player character");
createToggleButton("Acquaintances", ACQUAINTANCES_KEY, soundIdReader, cardLayout, infoPanel, buttonGroup, toggleButtonPanel, "Shows acquaintances of the player character");
createToggleButton("Player Character Ranks", RANKS_KEY, soundIdReader, cardLayout, infoPanel, buttonGroup, toggleButtonPanel, "Shows group memberships of the player character");
createToggleButton("Organizations", ORGANIZATIONS_KEY, soundIdReader, cardLayout, infoPanel, buttonGroup, toggleButtonPanel, "Shows an overview of all organizations and their members");
createToggleButton("Deities", DEITIES_KEY, soundIdReader, cardLayout, infoPanel, buttonGroup, toggleButtonPanel, "Shows an overview of all deities and their happiness");
buttonGroup.setSelected(familyButton.getModel(), true);
}
private JToggleButton createToggleButton(String toolTipText,
ImageIcon icon,
java.awt.event.ActionListener actionListener)
{
JToggleButton btn = new JToggleButton();
btn.setMargin(new Insets(0, 0, 0, 0));
btn.setPreferredSize(new Dimension(30, 30));
btn.setIcon(icon);
btn.setMinimumSize(new Dimension(30, 30));
btn.setVerticalTextPosition(SwingConstants.BOTTOM);
btn.setSelected(false);
btn.setToolTipText(toolTipText);
btn.setHorizontalTextPosition(SwingConstants.CENTER);
btn.setFont(new java.awt.Font("SansSerif", 0, 10));
btn.setMaximumSize(new Dimension(30, 30));
btn.addActionListener(actionListener);
return btn;
}
private void addFillButton(JToolBar buttonBar, Insets margin) {
fill = new JToggleButton(new ImageIcon(
GUIFrame.class.getResource("/resources/images/Fill-16.png")));
fill.setMargin(margin);
fill.setFocusPainted(false);
fill.setRequestFocusEnabled(false);
fill.setToolTipText(formatToolTip("Show Fill",
"Fills the entity with the selected colour."));
fill.addActionListener( new ActionListener() {
@Override
public void actionPerformed( ActionEvent event ) {
if (!(selectedEntity instanceof FillEntity))
return;
FillEntity fillEnt = (FillEntity) selectedEntity;
fillColour.setEnabled(fill.isSelected());
if (fillEnt.isFilled() == fill.isSelected())
return;
KeywordIndex kw = InputAgent.formatBoolean("Filled", fill.isSelected());
InputAgent.storeAndExecute(new KeywordCommand((Entity)fillEnt, kw));
controlStartResume.requestFocusInWindow();
}
});
buttonBar.add( fill );
}
public static void main(String[] args) throws IntrospectionException {
Class[] types = {
Component.class,
Container.class,
JComponent.class,
AbstractButton.class,
JButton.class,
JToggleButton.class,
};
// Control set. "enabled" and "name" has the same pattern and can be found
String[] names = {
"enabled",
"name",
"focusable",
};
for (String name : names) {
for (Class type : types) {
BeanUtils.getPropertyDescriptor(type, name);
}
}
}
TimerPanel(ClockManager clockManager, Timer timer)
{
super(clockManager, timer, "timer", true);
JToggleButton loopButton = new JToggleButton(ClockTabPanel.LOOP_ICON);
loopButton.setRolloverIcon(ClockTabPanel.LOOP_ICON_HOVER);
loopButton.setSelectedIcon(ClockTabPanel.LOOP_SELECTED_ICON);
loopButton.setRolloverSelectedIcon(ClockTabPanel.LOOP_SELECTED_ICON_HOVER);
SwingUtil.removeButtonDecorations(loopButton);
loopButton.setPreferredSize(new Dimension(16, 14));
loopButton.setToolTipText("Loop timer");
loopButton.addActionListener(e -> timer.setLoop(!timer.isLoop()));
loopButton.setSelected(timer.isLoop());
leftActions.add(loopButton);
JButton deleteButton = new JButton(ClockTabPanel.DELETE_ICON);
SwingUtil.removeButtonDecorations(deleteButton);
deleteButton.setRolloverIcon(ClockTabPanel.DELETE_ICON_HOVER);
deleteButton.setPreferredSize(new Dimension(16, 14));
deleteButton.setToolTipText("Delete timer");
deleteButton.addActionListener(e -> clockManager.removeTimer(timer));
rightActions.add(deleteButton);
}
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);
}
private void addButton(String title, String iconUrl,
final Component component, JButtonBar bar, ButtonGroup group) {
Action action = new AbstractAction(title, new ImageIcon(
ButtonBarMain.class.getResource(iconUrl))) {
public void actionPerformed(ActionEvent e) {
show(component);
}
};
JToggleButton button = new JToggleButton(action);
bar.add(button);
group.add(button);
if (group.getSelection() == null) {
button.setSelected(true);
show(component);
}
}
/**
* Sets the font for all the components in this search bar.
*/
@Override
public void setFont(Font f) {
for (int a = 0; a < getComponentCount(); a++) {
Component c = getComponent(a);
if (c instanceof JButton) {
((JButton) c).setFont(f);
} else if (c instanceof JCheckBox) {
// do nothing
} else if (c instanceof JToggleButton) {
((JToggleButton) c).setFont(f);
} else if (c instanceof JLabel) {
((JLabel) c).setFont(f);
} else if (c instanceof JTextField) {
((JTextField) c).setFont(f);
}
}
}
private JScrollPane scroll(final JTextArea text) {
final JToggleButton toggleButton = new JToggleButton();
toggleButton.setAction(new AbstractAction() {
private static final long serialVersionUID = -4214143754637722322L;
@Override
public void actionPerformed(final ActionEvent e) {
final boolean wrap = toggleButton.isSelected();
text.setLineWrap(wrap);
}
});
toggleButton.setToolTipText("Toggle line wrapping");
final JScrollPane scrollStatusLog = new JScrollPane(text, //
ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, //
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
scrollStatusLog.setCorner(ScrollPaneConstants.LOWER_RIGHT_CORNER, toggleButton);
return scrollStatusLog;
}
/**
* Finds the toggle button with the given name inside of the given container and then
* ensures that the selected state of the button matches <code>selected</code>.
* <p>
* Note: this works for any instanceof {@link JToggleButton}, such as:
* <ul>
* <li>{@link JCheckBox}</li>
* <li>{@link JRadioButton}</li>
* </ul>
* as well as {@link EmptyBorderToggleButton}s.
*
* @param container a container that has the desired button as a descendant
* @param buttonName the name of the button (you must set this on the button when it is
* constructed; if there is no button with the given name found, then this
* method will search for a button with the given text
* @param selected true to toggle the button to selected; false for de-selected
*/
public static void setToggleButtonSelected(Container container, String buttonName,
boolean selected) {
AbstractButton button = findAbstractButtonByName(container, buttonName);
if (button == null) {
button = findAbstractButtonByText(container, buttonName);
}
if (button == null) {
throw new AssertionError("Could not find button by name or text '" + buttonName + "'");
}
boolean isToggle =
(button instanceof JToggleButton) || (button instanceof EmptyBorderToggleButton);
if (!isToggle) {
throw new AssertionError(
"Found a button, but it is not a toggle button. Text: '" + buttonName + "'");
}
setToggleButtonSelected(button, selected);
}
private void addShowSubModelsButton(JToolBar buttonBar, Insets margin) {
showSubModels = new JToggleButton( new ImageIcon(
GUIFrame.class.getResource("/resources/images/ShowSubModels-16.png")) );
showSubModels.setMargin(margin);
showSubModels.setFocusPainted(false);
showSubModels.setRequestFocusEnabled(false);
showSubModels.setToolTipText(formatToolTip("Show SubModels",
"Displays the components of each sub-model."));
showSubModels.addActionListener( new ActionListener() {
@Override
public void actionPerformed( ActionEvent event ) {
boolean bool = showSubModels.isSelected();
KeywordIndex kw = InputAgent.formatBoolean("ShowSubModels", bool);
InputAgent.storeAndExecute(new KeywordCommand(sim.getSimulation(), kw));
setShowSubModels(bool);
controlStartResume.requestFocusInWindow();
}
} );
buttonBar.add( showSubModels );
}
public static void main(String[] args) throws IntrospectionException {
Class[] types = {
Component.class,
Container.class,
JComponent.class,
AbstractButton.class,
JButton.class,
JToggleButton.class,
};
// Control set. "enabled" and "name" has the same pattern and can be found
String[] names = {
"enabled",
"name",
"focusable",
};
for (String name : names) {
for (Class type : types) {
BeanUtils.getPropertyDescriptor(type, name);
}
}
}
private void addEntityFinderButton(JToolBar buttonBar, Insets margin) {
find = new JToggleButton(new ImageIcon(GUIFrame.class.getResource("/resources/images/Find-16.png")));
find.setToolTipText(formatToolTip("Entity Finder (Ctrl+F)",
"Searches for an entity with a given name."));
find.setMargin(margin);
find.setFocusPainted(false);
find.setRequestFocusEnabled(false);
find.addActionListener(new ActionListener() {
@Override
public void actionPerformed( ActionEvent event ) {
if (find.isSelected()) {
FindBox.getInstance().showDialog();
}
else {
FindBox.getInstance().setVisible(false);
}
controlStartResume.requestFocusInWindow();
}
});
buttonBar.add( find );
}
public OptComponentBinding(Bindings bindings, String property, Class<? extends IValidatable> clazz,
JToggleButton button, boolean enabledByDefault) {
if (property == null || clazz == null || button == null) {
throw new NullPointerException();
}
if (property.equals("")) {
throw new IllegalArgumentException();
}
if (!Arrays.asList(clazz.getInterfaces()).contains(IValidatable.class)) {
throw new IllegalArgumentException(
Messages.getString("OptComponentBinding.must.implement")
+ IValidatable.class);
}
_bindings = bindings;
_property = property;
_clazz = clazz;
_button = button;
_button.addActionListener(this);
_enabledByDefault = enabledByDefault;
}
private static JScrollPane createToggleButtonSelectionPane(JTable table, JTable rowheaderTable,
JToggleButton button)
{
rowheaderTable.setAutoCreateColumnsFromModel(false);
// force the tables to share models
rowheaderTable.setModel(table.getModel());
rowheaderTable.setSelectionModel(table.getSelectionModel());
rowheaderTable.setRowHeight(table.getRowHeight());
rowheaderTable.setIntercellSpacing(table.getIntercellSpacing());
rowheaderTable.setShowGrid(false);
rowheaderTable.setFocusable(false);
TableColumn column = new TableColumn(-1);
column.setHeaderValue(new Object());
column.setCellRenderer(new TableCellUtilities.ToggleButtonRenderer(button));
rowheaderTable.addColumn(column);
rowheaderTable.setPreferredScrollableViewportSize(new Dimension(20, 0));
JScrollPane scrollPane = new JScrollPane();
scrollPane.setViewportView(table);
scrollPane.setRowHeaderView(rowheaderTable);
return scrollPane;
}
public OptComponentBinding(Bindings bindings, String property, Class<? extends IValidatable> clazz,
JToggleButton button, boolean enabledByDefault) {
if (property == null || clazz == null || button == null) {
throw new NullPointerException();
}
if (property.equals("")) {
throw new IllegalArgumentException();
}
if (!Arrays.asList(clazz.getInterfaces()).contains(IValidatable.class)) {
throw new IllegalArgumentException(
Messages.getString("OptComponentBinding.must.implement")
+ IValidatable.class);
}
_bindings = bindings;
_property = property;
_clazz = clazz;
_button = button;
_button.addActionListener(this);
_enabledByDefault = enabledByDefault;
}
public static void main(String[] args) throws IntrospectionException {
Class[] types = {
Component.class,
Container.class,
JComponent.class,
AbstractButton.class,
JButton.class,
JToggleButton.class,
};
// Control set. "enabled" and "name" has the same pattern and can be found
String[] names = {
"enabled",
"name",
"focusable",
};
for (String name : names) {
for (Class type : types) {
BeanUtils.getPropertyDescriptor(type, name);
}
}
}
@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;
}
static ComponentBuilder getBuilder(Instance instance, Heap heap) {
if (DetailsUtils.isSubclassOf(instance, JButton.class.getName())) {
return new JButtonBuilder(instance, heap);
} else if (DetailsUtils.isSubclassOf(instance, JCheckBox.class.getName())) {
return new JCheckBoxBuilder(instance, heap);
} else if (DetailsUtils.isSubclassOf(instance, JRadioButton.class.getName())) {
return new JRadioButtonBuilder(instance, heap);
} else if (DetailsUtils.isSubclassOf(instance, JToggleButton.class.getName())) {
return new JToggleButtonBuilder(instance, heap);
} else if (DetailsUtils.isSubclassOf(instance, JCheckBoxMenuItem.class.getName())) {
return new JCheckBoxMenuItemBuilder(instance, heap);
} else if (DetailsUtils.isSubclassOf(instance, JRadioButtonMenuItem.class.getName())) {
return new JRadioButtonMenuItemBuilder(instance, heap);
} else if (DetailsUtils.isSubclassOf(instance, JMenu.class.getName())) {
return new JMenuBuilder(instance, heap);
} else if (DetailsUtils.isSubclassOf(instance, JMenuBar.class.getName())) {
return new JMenuBarBuilder(instance, heap);
} else if (DetailsUtils.isSubclassOf(instance, JMenuItem.class.getName())) {
return new JMenuItemBuilder(instance, heap);
}
return null;
}
public void PopuleBarra(JComponent obj) {
ButtonGroup buttons = new ButtonGroup();
Barra = obj;
Acao ac = new Acao(editor, "?", "Controler.interface.BarraLateral.Nothing.img", "Controler.interface.BarraLateral.Nothing.Texto", null);
JToggleButton btn = arrume(new JToggleButton(ac));
buttons.add(btn);
obj.add(btn);
btn.setSelected(true);
ac.IDX = -1;
this.BtnNothing = btn;
int i = 0;
for (ConfigAcao ca : Lista) {
if (ca.tipo == TipoConfigAcao.tpBotoes || ca.tipo == TipoConfigAcao.tpAny) {
ac = new Acao(editor, ca.texto, ca.ico, ca.descricao, ca.command);
ac.IDX = i++;
btn = arrume(new JToggleButton(ac));
buttons.add(btn);
//obj.add(btn);
listaBotoes.put(ca.command, btn);
}
}
menuComandos c = menuComandos.cmdDel;
String str = "Controler.comandos." + c.toString().substring(3).toLowerCase();
ac = new Acao(editor, Editor.fromConfiguracao.getValor(str + ".descricao"), str + ".img", str + ".descricao", c.toString());
ListaDeAcoesEditaveis.add(ac);
ac.normal = false;
JButton btn2 = new JButton(ac);
btn2.setHideActionText(true);
btn2.setFocusable(false);
btn2.setPreferredSize(new Dimension(40, 40));
obj.add(btn2);
LayoutManager la = obj.getLayout();
if (la instanceof GridLayout) {
((GridLayout) la).setRows(i + 2);
}
}
public void setOrSwitchZone(MagicPlayerZone aZone) {
int switchPlayer = aZone != getZone()
? getPlayerIndex()
: getPlayerIndex() == 0 ? 1 : 0;
for (JToggleButton btn : buttons) {
if (aZone.equals(getZone(btn)) && switchPlayer == getPlayerIndex(btn)) {
setSelectedTab(getTabIndex(aZone, switchPlayer));
}
}
}
private void scanScript(final StringReader reader) throws Exception {
scriptPane.read(reader, null);
reader.reset();
// create lexer
final GroovyLangLexer lexer = new GroovyLangLexer(reader);
tokenPane.setEditable(true);
tokenPane.setText("");
int line = 1;
final ButtonGroup bg = new ButtonGroup();
Token token;
while (true) {
token = lexer.nextToken();
JToggleButton tokenButton = new JToggleButton(tokens.get(token.getType()));
bg.add(tokenButton);
tokenButton.addActionListener(this);
tokenButton.setToolTipText(token.getText());
tokenButton.putClientProperty("token", token);
tokenButton.setMargin(new Insets(0, 1, 0, 1));
tokenButton.setFocusPainted(false);
if (token.getLine() > line) {
tokenPane.getDocument().insertString(tokenPane.getDocument().getLength(), "\n", null);
line = token.getLine();
}
insertComponent(tokenButton);
if (eof().equals(token.getType())) {
break;
}
}
tokenPane.setEditable(false);
tokenPane.setCaretPosition(0);
reader.close();
}
private JToggleButton getToggleButton(String text, AbstractAction action) {
final JToggleButton btn = new ViewToggleButton(text);
if (action != null) {
btn.addActionListener(action);
}
toggleGroup.add(btn);
return btn;
}
/** Reactions to toggle button click, */
public void actionPerformed(ActionEvent e) {
// copy changed state first
JToggleButton toggle = (JToggleButton)e.getSource();
int index = toggles.indexOf(e.getSource());
synchronized (STATES_LOCK) {
filterStates.put(filtersDesc.getName(index),
Boolean.valueOf(toggle.isSelected()));
}
// notify
fireChange();
}
/**
* 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);
}
/**
* Creates a panel that allows forcing of pseudo-classes.
*
* @param pseudoClassToggle toggle-button used to show the panel.
* @return panel that allows forcing of pseudo-classes.
*/
private JPanel createPseudoClassPanel(JToggleButton pseudoClassToggle) {
final JPanel panel = new JPanel();
panel.setLayout(new GridLayout(2,2));
ResourceBundle bundle = NbBundle.getBundle(CSSStylesSelectionPanel.class);
panel.add(createPseudoCheckBox(
CSS.PseudoClass.ACTIVE,
bundle.getString("CSSStylesSelectionPanel.pseudoClass.active"))); // NOI18N
panel.add(createPseudoCheckBox(
CSS.PseudoClass.HOVER,
bundle.getString("CSSStylesSelectionPanel.pseudoClass.hover"))); // NOI18N
panel.add(createPseudoCheckBox(
CSS.PseudoClass.FOCUS,
bundle.getString("CSSStylesSelectionPanel.pseudoClass.focus"))); // NOI18N
panel.add(createPseudoCheckBox(
CSS.PseudoClass.VISITED,
bundle.getString("CSSStylesSelectionPanel.pseudoClass.visited"))); // NOI18N
panel.setVisible(false);
pseudoClassToggle.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
JToggleButton source = (JToggleButton)e.getSource();
panel.setVisible(source.isSelected());
}
});
return panel;
}
/**
* Constructor
*/
public ShapeSelectionPanel() {
super(BoxLayout.Y_AXIS);
JToolBar tb = new JToolBar();
tb.setFloatable(false);
ButtonGroup group = new ButtonGroup();
for (EShapeType type : EShapeType.values()) {
JToggleButton bt = new JToggleButton(type.getIcon());
bt.setDisabledIcon(type.getIcon().createDisabledIcon());
bt.setSelectedIcon(type.getIcon().createSelectedIcon());
bt.setToolTipText(type.getShape().getName());
bt.addActionListener(new ShapeActionListener(type.getShape()));
bt.setEnabled(false);
tb.add(bt);
group.add(bt);
buttons.put(type, bt);
}
add(tb);
for (EShapeProperty p : EShapeProperty.values()) {
StrokenSlider slider = new StrokenSlider(p);
properties.put(p, slider);
add(slider);
}
updateStrokeProperties();
}
public static JToggleButton createShowResultButton() {
JToggleButton button = createToggleButton(
SHOW_EVALUTOR_RESULT,
"org/netbeans/modules/debugger/resources/localsView/show_evaluator_result_16.png",
NbBundle.getMessage (VariablesViewButtons.class, "Hint_Show_Result")
);
button.addActionListener(new ShowResultActionListener(button));
return button;
}