| Method from javax.swing.plaf.basic.BasicComboBoxUI$Handler Detail: |
public void actionPerformed(ActionEvent evt) {
Object item = comboBox.getEditor().getItem();
if (item != null) {
if(!comboBox.isPopupVisible() && !item.equals(comboBox.getSelectedItem())) {
comboBox.setSelectedItem(comboBox.getEditor().getItem());
}
ActionMap am = comboBox.getActionMap();
if (am != null) {
Action action = am.get("enterPressed");
if (action != null) {
action.actionPerformed(new ActionEvent(comboBox, evt.getID(),
evt.getActionCommand(),
evt.getModifiers()));
}
}
}
}
|
public void addLayoutComponent(String name,
Component comp) {
}
|
public void contentsChanged(ListDataEvent e) {
if ( !(e.getIndex0() == -1 && e.getIndex1() == -1) ) {
isMinimumSizeDirty = true;
comboBox.revalidate();
}
// set the editor with the selected item since this
// is the event handler for a selected item change.
if (comboBox.isEditable() && editor != null) {
comboBox.configureEditor( comboBox.getEditor(),
comboBox.getSelectedItem() );
}
isDisplaySizeDirty = true;
comboBox.repaint();
}
|
public void focusGained(FocusEvent e) {
ComboBoxEditor comboBoxEditor = comboBox.getEditor();
if ( (comboBoxEditor != null) &&
(e.getSource() == comboBoxEditor.getEditorComponent()) ) {
return;
}
hasFocus = true;
comboBox.repaint();
if (comboBox.isEditable() && editor != null) {
editor.requestFocus();
}
}
|
public void focusLost(FocusEvent e) {
ComboBoxEditor editor = comboBox.getEditor();
if ( (editor != null) &&
(e.getSource() == editor.getEditorComponent()) ) {
Object item = editor.getItem();
Object selectedItem = comboBox.getSelectedItem();
if (!e.isTemporary() && item != null &&
!item.equals((selectedItem == null) ? "" : selectedItem )) {
comboBox.actionPerformed
(new ActionEvent(editor, 0, "",
EventQueue.getMostRecentEventTime(), 0));
}
}
hasFocus = false;
if (!e.isTemporary()) {
setPopupVisible(comboBox, false);
}
comboBox.repaint();
}
|
public void intervalAdded(ListDataEvent e) {
contentsChanged( e );
}
|
public void intervalRemoved(ListDataEvent e) {
contentsChanged( e );
}
|
public void keyPressed(KeyEvent e) {
if ( isNavigationKey(e.getKeyCode(), e.getModifiers()) ) {
lastTime = 0L;
} else if ( comboBox.isEnabled() && comboBox.getModel().getSize()!=0 &&
isTypeAheadKey( e ) && e.getKeyChar() != KeyEvent.CHAR_UNDEFINED) {
time = e.getWhen();
if ( comboBox.selectWithKeyChar(e.getKeyChar()) ) {
e.consume();
}
}
}
|
public void keyReleased(KeyEvent e) {
}
|
public void keyTyped(KeyEvent e) {
}
|
public void layoutContainer(Container parent) {
JComboBox cb = (JComboBox)parent;
int width = cb.getWidth();
int height = cb.getHeight();
Insets insets = getInsets();
int buttonSize = height - (insets.top + insets.bottom);
Rectangle cvb;
if ( arrowButton != null ) {
if(BasicGraphicsUtils.isLeftToRight(cb)) {
arrowButton.setBounds( width - (insets.right + buttonSize),
insets.top,
buttonSize, buttonSize);
}
else {
arrowButton.setBounds( insets.left, insets.top,
buttonSize, buttonSize);
}
}
if ( editor != null ) {
cvb = rectangleForCurrentValue();
editor.setBounds(cvb);
}
}
|
public Dimension minimumLayoutSize(Container parent) {
return parent.getMinimumSize();
}
|
public Dimension preferredLayoutSize(Container parent) {
return parent.getPreferredSize();
}
|
public void propertyChange(PropertyChangeEvent e) {
String propertyName = e.getPropertyName();
JComboBox comboBox = (JComboBox)e.getSource();
if ( propertyName == "model" ) {
ComboBoxModel newModel = (ComboBoxModel)e.getNewValue();
ComboBoxModel oldModel = (ComboBoxModel)e.getOldValue();
if ( oldModel != null && listDataListener != null ) {
oldModel.removeListDataListener( listDataListener );
}
if ( newModel != null && listDataListener != null ) {
newModel.addListDataListener( listDataListener );
}
if ( editor != null ) {
comboBox.configureEditor( comboBox.getEditor(), comboBox.getSelectedItem() );
}
isMinimumSizeDirty = true;
isDisplaySizeDirty = true;
comboBox.revalidate();
comboBox.repaint();
}
else if ( propertyName == "editor" && comboBox.isEditable() ) {
addEditor();
comboBox.revalidate();
}
else if ( propertyName == "editable" ) {
if ( comboBox.isEditable() ) {
comboBox.setRequestFocusEnabled( false );
addEditor();
} else {
comboBox.setRequestFocusEnabled( true );
removeEditor();
}
updateToolTipTextForChildren();
comboBox.revalidate();
}
else if ( propertyName == "enabled" ) {
boolean enabled = comboBox.isEnabled();
if ( editor != null )
editor.setEnabled(enabled);
if ( arrowButton != null )
arrowButton.setEnabled(enabled);
comboBox.repaint();
}
else if ( propertyName == "focusable" ) {
boolean focusable = comboBox.isFocusable();
if ( editor != null )
editor.setFocusable(focusable);
if ( arrowButton != null )
arrowButton.setFocusable(focusable);
comboBox.repaint();
}
else if ( propertyName == "maximumRowCount" ) {
if ( isPopupVisible( comboBox ) ) {
setPopupVisible(comboBox, false);
setPopupVisible(comboBox, true);
}
}
else if ( propertyName == "font" ) {
listBox.setFont( comboBox.getFont() );
if ( editor != null ) {
editor.setFont( comboBox.getFont() );
}
isMinimumSizeDirty = true;
comboBox.validate();
}
else if ( propertyName == JComponent.TOOL_TIP_TEXT_KEY ) {
updateToolTipTextForChildren();
}
else if ( propertyName == BasicComboBoxUI.IS_TABLE_CELL_EDITOR ) {
Boolean inTable = (Boolean)e.getNewValue();
isTableCellEditor = inTable.equals(Boolean.TRUE) ? true : false;
}
else if (propertyName == "prototypeDisplayValue") {
isMinimumSizeDirty = true;
isDisplaySizeDirty = true;
comboBox.revalidate();
}
else if (propertyName == "renderer") {
isMinimumSizeDirty = true;
isDisplaySizeDirty = true;
comboBox.revalidate();
}
}
|
public void removeLayoutComponent(Component comp) {
}
|