本文整理汇总了Java中javax.swing.JToggleButton.addItemListener方法的典型用法代码示例。如果您正苦于以下问题:Java JToggleButton.addItemListener方法的具体用法?Java JToggleButton.addItemListener怎么用?Java JToggleButton.addItemListener使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JToggleButton
的用法示例。
在下文中一共展示了JToggleButton.addItemListener方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: newOptionButton
import javax.swing.JToggleButton; //导入方法依赖的package包/类
private JToggleButton newOptionButton(Icon icon, String tooltip, String accessibleName, final String property) {
JToggleButton newButton = new JToggleButton(icon);
newButton.setToolTipText(tooltip);
newButton.getAccessibleContext().setAccessibleName(accessibleName);
boolean isSelected = NbPreferences.forModule(StatisticsPanel.class).getBoolean(property, false);
newButton.setSelected(isSelected);
newButton.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
boolean selected;
switch (e.getStateChange()) {
case ItemEvent.SELECTED:
selected = true;
break;
case ItemEvent.DESELECTED:
selected = false;
break;
default:
return;
}
ResultWindow.getInstance().updateOptionStatus(property, selected);
}
});
return newButton;
}
示例2: init
import javax.swing.JToggleButton; //导入方法依赖的package包/类
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);
}
示例3: newShowButton
import javax.swing.JToggleButton; //导入方法依赖的package包/类
private JToggleButton newShowButton(String iconId,
String tooltip,
String accessibleName,
Status status) {
JToggleButton btn = new JToggleButton(ImageUtilities.loadImageIcon(iconId, true));
btn.setToolTipText(tooltip);
btn.getAccessibleContext().setAccessibleName(accessibleName);
btn.setSelected((filterMask & status.getBitMask()) == 0);
btn.addItemListener(new FilterItemListener(status));
return btn;
}
示例4: rebuildToolbar
import javax.swing.JToggleButton; //导入方法依赖的package包/类
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 );
}
示例5: buildGui
import javax.swing.JToggleButton; //导入方法依赖的package包/类
/**
* (Re)constructs the UI. This can be called many times, whenever a
* significant value (such as {@link #maximumFastChoices}, or the model)
* has changed.
*/
private void buildGui(){
removeAll();
if(model != null && model.getSize() > 0){
if(model.getSize() > maximumFastChoices){
//use combobox
add(combo);
}else{
//use buttons
//first clear the old buttons, if any exist
if(buttonToValueMap.size() > 0){
for(AbstractButton aBtn : buttonToValueMap.keySet()){
aBtn.removeItemListener(sharedItemListener);
}
}
//now create the new buttons
buttonToValueMap.clear();
for(int i = 0; i < model.getSize(); i++){
Object aValue = model.getElementAt(i);
JToggleButton aButton = new JToggleButton(aValue.toString());
if(defaultButtonMargin != null) aButton.setMargin(defaultButtonMargin);
aButton.addItemListener(sharedItemListener);
buttonToValueMap.put(aButton, aValue);
add(aButton);
}
}
}
revalidate();
}
示例6: create
import javax.swing.JToggleButton; //导入方法依赖的package包/类
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;
}
示例7: init
import javax.swing.JToggleButton; //导入方法依赖的package包/类
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);
}