我想更改 JComboBox 的字体大小。但是,只有未选择的项目会发生变化,就像那样:
https://imgur.com/a/WnnyPA6
所以我希望所选项目也加粗。
我做了一个像这样的自定义组合框类:
public class CustomComboBox extends JLabel implements ListCellRenderer {
public Component getListCellRendererComponent(
JList list,
Object value,
int index,
boolean isSelected,
boolean cellHasFocus) {
JLabel label = new JLabel(){
public Dimension getPreferredSize(){
return new Dimension(200, 80);
}
};
label.setText(String.valueOf(value));
label.setFont(new Font("Serif", Font.BOLD, 30));
return label;
}
}
慕森卡
料青山看我应如是
相关分类