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


Java JComboBox.addActionListener方法代碼示例

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


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

示例1: showInfo

import javax.swing.JComboBox; //導入方法依賴的package包/類
/**
 * Show information about a host
 * @param host Host to show the information of
 */
@SuppressWarnings("unchecked")
public void showInfo(DTNHost host) {
	Vector messages = new Vector<Message>(host.getMessageCollection());
	Collections.sort(messages);
	reset();
	this.selectedHost = host;
	String text = (host.isActive() ? "" : "INACTIVE ") + host + " at " +
		host.getLocation();
	
	msgChooser = new JComboBox(messages);
	msgChooser.insertItemAt(messages.size() + " messages", 0);
	msgChooser.setSelectedIndex(0);
	msgChooser.addActionListener(this);
	
	routingInfoButton = new JButton("routing info");
	routingInfoButton.addActionListener(this);
	
	this.add(new JLabel(text));
	this.add(msgChooser);
	this.add(routingInfoButton);
	this.revalidate();
}
 
開發者ID:mdonnyk,項目名稱:the-one-mdonnyk,代碼行數:27,代碼來源:InfoPanel.java

示例2: getTableCellEditorComponent

import javax.swing.JComboBox; //導入方法依賴的package包/類
public Component getTableCellEditorComponent(JTable table, Object obj, boolean isSelected, int row, int col) {  
                      comboBox = new JComboBox();   
                      comboBox.addActionListener(new ActionListener() {
		public void actionPerformed(ActionEvent event) {
                                  fireEditingStopped();
		}
	});
                      DefaultComboBoxModel rootModel = new DefaultComboBoxModel();
                      SchemaObject o = (SchemaObject)table.getModel().getValueAt(row, SCHEMA_COL);
                      
                      if( !(o.toString().equals(startString))) {
                          String[] root = o.getRootElements();
                          if(root != null && root.length >0) {
                              for(int i=0; i < root.length; i++)
                                  rootModel.addElement(root[i]);
                          }
                      }                           
                      comboBox.setModel(rootModel);
	return comboBox;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:21,代碼來源:SchemaPanel.java

示例3: connect

import javax.swing.JComboBox; //導入方法依賴的package包/類
void connect( JTree errorTree, JComboBox severityComboBox, 
              JCheckBox tasklistCheckBox, JPanel customizerPanel,
              JEditorPane descriptionTextArea) {
    
    this.errorTree = errorTree;
    this.severityComboBox = severityComboBox;
    this.tasklistCheckBox = tasklistCheckBox;
    this.customizerPanel = customizerPanel;
    this.descriptionTextArea = descriptionTextArea;        
    
    valueChanged( null );
    
    errorTree.addKeyListener(this);
    errorTree.addMouseListener(this);
    errorTree.getSelectionModel().addTreeSelectionListener(this);
        
    severityComboBox.addActionListener(this);
    tasklistCheckBox.addChangeListener(this);
    
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:21,代碼來源:HintsPanelLogic.java

示例4: makeComboBox

import javax.swing.JComboBox; //導入方法依賴的package包/類
static JComboBox makeComboBox(Map<Procedure, MarkovGraph> grafs) {
    String[] nameArray = new String[grafs.keySet().size()];
    int i = 0;
    for (Object p : grafs.keySet().toArray()) {
        nameArray[i] = ((Procedure) p).toString();
        i++;
    }
    JComboBox jcb = new JComboBox(nameArray);
    ActionListener l = null; // FIXME(svelagap) new MyActionListener(grafs);
    jcb.addActionListener(l);
    return jcb;
}
 
開發者ID:s-store,項目名稱:s-store,代碼行數:13,代碼來源:MarkovViewer.java

示例5: connect

import javax.swing.JComboBox; //導入方法依賴的package包/類
void connect( final JTree errorTree, DefaultTreeModel errorTreeModel, JLabel severityLabel, JComboBox severityComboBox,
              JCheckBox tasklistCheckBox, JPanel customizerPanel,
              JEditorPane descriptionTextArea, final JComboBox configCombo, JButton editScript,
              HintsSettings settings, boolean direct) {
    
    this.errorTree = errorTree;
    this.errorTreeModel = errorTreeModel;
    this.severityLabel = severityLabel;
    this.severityComboBox = severityComboBox;
    this.tasklistCheckBox = tasklistCheckBox;
    this.customizerPanel = customizerPanel;
    this.descriptionTextArea = descriptionTextArea;        
    this.configCombo = configCombo;
    this.editScript = editScript;
    this.direct = direct;
    
    if (configCombo.getSelectedItem() !=null) {
        originalSettings = ((Configuration) configCombo.getSelectedItem()).getSettings();
    } else if (settings != null) {
        originalSettings = settings;
    } else {
        originalSettings = HintsSettings.getGlobalSettings();
    }
    
    writableSettings = new WritableSettings(originalSettings, direct);
    
    valueChanged( null );
    
    errorTree.addKeyListener(this);
    errorTree.addMouseListener(this);
    errorTree.getSelectionModel().addTreeSelectionListener(this);
        
    this.configCombo.addItemListener(this);
    severityComboBox.addActionListener(this);
    tasklistCheckBox.addChangeListener(this);
    
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:38,代碼來源:HintsPanelLogic.java

示例6: makeAlphabetizedComboBox

import javax.swing.JComboBox; //導入方法依賴的package包/類
static JComboBox makeAlphabetizedComboBox(Map<Procedure, MarkovGraph> grafs) {
    List<Procedure> ls = new LinkedList<Procedure>();
    List<String> names = new LinkedList<String>();
    ls.addAll(grafs.keySet());
    for (Procedure p : ls) {
        names.add(p.getName().toLowerCase());
    }
    Collections.sort(names);
    JComboBox jcb = new JComboBox(names.toArray());
    ActionListener l = null; // FIXME(svelagap) new MyActionListener(grafs);
    jcb.addActionListener(l);
    return jcb;
}
 
開發者ID:s-store,項目名稱:s-store,代碼行數:14,代碼來源:MarkovViewer.java

示例7: createList

import javax.swing.JComboBox; //導入方法依賴的package包/類
private JPanel createList() {
    DefaultListModel listModel = new DefaultListModel();

    for (int i = 0; i < 10; i++) {
        listModel.addElement("List Item " + i);
    }

    list = new JList(listModel);
    list.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
    JScrollPane scrollPane = new JScrollPane(list);
    scrollPane.setPreferredSize(new Dimension(400, 100));

    list.setDragEnabled(true);
    list.setTransferHandler(new ListTransferHandler());

    dropCombo = new JComboBox(new String[] { "USE_SELECTION", "ON", "INSERT", "ON_OR_INSERT" });
    dropCombo.addActionListener(this);
    JPanel dropPanel = new JPanel();
    dropPanel.add(new JLabel("List Drop Mode:"));
    dropPanel.add(dropCombo);

    JPanel panel = new JPanel(new BorderLayout());
    panel.add(scrollPane, BorderLayout.CENTER);
    panel.add(dropPanel, BorderLayout.SOUTH);
    panel.setBorder(BorderFactory.createTitledBorder("List"));
    return panel;
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:28,代碼來源:DropDemo.java

示例8: createNorth

import javax.swing.JComboBox; //導入方法依賴的package包/類
private JComponent createNorth()
{
	Map<TextAttribute, Float> fontAttributes = new HashMap<TextAttribute, Float>();
	fontAttributes.put(TextAttribute.SIZE, 30f);
	fontAttributes.put(TextAttribute.WEIGHT, TextAttribute.WEIGHT_BOLD);

	dateDisplay = new JLabel();
	dateDisplay.setVerticalAlignment(SwingConstants.BOTTOM);
	dateDisplay.setFont(new Font(fontAttributes));
	dateDisplay.setForeground(Color.BLUE);

	months = new JComboBox(MONTHS);
	years = new JComboBox();

	for( int i = YEAR_START; i <= YEAR_END; i++ )
	{
		years.addItem(Integer.valueOf(i));
	}

	months.addActionListener(this);
	years.addActionListener(this);

	final int height1 = months.getPreferredSize().height;
	final int width1 = months.getPreferredSize().width;

	final int[] rows = {height1, height1};
	final int[] cols = {TableLayout.FILL, width1};

	JPanel all = new JPanel(new TableLayout(rows, cols, 5, 5));
	all.add(dateDisplay, new Rectangle(0, 0, 1, 2));
	all.add(months, new Rectangle(1, 0, 1, 1));
	all.add(years, new Rectangle(1, 1, 1, 1));

	return all;
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:36,代碼來源:JCalendar.java

示例9: subscribeActual

import javax.swing.JComboBox; //導入方法依賴的package包/類
@Override
protected void subscribeActual(Observer<? super ActionEvent> observer) {
    JComboBox<?> w = widget;

    ActionEventConsumer aec = new ActionEventConsumer(observer, w);
    observer.onSubscribe(aec);

    w.addActionListener(aec);
    if (aec.get() == null) {
        w.removeActionListener(aec);
    }
}
 
開發者ID:akarnokd,項目名稱:RxJava2Swing,代碼行數:13,代碼來源:ActionEventComboBoxObservable.java

示例10: getControls

import javax.swing.JComboBox; //導入方法依賴的package包/類
public java.awt.Component getControls() {
  if (p == null) {
    super.getControls();

    nameField.addFocusListener(this);
    dropList = new JComboBox(optionsModel);
    dropList.setSelectedIndex(0);
    dropList.setEnabled(false);
    dropList.addActionListener(this);

    setListVisibility();
    p.add(dropList);
  }
  return p;
}
 
開發者ID:ajmath,項目名稱:VASSAL-src,代碼行數:16,代碼來源:FormattedStringConfigurer.java

示例11: createSaveBox

import javax.swing.JComboBox; //導入方法依賴的package包/類
protected Component createSaveBox() {
	save = new JComboBox(saveOptions);
	save.addActionListener(this);
	save.addItemListener(this);
	save.addPopupMenuListener(this);
	save.setActionCommand("save");
	return save;
}
 
開發者ID:iedadata,項目名稱:geomapapp,代碼行數:9,代碼來源:CustomDB.java

示例12: init

import javax.swing.JComboBox; //導入方法依賴的package包/類
/**
 * Initializes the node chooser panels
 */
private void init() {
	nodesPanel = new JPanel();
	chooserPanel = new JPanel();
	
	this.setLayout(new GridBagLayout());
	GridBagConstraints c = new GridBagConstraints();
	c.anchor = GridBagConstraints.FIRST_LINE_START;
	
	nodesPanel.setLayout(new BoxLayout(nodesPanel,BoxLayout.Y_AXIS));
	nodesPanel.setBorder(BorderFactory.createTitledBorder(getBorder(),
			"Nodes"));
	
	if (nodes.size() > MAX_NODE_COUNT) {
		String[] groupNames = new String[(nodes.size()-1)/MAX_NODE_COUNT+1];
		int last = 0;
		for (int i=0, n=nodes.size(); i <= (n-1) / MAX_NODE_COUNT; i++) {
			int next = MAX_NODE_COUNT * (i+1) - 1;
			if (next > n) {
				next = n-1;
			}
			groupNames[i] = (last + "..." + next);
			last = next + 1;
		}
		groupChooser = new JComboBox(groupNames);
		groupChooser.addActionListener(this);
		chooserPanel.add(groupChooser);
	}
	
	setNodes(0);
	c.gridy = 0;
	this.add(chooserPanel, c);
	c.gridy = 1;
	this.add(nodesPanel, c);
}
 
開發者ID:mdonnyk,項目名稱:the-one-mdonnyk,代碼行數:38,代碼來源:NodeChooser.java

示例13: MapPanel

import javax.swing.JComboBox; //導入方法依賴的package包/類
public MapPanel(JSpinner sx, JSpinner sy, JComboBox ci) {
	this.sx = sx;
	this.sy = sy;
	this.ci = ci;
	
	addMouseListener(this);
	
	ci.addActionListener(new ActionListener() {

		@Override
		public void actionPerformed(ActionEvent arg0) {
			repaint();
		}
		
	});
	
	try {
		bg = ImageIO.read(new File(Settings.BASE_PATH + File.separatorChar + "gfx" + File.separatorChar + "MAP.bmp"));
		iconSheet = ImageIO.read(new File(Settings.BASE_PATH + File.separatorChar + "gfx" + File.separatorChar + "PK2STUFF.bmp"));
	} catch (IOException e) {
		e.printStackTrace();
	}
	
	for (int i = 0; i < 22; i++) {
		iconList.add(iconSheet.getSubimage((i * 28) + 1, iconSheet.getHeight() - 28, 27, 27));
	}
	
	for (int i = 0; i < iconList.size(); i++) {
		BufferedImage bb = iconList.get(i);
		BufferedImage b2 = new BufferedImage(27, 27, BufferedImage.TYPE_INT_ARGB);
		
		int oldRGB = new Color(155, 232, 224).getRGB();

		for (int x = 0; x < bb.getWidth(); x++) {
			for (int y = 0; y < bb.getHeight(); y++) {
				if (bb.getRGB(x, y) != oldRGB) {
					b2.setRGB(x, y, bb.getRGB(x, y));
				}
			}
		}
	    
	    iconList.set(i, b2);
	}
}
 
開發者ID:Detea,項目名稱:PekaED,代碼行數:45,代碼來源:SetMapPositionDialog.java

示例14: ParameterDisjunctionEditor

import javax.swing.JComboBox; //導入方法依賴的package包/類
public ParameterDisjunctionEditor() {
  super(new JComboBox());
  combo = (JComboBox)super.getComponent();
  class CustomRenderer extends JLabel implements ListCellRenderer {
    public CustomRenderer() {
      setOpaque(true);
    }

    @Override
    public Component getListCellRendererComponent(JList list, Object value,
            int index, boolean isSelected, boolean cellHasFocus) {
      if(isSelected) {
        setBackground(list.getSelectionBackground());
        setForeground(list.getSelectionForeground());
      }
      else {
        setBackground(list.getBackground());
        setForeground(list.getForeground());
      }

      setFont(list.getFont());

      setText((String)value);

      setIcon(MainFrame.getIcon("param"));
      Parameter[] params = pDisj.getParameters();
      for(int i = 0; i < params.length; i++) {
        Parameter param = params[i];
        if(param.getName().equals(value)) {
          String type = param.getTypeName();
          if(Gate.getCreoleRegister().containsKey(type)) {
            ResourceData rData = Gate.getCreoleRegister()
                    .get(type);
            if(rData != null)
              setIcon(MainFrame.getIcon(rData.getIcon(),
                  rData.getResourceClassLoader()));
          }
          break;
        }// if(params[i].getName().equals(value))
      }// for(int i = 0; params.length; i++)

      
      return this;
    }
  } // class CustomRenderer extends JLabel implements
    // ListCellRenderer
  combo.setRenderer(new CustomRenderer());
  combo.addActionListener(new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent e) {
      pDisj.setSelectedIndex(combo.getSelectedIndex());
      stopCellEditing();
    }
  });
}
 
開發者ID:GateNLP,項目名稱:gate-core,代碼行數:56,代碼來源:ResourceParametersEditor.java

示例15: createCustomControls

import javax.swing.JComboBox; //導入方法依賴的package包/類
@SuppressWarnings("rawtypes")
	protected JComponent createCustomControls() {
		myComboBox = new JComboBox();
		myComboBox.setFont(myComboBox.getFont().deriveFont(10f));
		
		ArrayList<FiringModelMap> contents;
		if (stf != null) {
			stf.getSupport().addPropertyChangeListener("firingModelMaps", this);
			contents = stf.getFiringModelMaps();
		}
		else 
			contents = new ArrayList<FiringModelMap>();
		updateComboBox(new ArrayList<FiringModelMap>(), contents);
		
		myComboBox.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent arg0) {
				Object newSelection = myComboBox.getSelectedItem();
				if (newSelection != currentSelection) {
					if (stf != null) {
						synchronized (stf.getFilteringLock()) {
							currentSelection = newSelection;
							if (currentSelection instanceof FiringModelMap)
								setInputMap((FiringModelMap)currentSelection);
							else 
								setInputMap(null);
						}

					}

				}
			}
		});
		
		
		getSupport().addPropertyChangeListener("inputMap",new PropertyChangeListener() {
			@Override
			public void propertyChange(PropertyChangeEvent evt) {
				if (evt.getNewValue() != evt.getOldValue()) {
					if (evt.getNewValue() != null)
						myComboBox.setSelectedItem(evt.getNewValue());
					else
						myComboBox.setSelectedIndex(0);
				}
}
		});
		JPanel customPanel = new JPanel();
        customPanel.setLayout(new BoxLayout(customPanel, BoxLayout.X_AXIS));
        customPanel.setAlignmentX(ParameterBrowserPanel.ALIGNMENT);
        final JLabel jLabel = new JLabel("Input map:");
        jLabel.setFont(jLabel.getFont().deriveFont(10f));
		customPanel.add(jLabel);
        customPanel.add(myComboBox);
        return customPanel;
	}
 
開發者ID:SensorsINI,項目名稱:jaer,代碼行數:56,代碼來源:SpikeSoundSignalHandler.java


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