本文整理匯總了Java中javax.swing.JComboBox.setFocusable方法的典型用法代碼示例。如果您正苦於以下問題:Java JComboBox.setFocusable方法的具體用法?Java JComboBox.setFocusable怎麽用?Java JComboBox.setFocusable使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.swing.JComboBox
的用法示例。
在下文中一共展示了JComboBox.setFocusable方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getLabelComboBox
import javax.swing.JComboBox; //導入方法依賴的package包/類
/** Returns the combo box for the label in the given type graph. */
private JComboBox<TypeLabel> getLabelComboBox(TypeGraph typeGraph) {
final JComboBox<TypeLabel> result = new JComboBox<>();
result.setFocusable(false);
result.setRenderer(new DefaultListCellRenderer() {
@SuppressWarnings("rawtypes")
@Override
public Component getListCellRendererComponent(JList list, Object value, int index,
boolean isSelected, boolean cellHasFocus) {
if (value instanceof TypeLabel) {
value = HTMLConverter.HTML_TAG.on(((TypeLabel) value).toLine().toHTMLString());
}
return super.getListCellRendererComponent(list,
value,
index,
isSelected,
cellHasFocus);
}
});
for (TypeLabel label : sortLabels(typeGraph.getLabels())) {
if (!label.isDataType() && label != TypeLabel.NODE) {
result.addItem(label);
}
}
return result;
}
示例2: getNewTypeCombobox
import javax.swing.JComboBox; //導入方法依賴的package包/類
/** Returns the combobox for the new label's type. */
private JComboBox<String> getNewTypeCombobox() {
if (this.newTypeChoice == null) {
final JComboBox<String> result = this.newTypeChoice = new JComboBox<>();
for (EdgeRole kind : EdgeRole.values()) {
result.addItem(kind.getDescription(true));
}
result.setSelectedIndex(EdgeRole.getIndex(getOldLabel().getRole()));
result.setEnabled(true);
result.setFocusable(false);
result.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
Font font = getNewField().getFont();
int fontProperty;
switch (EdgeRole.getRole(result.getSelectedIndex())) {
case NODE_TYPE:
fontProperty = Font.BOLD;
break;
case FLAG:
fontProperty = Font.ITALIC;
break;
default:
fontProperty = Font.PLAIN;
}
font = font.deriveFont(fontProperty);
getNewField().setFont(font);
setReplaceEnabled();
}
});
}
return this.newTypeChoice;
}