當前位置: 首頁>>代碼示例>>Java>>正文


Java JToggleButton.addItemListener方法代碼示例

本文整理匯總了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;
   }
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:26,代碼來源:StatisticsPanel.java

示例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);
}
 
開發者ID:CognizantQAHub,項目名稱:Cognizant-Intelligent-Test-Scripter,代碼行數:26,代碼來源:WebORTable.java

示例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;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:12,代碼來源:StatisticsPanel.java

示例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 );
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:35,代碼來源:TaskListTopComponent.java

示例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();
}
 
開發者ID:GateNLP,項目名稱:gate-core,代碼行數:34,代碼來源:JChoice.java

示例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;
}
 
開發者ID:CognizantQAHub,項目名稱:Cognizant-Intelligent-Test-Scripter,代碼行數:10,代碼來源:ObjectRepo.java

示例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);
        }
 
開發者ID:CognizantQAHub,項目名稱:Cognizant-Intelligent-Test-Scripter,代碼行數:35,代碼來源:ImageORTable.java


注:本文中的javax.swing.JToggleButton.addItemListener方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。