当前位置: 首页>>代码示例>>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;未经允许,请勿转载。