How to set font attributes in combobox
From: V S Rawat (vsrawat_no_reply__at_hclinfinet.com)
Date: 06/24/04
- Next message: VisionSet: "Re: Why use panels"
- Previous message: V S Rawat: "Why use panels"
- Next in thread: Chris Smith: "Re: How to set font attributes in combobox"
- Reply: Chris Smith: "Re: How to set font attributes in combobox"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 24 Jun 2004 20:43:13 +0530
I could not make head or tail out of sun's tutorial on
combobox renderer. The example given is getting compiled and
running ok, but how to use those things to my program.
relevant lines I have used in my program are given below.
compiler is giving "can't resolve symbol" on setFont line.
and when I am changing that fontname to
normalFont.deriveFont(Font.ITALIC), it is compiling and
running, but the data that was appearing ok previously, is
all appearing blank.
I am moving data in combobox and it is appearing. Just that
its font, size and color is not ok. I want to set font to
some unicode font, size to 18, color to blue.
If possible, I want different fonts, sizes, colors on
different parts of same entry in combobox. something like
set text: (font1, size1, color1) abc (font2, size2, color2) xyz
I have tried <html> as was used on JButtons but that is not
working.
how to do it?
thanks.
-Rawat
------------------
ComboBoxRenderer cbRenderer;
JComboBox ctrlComboBox;
cbRenderer = new ComboBoxRenderer();
ctrlComboBox = new JComboBox();
ctrlComboBox.setRenderer(cbRenderer);
class ComboBoxRenderer extends JLabel implements
ListCellRenderer {
public ComboBoxRenderer() {
}
public Component getListCellRendererComponent(
JList list,
Object value,
int index,
boolean isSelected,
boolean
cellHasFocus) {
setFont("Arial Unicode MS");
return this;
}
}
- Next message: VisionSet: "Re: Why use panels"
- Previous message: V S Rawat: "Why use panels"
- Next in thread: Chris Smith: "Re: How to set font attributes in combobox"
- Reply: Chris Smith: "Re: How to set font attributes in combobox"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]