public FontSelectorDialog(Component comp, Font font) {
//super(JOptionPane.getFrameForComponent(comp),jpicedt.Localizer.currentLocalizer().get("widget.FontSelector"),true); //
super(JOptionPane.getFrameForComponent(comp),Globals.lang("FontSelector"),true); //
JPanel content = new JPanel(new BorderLayout());
content.setBorder(new EmptyBorder(12,12,12,12));
setContentPane(content);
JPanel listPanel = new JPanel(new GridLayout(1,3,6,6));
JPanel familyPanel = createTextFieldAndListPanel(
Globals.lang("Font Family"),
familyField = new JTextField(),
familyList = new JList(getFontList()));
listPanel.add(familyPanel);
String[] sizes = { "9", "10", "12", "14", "16", "18", "24" };
JPanel sizePanel = createTextFieldAndListPanel(
Globals.lang("Font Size"),
sizeField = new JTextField(),
sizeList = new JList(sizes));
listPanel.add(sizePanel);
String[] styles = {PLAIN,BOLD,ITALIC,BOLD_ITALIC};
JPanel stylePanel = createTextFieldAndListPanel(
Globals.lang("Font Style"),
styleField = new JTextField(),
styleList = new JList(styles));
styleField.setEditable(false);
listPanel.add(stylePanel);
familyList.setSelectedValue(font.getFamily(),true);
familyField.setText(font.getFamily());
sizeList.setSelectedValue(String.valueOf(font.getSize()),true);
sizeField.setText(String.valueOf(font.getSize()));
styleList.setSelectedIndex(font.getStyle());
styleField.setText((String)styleList.getSelectedValue());
ListHandler listHandler = new ListHandler();
familyList.addListSelectionListener(listHandler);
sizeList.addListSelectionListener(listHandler);
styleList.addListSelectionListener(listHandler);
content.add(BorderLayout.NORTH,listPanel);
//preview = new JLabel("Font Preview");
/* --------------------------------------------------------
| Experimental addition by Morten Alver. I want to |
| enable antialiasing in the preview field, since I'm |
| working on introducing this in the table view. |
-------------------------------------------------------- */
preview = new JLabel(Globals.lang("Font Preview")) {
private static final long serialVersionUID = -4191591634265068189L;
public void paint(Graphics g) {
Graphics2D g2 = (Graphics2D)g;
g2.setRenderingHint
(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
super.paint(g2);
}
};
preview.setBorder(new TitledBorder(Globals.lang("Font Preview")));
updatePreview();
Dimension prefSize = preview.getPreferredSize();
prefSize.height = 50;
preview.setPreferredSize(prefSize);
content.add(BorderLayout.CENTER,preview);
JPanel buttons = new JPanel();
buttons.setLayout(new BoxLayout(buttons,BoxLayout.X_AXIS));
buttons.setBorder(new EmptyBorder(12,0,0,0));
buttons.add(Box.createGlue());
ok = new JButton(Globals.lang("OK"));
ok.addActionListener(new ActionHandler());
getRootPane().setDefaultButton(ok);