本文整理汇总了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;
}