⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jcombobox.java

📁 gcc的组建
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
    PopupMenuEvent e = new PopupMenuEvent(this);    for(int i = 0; i < listeners.length; i++)      listeners[i].popupMenuWillBecomeInvisible(e);  }  /**   * Fires a popupMenuWillBecomeVisible() event to all    * <code>PopupMenuListeners</code>.   *   * Note: This method is intended for use by plaf classes only.   */  public void firePopupMenuWillBecomeVisible()  {    PopupMenuListener[] listeners = getPopupMenuListeners();    PopupMenuEvent e = new PopupMenuEvent(this);    for(int i = 0; i < listeners.length; i++)      listeners[i].popupMenuWillBecomeVisible(e);  }  /**   * This method is invoked whenever selected item changes in the combo box's   * data model. It fires ItemEvent and ActionEvent to all registered   * ComboBox's ItemListeners and ActionListeners respectively, indicating   * the change.   */  protected void selectedItemChanged()  {    // Fire ItemEvent to indicated that previously selected item is now    // deselected            if (selectedItemReminder != null)      fireItemStateChanged(new ItemEvent(this, ItemEvent.ITEM_STATE_CHANGED,                                         selectedItemReminder,                                         ItemEvent.DESELECTED));    // Fire ItemEvent to indicate that new item is selected        Object newSelection = getSelectedItem();    if (newSelection != null)      fireItemStateChanged(new ItemEvent(this, ItemEvent.ITEM_STATE_CHANGED,                                         newSelection, ItemEvent.SELECTED));    // Fire Action Event to JComboBox's registered listeners					 				     fireActionEvent();    selectedItemReminder = newSelection;  }  /**   * Returns Object array of size 1 containing currently selected element in   * the JComboBox.   *   * @return Object[] Object array of size 1 containing currently selected   *         element in the JComboBox.   */  public Object[] getSelectedObjects()  {    return new Object[] { getSelectedItem() };  }  /**   * This method handles actionEvents fired by the ComboBoxEditor. It changes   * this JComboBox's selection to the new value currently in the editor and   * hides list of combo box items.   *   * @param e the ActionEvent   */  public void actionPerformed(ActionEvent e)  {    setSelectedItem(((ComboBoxEditor) e.getSource()).getItem());    setPopupVisible(false);  }  /**   * This method selects item in this combo box that matches specified   * specified keyChar and returns true if such item is found. Otherwise   * false is returned.   *   * @param keyChar character indicating which item in the combo box should be   *        selected.   *   * @return boolean true if item corresponding to the specified keyChar   *         exists in the combo box. Otherwise false is returned.   */  public boolean selectWithKeyChar(char keyChar)  {    // FIXME: Need to implement    return false;  }  /**   * The part of implementation of ListDataListener interface. This method is   * invoked when some items where added to the JComboBox's data model.   *   * @param event ListDataEvent describing the change   */  public void intervalAdded(ListDataEvent event)  {    // FIXME: Need to implement    repaint();  }  /**   * The part of implementation of ListDataListener interface. This method is   * invoked when some items where removed from the JComboBox's data model.   *   * @param event ListDataEvent describing the change.   */  public void intervalRemoved(ListDataEvent event)  {    // FIXME: Need to implement    repaint();  }  /**   * The part of implementation of ListDataListener interface. This method is   * invoked when contents of the JComboBox's  data model changed.   *   * @param event ListDataEvent describing the change   */  public void contentsChanged(ListDataEvent event)  {    // if first and last index of the given ListDataEvent are both -1,    // then it indicates that selected item in the combo box data model    // have changed.     if (event.getIndex0() == -1 && event.getIndex1() == -1)      selectedItemChanged();  }  /**   * This method disables or enables JComboBox. If the JComboBox is enabled,   * then user is able to make item choice, otherwise if JComboBox is   * disabled then user is not able to make a selection.   *   * @param enabled if 'enabled' is true then enable JComboBox and disable it   */  public void setEnabled(boolean enabled)  {    boolean oldEnabled = super.isEnabled();    if (enabled != oldEnabled)      {        super.setEnabled(enabled);        firePropertyChange("enabled", oldEnabled, enabled);      }  }  /**   * This method initializes specified ComboBoxEditor to display given item.   *   * @param anEditor ComboBoxEditor to initialize   * @param anItem Item that should displayed in the specified editor   */  public void configureEditor(ComboBoxEditor anEditor, Object anItem)  {    anEditor.setItem(anItem);  }  /**   * This method hides  combo box's popup whenever TAB key is pressed.   *   * @param e The KeyEvent indicating which key was pressed.   */  public void processKeyEvent(KeyEvent e)  {    if (e.getKeyCode() == KeyEvent.VK_TAB)      setPopupVisible(false);    else if (keySelectionManager != null)      {        int i = keySelectionManager.selectionForKey(e.getKeyChar(),                                                    getModel());        if (i >= 0)          setSelectedIndex(i);        else          super.processKeyEvent(e);      }    else      super.processKeyEvent(e);  }  /**   * setKeySelectionManager   *   * @param aManager   */  public void setKeySelectionManager(KeySelectionManager aManager)  {    keySelectionManager = aManager;  }  /**   * getKeySelectionManager   *   * @return JComboBox.KeySelectionManager   */  public KeySelectionManager getKeySelectionManager()  {    return null;  }  /**   * This method returns number of elements in this JComboBox   *   * @return int number of elements in this JComboBox   */  public int getItemCount()  {    return dataModel.getSize();  }  /**   * Returns elements located in the combo box at the given index.   *   * @param index index specifying location of the component to  return.   *   * @return component in the combo box that is located in  the given index.   */  public Object getItemAt(int index)  {    return dataModel.getElementAt(index);  }  /**   * createDefaultKeySelectionManager   *   * @return KeySelectionManager   */  protected KeySelectionManager createDefaultKeySelectionManager()  {    return null;  }  /**   * A string that describes this JComboBox. Normally only used for debugging.   *   * @return A string describing this JComboBox   */  protected String paramString()  {    return "JComboBox";  }  public AccessibleContext getAccessibleContext()  {    if (accessibleContext == null)      accessibleContext = new AccessibleJComboBox();    return accessibleContext;  }  /**   * This methods adds specified ActionListener to this JComboBox.   *   * @param listener to add   */  public void addActionListener(ActionListener listener)  {    listenerList.add(ActionListener.class, listener);  }  /**   * This method removes specified ActionListener from this JComboBox.   *   * @param listener ActionListener   */  public void removeActionListener(ActionListener listener)  {    listenerList.remove(ActionListener.class, listener);  }  /**   * This method returns array of ActionListeners that are registered with   * this JComboBox.   *   * @since 1.4   */  public ActionListener[] getActionListeners()  {    return (ActionListener[]) getListeners(ActionListener.class);  }  /**   * This method registers given ItemListener with this JComboBox   *   * @param listener to remove   */  public void addItemListener(ItemListener listener)  {    listenerList.add(ItemListener.class, listener);  }  /**   * This method unregisters given ItemListener from this JComboBox   *   * @param listener to remove   */  public void removeItemListener(ItemListener listener)  {    listenerList.remove(ItemListener.class, listener);  }  /**   * This method returns array of ItemListeners that are registered with this   * JComboBox.   *   * @since 1.4   */  public ItemListener[] getItemListeners()  {    return (ItemListener[]) getListeners(ItemListener.class);  }  /**   * Adds PopupMenuListener to combo box to listen to the events fired by the   * combo box's popup menu containing its list of items   *   * @param listener to add   */  public void addPopupMenuListener(PopupMenuListener listener)  {    listenerList.add(PopupMenuListener.class, listener);  }  /**   * Removes PopupMenuListener to combo box to listen to the events fired by   * the combo box's popup menu containing its list of items   *   * @param listener to add   */  public void removePopupMenuListener(PopupMenuListener listener)  {    listenerList.remove(PopupMenuListener.class, listener);  }  /**   * Returns array of PopupMenuListeners that are registered with  combo box.   */  public PopupMenuListener[] getPopupMenuListeners()  {    return (PopupMenuListener[]) getListeners(PopupMenuListener.class);  }  /**   * Accessibility support for <code>JComboBox</code>.   */  protected class AccessibleJComboBox extends AccessibleJComponent    implements AccessibleAction, AccessibleSelection  {    private static final long serialVersionUID = 8217828307256675666L;    protected AccessibleJComboBox()    {      // Nothing to do here.    }    public int getAccessibleChildrenCount()    {      return 0;    }    public Accessible getAccessibleChild(int value0)    {      return null;    }    public AccessibleSelection getAccessibleSelection()    {      return null;    }    public Accessible getAccessibleSelection(int value0)    {      return null;    }    public boolean isAccessibleChildSelected(int value0)    {      return false;    }    public AccessibleRole getAccessibleRole()    {      return AccessibleRole.COMBO_BOX;    }    public AccessibleAction getAccessibleAction()    {      return null;    }    public String getAccessibleActionDescription(int value0)    {      return null;    }    public int getAccessibleActionCount()    {      return 0;    }    public boolean doAccessibleAction(int value0)    {      return false;    }    public int getAccessibleSelectionCount()    {      return 0;    }    public void addAccessibleSelection(int value0)    {      // TODO: Implement this properly.    }    public void removeAccessibleSelection(int value0)    {      // TODO: Implement this properly.    }    public void clearAccessibleSelection()    {      // TODO: Implement this properly.    }    public void selectAllAccessibleSelection()    {      // TODO: Implement this properly.    }  }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -