Hi all,
here is another very special behaviour of the ListComboBox that differs from JComboBox and many others.
Given a FontUiResource, ListComboBox.setFont() will ignore it while others do.
[code]import java.awt.Font;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.text.StyleContext;
import com.jidesoft.combobox.ListComboBox;
import com.jidesoft.swing.JideComboBox;
public class ComboBoxDemo_setFont_DifferentComboBoxes {
public static void main(String[] args) {
JFrame frame = new JFrame("ComboBoxes setFont Example");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Font myFont = StyleContext.getDefaultStyleContext().getFont("Snap ITC", 0, 12);
String[] items = new String[] { "Option 1", "Option 2", "Option 3" };
// Uses font
JComboBox<String> jComboBox = new JComboBox<String>(items);
jComboBox.setEditable(false);
jComboBox.setFont(myFont);
// Uses font
JideComboBox jideComboBox = new JideComboBox(items);
jideComboBox.setEditable(false);
jideComboBox.setFont(myFont);
// Does not use font
ListComboBox listComboBox = new ListComboBox(items);
listComboBox.setEditable(false);
listComboBox.setFont(myFont);
JPanel panel = new JPanel();
panel.add(jComboBox);
panel.add(jideComboBox);
panel.add(listComboBox);
frame.getContentPane().add(panel);
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
}
[code]