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


Java ItemListener.itemStateChanged方法代碼示例

本文整理匯總了Java中java.awt.event.ItemListener.itemStateChanged方法的典型用法代碼示例。如果您正苦於以下問題:Java ItemListener.itemStateChanged方法的具體用法?Java ItemListener.itemStateChanged怎麽用?Java ItemListener.itemStateChanged使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.awt.event.ItemListener的用法示例。


在下文中一共展示了ItemListener.itemStateChanged方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: Ed

import java.awt.event.ItemListener; //導入方法依賴的package包/類
public Ed(ReportState piece) {

      box = new JPanel();
      box.setLayout(new BoxLayout(box, BoxLayout.Y_AXIS));
      descInput = new StringConfigurer(null, "Description:  ", piece.description);
      box.add(descInput.getControls());
      keys = new NamedKeyStrokeArrayConfigurer(null, "Report on these keystrokes:  ", piece.keys);
      box.add(keys.getControls());
      cycle = new JCheckBox("Cycle through different messages?");
      box.add(cycle);
      format = new PlayerIdFormattedStringConfigurer(null, "Report format:  ", new String[]{COMMAND_NAME,
                                                                                         OLD_UNIT_NAME,
                                                                                         NEW_UNIT_NAME,
                                                                                         MAP_NAME,
                                                                                         OLD_MAP_NAME,
                                                                                         LOCATION_NAME,
                                                                                         OLD_LOCATION_NAME});
      format.setValue(piece.reportFormat);
      box.add(format.getControls());
      cycleFormat = new StringArrayConfigurer(null, "Message formats", piece.cycleReportFormat);
      box.add(cycleFormat.getControls());
      cycleDownKeys = new NamedKeyStrokeArrayConfigurer(null, "Report previous message on these keystrokes:  ", piece.cycleDownKeys);
      box.add(cycleDownKeys.getControls());
      ItemListener l = new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
          format.getControls().setVisible(!cycle.isSelected());
          cycleFormat.getControls().setVisible(cycle.isSelected());
          cycleDownKeys.getControls().setVisible(cycle.isSelected());
          Window w = SwingUtilities.getWindowAncestor(box);
          if (w != null) {
            w.pack();
          }
        }
      };
      l.itemStateChanged(null);
      cycle.addItemListener(l);
      cycle.setSelected(piece.cycleReportFormat.length > 0);
    }
 
開發者ID:ajmath,項目名稱:VASSAL-src,代碼行數:39,代碼來源:ReportState.java

示例2: setActivated

import java.awt.event.ItemListener; //導入方法依賴的package包/類
/**
 * activates or deactivates the widget in the panel
 * @param activated boolean true to activate and false to deactivate
 */
public void setActivated(boolean activated) {
	if(widget!=null && widget.isClickable()){
		widget.setActive(activated);
		if(activated){
			labelPanel.setBackground(highlightColor);
			jLabel.setForeground(Color.GRAY);
		}else{
			labelPanel.setBackground(Color.GRAY);
			jLabel.setForeground(highlightColor);
		}
		if(widget!=null){
			widget.onActiveChanged();
		}
		//notify the listeners over the widet the state change event
		for(ItemListener listener: listeners){
			ItemEvent e = new ItemEvent(this,0,widget, isActivated() ? ItemEvent.SELECTED : ItemEvent.DESELECTED);
			listener.itemStateChanged(e);
		}
	}
}
 
開發者ID:dev-cuttlefish,項目名稱:cuttlefish,代碼行數:25,代碼來源:GroupPanel.java

示例3: fireSelectionChanged

import java.awt.event.ItemListener; //導入方法依賴的package包/類
private void fireSelectionChanged() {
    if ((selectionListeners == null) || selectionListeners.isEmpty()) {
        return;
    }

    final ItemEvent event = new ItemEvent(this,
                                          ItemEvent.ITEM_STATE_CHANGED,
                                          getSelectedRepository(),
                                          ItemEvent.SELECTED);
    for (ItemListener l : selectionListeners) {
        l.itemStateChanged(event);
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:14,代碼來源:RepositorySelectorBuilder.java

示例4: itemStateChanged

import java.awt.event.ItemListener; //導入方法依賴的package包/類
@Override
public void itemStateChanged(final ItemEvent e)
{
	if( allowSetEnable )
	{
		setAllEnabled(e.getStateChange() == ItemEvent.SELECTED);
	}

	for( final ItemListener listener : listenerList.getListeners(ItemListener.class) )
	{
		listener.itemStateChanged(e);
	}
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:14,代碼來源:GroupBox.java

示例5: processItemEvent

import java.awt.event.ItemListener; //導入方法依賴的package包/類
/**
 * Processes item events occurring on this check box menu item by
 * dispatching them to any registered {@code ItemListener} objects.
 * <p>
 * This method is not called unless item events are
 * enabled for this menu item. Item events are enabled
 * when one of the following occurs:
 * <ul>
 * <li>An {@code ItemListener} object is registered
 * via {@code addItemListener}.
 * <li>Item events are enabled via {@code enableEvents}.
 * </ul>
 * <p>Note that if the event parameter is {@code null}
 * the behavior is unspecified and may result in an
 * exception.
 *
 * @param       e the item event
 * @see         java.awt.event.ItemEvent
 * @see         java.awt.event.ItemListener
 * @see         #addItemListener
 * @see         java.awt.MenuItem#enableEvents
 * @since       1.1
 */
protected void processItemEvent(ItemEvent e) {
    ItemListener listener = itemListener;
    if (listener != null) {
        listener.itemStateChanged(e);
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:30,代碼來源:CheckboxMenuItem.java


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