mirror of
https://github.com/DanilaFe/abacus
synced 2024-12-23 16:00:09 -08:00
Comment and clean up the Window class.
This commit is contained in:
parent
1b788c0a46
commit
49f6f2d21e
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue
Block a user