From fc853e3c385e32591ceac07070d37932fcf87941 Mon Sep 17 00:00:00 2001 From: Jim Procter Date: Tue, 4 Jun 2013 11:50:19 +0100 Subject: [PATCH] JAL-1307 patch to squash number format exceptions when pressing return --- src/jalview/appletgui/SeqPanel.java | 22 +++++++++++++--------- src/jalview/gui/SeqPanel.java | 19 ++++++++++++------- 2 files changed, 25 insertions(+), 16 deletions(-) diff --git a/src/jalview/appletgui/SeqPanel.java b/src/jalview/appletgui/SeqPanel.java index 5238750..ac01e2f 100644 --- a/src/jalview/appletgui/SeqPanel.java +++ b/src/jalview/appletgui/SeqPanel.java @@ -342,31 +342,35 @@ public class SeqPanel extends Panel implements MouseMotionListener, keyboardNo1.append(value); } } - int getKeyboardNo1() { - if (keyboardNo1 == null) - return 1; - else + try { + if (keyboardNo1 != null) { int value = Integer.parseInt(keyboardNo1.toString()); keyboardNo1 = null; return value; } + } catch (Exception x) + {} + keyboardNo1 = null; + return 1; } int getKeyboardNo2() { - if (keyboardNo2 == null) - return 1; - else - { + try { + if (keyboardNo2!=null){ int value = Integer.parseInt(keyboardNo2.toString()); keyboardNo2 = null; return value; } + } catch (Exception x) + {} + keyboardNo2 = null; + return 1; } - + void setStatusMessage(SequenceI sequence, int res, int seq) { StringBuffer text = new StringBuffer("Sequence " + (seq + 1) + " ID: " diff --git a/src/jalview/gui/SeqPanel.java b/src/jalview/gui/SeqPanel.java index 3095c47..9c3d557 100644 --- a/src/jalview/gui/SeqPanel.java +++ b/src/jalview/gui/SeqPanel.java @@ -518,26 +518,31 @@ public class SeqPanel extends JPanel implements MouseListener, int getKeyboardNo1() { - if (keyboardNo1 == null) - return 1; - else + try { + if (keyboardNo1 != null) { int value = Integer.parseInt(keyboardNo1.toString()); keyboardNo1 = null; return value; } + } catch (Exception x) + {} + keyboardNo1 = null; + return 1; } int getKeyboardNo2() { - if (keyboardNo2 == null) - return 1; - else - { + try { + if (keyboardNo2!=null){ int value = Integer.parseInt(keyboardNo2.toString()); keyboardNo2 = null; return value; } + } catch (Exception x) + {} + keyboardNo2 = null; + return 1; } /** -- 1.7.10.2