super(new BorderLayout());
fontNameList = new JList();
fontNameList.setCellRenderer(new FontNameListCellRenderer());
fontNameList.setVisibleRowCount(7);
// fontNameList.setAutoscrolls(true);
fontNameList.addListSelectionListener(new ListSelectionListener() {
public void valueChanged(ListSelectionEvent e) {
if (!fontNameList.isSelectionEmpty() && !e.getValueIsAdjusting()) {
try {
adjusting = true;
String fn = ((Font) fontNameList.getSelectedValue()).getName();
fontName.setText(fn.equals(AUTOMATIC) ? "Automatic" : fn);
fontName.requestFocus();
} catch (IllegalStateException iee) {
}
adjusting = false;
changeFontBasedOnState();
}
}
});
// Create the font style selection panel
JPanel stylePanel = null;
if (showStyles) {
stylePanel = new JPanel(new GridBagLayout());
stylePanel.setBorder(BorderFactory.createTitledBorder("Font style"));
GridBagConstraints gBC = new GridBagConstraints();
gBC.fill = GridBagConstraints.BOTH;
gBC.anchor = GridBagConstraints.CENTER;
gBC.weighty = 0.0;
gBC.insets = new Insets(2, 2, 2, 2);
ActionListener l = new ActionListener() {
public void actionPerformed(ActionEvent evt) {
changeFontBasedOnState();
}
};
UIUtil.jGridBagAdd(stylePanel, bold = new JCheckBox("Bold"), gBC, GridBagConstraints.REMAINDER);
bold.addActionListener(l);
bold.setMnemonic('b');
UIUtil.jGridBagAdd(stylePanel, italic = new JCheckBox("Italic"), gBC, GridBagConstraints.REMAINDER);
italic.setMnemonic('i');
italic.addActionListener(l);
}
// Create the font size list
// @todo make this more specific to the font. not sure how yet :-)
JPanel sizePanel = null;
if (showSize) {
fontSizeList = new JList(new Integer[] { new Integer(8), new Integer(9), new Integer(10), new Integer(11),
new Integer(12), new Integer(14), new Integer(16), new Integer(18), new Integer(20), new Integer(22),
new Integer(24), new Integer(26), new Integer(28), new Integer(36), new Integer(48), new Integer(72) });