1
0
mirror of https://github.com/DanilaFe/abacus synced 2024-12-23 16:00:09 -08:00

Tidy Window class with more explicit variable names and private vars.

This commit is contained in:
Danila Fedorin 2017-07-25 21:13:18 -07:00
parent 734256fac1
commit ee63eb270e

View File

@ -4,60 +4,77 @@ import javax.swing.*;
import java.awt.*; import java.awt.*;
public class Window extends JFrame { public class Window extends JFrame {
private String history; private String history;
private String lastOutput; private String lastOutput;
private JPanel outputPanel;
private JTextArea lastOutputArea;
private JTextArea historyArea;
private JScrollPane historyAreaScroll;
private JPanel inputPanel;
private JTextField inputField;
private JButton inputEnterButton;
private JPanel sidePanel;
private JPanel numberSystemPanel;
private JComboBox<String> numberSystemList;
private JButton functionSelectButton;
private JPanel functionSelectPanel;
private JComboBox<String> functionList;
public Window() { public Window() {
super(); super();
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (InstantiationException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (UnsupportedLookAndFeelException e) {
e.printStackTrace();
}
//JFrame super= new JFrame();
//ImageIcon check = new ImageIcon(".\\Window Images\\Untitled.png");
String check = "Enter";
JButton checkButton = new JButton(check);
JTextField inputBox = new JTextField();
history = ""; history = "";
JTextArea historyBox = new JTextArea(history); lastOutput = "";
JScrollPane scrollHistoryBox = new JScrollPane(historyBox);
JTextArea outputBox = new JTextArea(lastOutput); setSize(640, 480);
JPanel output=new JPanel();
output.setLayout(new BorderLayout()); inputField = new JTextField();
output.add(scrollHistoryBox); inputEnterButton = new JButton("Calculate");
output.add(outputBox, BorderLayout.PAGE_END);
JPanel input = new JPanel(); inputPanel = new JPanel();
input.setLayout(new BorderLayout()); inputPanel.setLayout(new BorderLayout());
input.add(inputBox); inputPanel.add(inputField);
input.add(checkButton, BorderLayout.LINE_END); inputPanel.add(inputEnterButton, BorderLayout.LINE_END);
super.add(output);
JPanel custom = new JPanel(); historyArea = new JTextArea(history);
JPanel numCustom = new JPanel(); historyAreaScroll = new JScrollPane(historyArea);
JPanel funCustom = new JPanel(); lastOutputArea = new JTextArea(lastOutput);
custom.setLayout(new BorderLayout()); lastOutputArea.setEditable(false);
numCustom.setLayout(new BorderLayout()); lastOutputArea.setText(":)");
funCustom.setLayout(new BorderLayout());
JTextArea numLabel = new JTextArea("Number Type:"); outputPanel = new JPanel();
JTextArea funLabel = new JTextArea("Functions:"); outputPanel.setLayout(new BorderLayout());
JComboBox<String> numList = new JComboBox(); outputPanel.add(historyAreaScroll);
JComboBox<String> funList = new JComboBox(); outputPanel.add(lastOutputArea, BorderLayout.PAGE_END);
JButton funCheckButton = new JButton(check);
numCustom.add(numLabel); numberSystemList = new JComboBox<>();
numCustom.add(numList, BorderLayout.PAGE_END);
funCustom.add(funList); numberSystemPanel = new JPanel();
funCustom.add(funCheckButton, BorderLayout.LINE_END); numberSystemPanel.setLayout(new BorderLayout());
funCustom.add(funLabel, BorderLayout.PAGE_START); numberSystemPanel.add(new JLabel("Number Type:"));
custom.add(numCustom); numberSystemPanel.add(numberSystemList, BorderLayout.PAGE_END);
custom.add(funCustom, BorderLayout.PAGE_END);
super.add(custom, BorderLayout.LINE_END); functionList = new JComboBox<>();
super.add(input, BorderLayout.PAGE_END); functionSelectButton = new JButton("Select");
super.setVisible(true);
functionSelectPanel = new JPanel();
functionSelectPanel.setLayout(new BorderLayout());
functionSelectPanel.add(new JLabel("Functions:"));
functionSelectPanel.add(functionList, BorderLayout.LINE_END);
functionSelectPanel.add(functionSelectButton, BorderLayout.LINE_END);
sidePanel = new JPanel();
sidePanel.setLayout(new BorderLayout());
sidePanel.add(numberSystemPanel);
sidePanel.add(functionSelectPanel, BorderLayout.PAGE_END);
add(outputPanel, BorderLayout.CENTER);
add(sidePanel, BorderLayout.EAST);
add(inputPanel, BorderLayout.SOUTH);
} }
} }