From: gmungoc Date: Wed, 22 Apr 2015 12:21:59 +0000 (+0100) Subject: JAL-1690 fix NPE on Cancel when not in split frame X-Git-Tag: Jalview_2_9~60 X-Git-Url: http://source.jalview.org/gitweb/?p=jalview.git;a=commitdiff_plain;h=af4672ad3ed5b549ac78488e4e0aa9d2cde04ce9 JAL-1690 fix NPE on Cancel when not in split frame --- diff --git a/src/jalview/gui/FontChooser.java b/src/jalview/gui/FontChooser.java index 5e13781..381fbe3 100755 --- a/src/jalview/gui/FontChooser.java +++ b/src/jalview/gui/FontChooser.java @@ -94,8 +94,10 @@ public class FontChooser extends GFontChooser * Enable 'scale protein as cDNA' in a SplitFrame view. The selection is * stored in the ViewStyle of both dna and protein Viewport */ + scaleAsCdna.setEnabled(false); if (ap.av.getCodingComplement() != null) { + scaleAsCdna.setEnabled(true); scaleAsCdna.setVisible(true); scaleAsCdna.setSelected(ap.av.isScaleProteinAsCdna()); } @@ -243,15 +245,19 @@ public class FontChooser extends GFontChooser .getStringBounds("I", getGraphics()).getWidth(); if (mw < 1 || iw < 1) { - fontName.setSelectedItem(lastSelected.getName()); - fontStyle.setSelectedIndex(lastSelStyle); - fontSize.setSelectedItem(lastSelSize); - monospaced.setSelected(lastSelMono); JOptionPane .showInternalMessageDialog( this, MessageManager.getString("label.font_doesnt_have_letters_defined"), MessageManager.getString("label.invalid_font"), JOptionPane.WARNING_MESSAGE); + /* + * Restore previous values - size first to avoid recursive calls to this + * point! + */ + fontSize.setSelectedItem(lastSelSize); + fontName.setSelectedItem(lastSelected.getName()); + fontStyle.setSelectedIndex(lastSelStyle); + monospaced.setSelected(lastSelMono); return; } if (tp != null)