From 49f6f2d21ea617236cc3a4b4dce0ba8b65ea3d60 Mon Sep 17 00:00:00 2001 From: Danila Fedorin Date: Wed, 26 Jul 2017 19:10:55 -0700 Subject: [PATCH] Comment and clean up the Window class. --- src/org/nwapw/abacus/window/Window.java | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/org/nwapw/abacus/window/Window.java b/src/org/nwapw/abacus/window/Window.java index 8d35f20..d2d4891 100644 --- a/src/org/nwapw/abacus/window/Window.java +++ b/src/org/nwapw/abacus/window/Window.java @@ -18,18 +18,27 @@ import java.awt.event.MouseEvent; public class Window extends JFrame { private static final String CALC_STRING = "Calculate"; - private static final String SELECT_STRING = "Select"; private static final String SYNTAX_ERR_STRING = "Syntax Error"; private static final String EVAL_ERR_STRING = "Evaluation Error"; private static final String NUMBER_SYSTEM_LABEL = "Number Type:"; private static final String FUNCTION_LABEL = "Functions:"; + /** + * Array of Strings to which the "calculate" button's text + * changes. For instance, in the graph tab, the name will + * be "Graph" and not "Calculate". + */ private static final String[] BUTTON_NAMES = { CALC_STRING, CALC_STRING }; - private static boolean[] BUTTON_ENABLED = { + /** + * Array of booleans that determine whether the input + * field and the input button are enabled at a particular + * index. + */ + private static boolean[] INPUT_ENABLED = { true, false }; @@ -131,6 +140,10 @@ public class Window extends JFrame { inputField.setText(""); }; + /** + * Array of listeners that tell the input button how to behave + * at a given input tab. + */ private ActionListener[] listeners = { evaluateListener, null @@ -205,7 +218,7 @@ public class Window extends JFrame { pane.add("Settings", settingsPanel); pane.addChangeListener(e -> { int selectionIndex = pane.getSelectedIndex(); - boolean enabled = BUTTON_ENABLED[selectionIndex]; + boolean enabled = INPUT_ENABLED[selectionIndex]; ActionListener listener = listeners[selectionIndex]; inputEnterButton.setText(BUTTON_NAMES[selectionIndex]); inputField.setEnabled(enabled);