ResourceBundle bundle = ResourceBundle.getBundle(FontChooserUI.class
.getName()
+ "RB");
// FIRST PANEL with Font list
fontPanel = new JPanel(new PercentLayout(PercentLayout.VERTICAL, 2));
fontPanel.add(label = new JLabel(bundle
.getString("FontChooserUI.fontLabel")));
fontPanel.add(fontField = new JTextField(25));
fontField.setEditable(false);
fontPanel.add(new JScrollPane(fontList = new JList()), "*");
label.setLabelFor(fontList);
label.setDisplayedMnemonic(bundle.getString(
"FontChooserUI.fontLabel.mnemonic").charAt(0));
fontList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
String[] fontFamilies = chooser.getModel().getFontFamilies(null);
fontList.setListData(fontFamilies);
// SECOND PANEL with Bold, Italic, Charset
JPanel fontEffectPanel = new JPanel(new PercentLayout(
PercentLayout.VERTICAL, 2));
fontEffectPanel.add(label = new JLabel(bundle
.getString("FontChooserUI.styleLabel")));
fontEffectPanel.add(fontEffectField = new JTextField(10));
fontEffectField.setEditable(false);
fontEffectPanel.add(new JScrollPane(fontEffectList = new JList()), "*");
label.setLabelFor(fontEffectList);
label.setDisplayedMnemonic(bundle.getString(
"FontChooserUI.styleLabel.mnemonic").charAt(0));
fontEffectList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
FontStyle[] fontStyles = new FontStyle[]{
new FontStyle(Font.PLAIN, bundle.getString("FontChooserUI.style.plain")),
new FontStyle(Font.BOLD, bundle.getString("FontChooserUI.style.bold")),
new FontStyle(Font.ITALIC, bundle
.getString("FontChooserUI.style.italic")),
new FontStyle(Font.BOLD | Font.ITALIC, bundle
.getString("FontChooserUI.style.bolditalic")),};
fontEffectList.setListData(fontStyles);
// The SIZE PANEL
fontSizePanel = new JPanel(new PercentLayout(PercentLayout.VERTICAL, 2));
fontSizePanel.add(label = new JLabel(bundle
.getString("FontChooserUI.sizeLabel")));
label.setDisplayedMnemonic(bundle.getString(
"FontChooserUI.sizeLabel.mnemonic").charAt(0));
fontSizePanel.add(fontSizeField = new JTextField(5));
label.setLabelFor(fontSizeField);
fontSizePanel.add(new JScrollPane(fontSizeList = new JList()), "*");
int[] defaultFontSizes = chooser.getModel().getDefaultSizes();
String[] sizes = new String[defaultFontSizes.length];
for (int i = 0, c = sizes.length; i < c; i++) {
sizes[i] = String.valueOf(defaultFontSizes[i]);
}
fontSizeList.setPrototypeCellValue("012345");
fontSizeList.setListData(sizes);
fontSizeList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
fontSizeList.setVisibleRowCount(2);
chooser.setLayout(LookAndFeelTweaks.createBorderLayout());
JPanel panel = new JPanel();
panel.setLayout(LookAndFeelTweaks.createHorizontalPercentLayout());
panel.add(fontPanel, "*");
panel.add(fontEffectPanel);
panel.add(fontSizePanel);
previewPanel = new JTextArea();
previewPanel.setText(chooser.getModel().getPreviewMessage(null));
JScrollPane scroll = new JScrollPane(previewPanel);
JSplitPane split = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
split.setBorder(null);
split.setTopComponent(panel);
split.setBottomComponent(scroll);
split.setDividerLocation(0.5);
split.setOneTouchExpandable(true);
chooser.add("Center", split);
// allow the split pane to completely hide the top panel
panel.setMinimumSize(new Dimension(0, 0));
JPanel charSetPanel = new JPanel(new PercentLayout(
PercentLayout.HORIZONTAL, 2));
label = new JLabel("CHARSET");
label.setHorizontalAlignment(JLabel.RIGHT);
charSetPanel.add(label, "*");