下面列出了javax.swing.JComboBox#getClientProperty ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Override
public void actionPerformed(ActionEvent event) {
String command = event.getActionCommand();
if (COMPARISON.equals(command)) {
JComboBox<?> combo = (JComboBox<?>) event.getSource();
int selectedIndex = combo.getSelectedIndex();
StringCriteria stringCriteria = (StringCriteria) combo.getClientProperty(StringCriteria.class);
if (stringCriteria != null) {
stringCriteria.setType(StringCompareType.values()[selectedIndex]);
notifyActionListeners();
} else {
NumericCriteria numericCriteria = (NumericCriteria) combo.getClientProperty(NumericCriteria.class);
if (numericCriteria != null) {
numericCriteria.setType(NumericCompareType.values()[selectedIndex]);
notifyActionListeners();
}
}
}
}
public MenuToggleButton() {
// install a special client property on the button to prevent it from
// closing of the popup when the down arrow is pressed.
JComboBox box = new JComboBox();
Object preventHide = box.getClientProperty("doNotCancelPopup");
putClientProperty("doNotCancelPopup", preventHide);
}
static boolean isIgnoreSelectionEvents( JComboBox combo ) {
Object res = combo.getClientProperty( "nb.combo.autocomplete.ignoreselection" ); //NOI18N
return res instanceof Boolean && ((Boolean)res).booleanValue();
}
static boolean isAutoCompleteInstalled( JComboBox combo ) {
Object res = combo.getClientProperty( "nb.combo.autocomplete" ); //NOI18N
return res instanceof Boolean && ((Boolean)res).booleanValue();
}
static boolean isIgnoreSelectionEvents( JComboBox combo ) {
Object res = combo.getClientProperty( "nb.combo.autocomplete.ignoreselection" ); //NOI18N
return res instanceof Boolean && ((Boolean)res).booleanValue();
}
static boolean isAutoCompleteInstalled( JComboBox combo ) {
Object res = combo.getClientProperty( "nb.combo.autocomplete" ); //NOI18N
return res instanceof Boolean && ((Boolean)res).booleanValue();
}