+ fontStyle.getSelectedIndex(),
+ (Integer) fontSize.getSelectedItem());
+ FontMetrics fm = getGraphics().getFontMetrics(newFont);
+ double mw = fm.getStringBounds("M", getGraphics()).getWidth();
+ final Rectangle2D iBounds = fm.getStringBounds("I", getGraphics());
+ double iw = iBounds.getWidth();
+ if (mw < 1 || iw < 1)
+ {
+ final String messageKey = iBounds.getHeight() < 1 ? "label.font_doesnt_have_letters_defined"
+ : "label.font_too_small";
+ JOptionPane.showInternalMessageDialog(this,
+ MessageManager.getString(messageKey),
+ MessageManager.getString("label.invalid_font"),
+ JOptionPane.WARNING_MESSAGE);
+ /*
+ * Restore the changed value - note this will reinvoke this method via the
+ * ActionListener, but now validation should pass
+ */
+ if (lastSelected.getSize() != (Integer) fontSize.getSelectedItem()) // autoboxing
+ {
+ fontSize.setSelectedItem(lastSelected.getSize());
+ }
+ if (!lastSelected.getName().equals(
+ fontName.getSelectedItem().toString()))
+ {
+ fontName.setSelectedItem(lastSelected.getName());
+ }
+ if (lastSelected.getStyle() != fontStyle.getSelectedIndex())
+ {
+ fontStyle.setSelectedIndex(lastSelected.getStyle());
+ }
+ if (lastSelMono != monospaced.isSelected())
+ {
+ monospaced.setSelected(lastSelMono);
+ }
+ return;
+ }