1
0
mirror of https://github.com/DanilaFe/abacus synced 2024-09-15 19:50:27 -07: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;
public Window(){
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(); private JPanel outputPanel;
//ImageIcon check = new ImageIcon(".\\Window Images\\Untitled.png"); private JTextArea lastOutputArea;
String check = "Enter"; private JTextArea historyArea;
JButton checkButton = new JButton(check); private JScrollPane historyAreaScroll;
JTextField inputBox = new JTextField();
history=""; private JPanel inputPanel;
JTextArea historyBox = new JTextArea(history); private JTextField inputField;
JScrollPane scrollHistoryBox = new JScrollPane(historyBox); private JButton inputEnterButton;
JTextArea outputBox = new JTextArea(lastOutput);
JPanel output=new JPanel(); private JPanel sidePanel;
output.setLayout(new BorderLayout()); private JPanel numberSystemPanel;
output.add(scrollHistoryBox); private JComboBox<String> numberSystemList;
output.add(outputBox, BorderLayout.PAGE_END); private JButton functionSelectButton;
JPanel input = new JPanel(); private JPanel functionSelectPanel;
input.setLayout(new BorderLayout()); private JComboBox<String> functionList;
input.add(inputBox);
input.add(checkButton, BorderLayout.LINE_END); public Window() {
super.add(output); super();
JPanel custom = new JPanel();
JPanel numCustom = new JPanel();
JPanel funCustom = new JPanel(); history = "";
custom.setLayout(new BorderLayout()); lastOutput = "";
numCustom.setLayout(new BorderLayout());
funCustom.setLayout(new BorderLayout()); setSize(640, 480);
JTextArea numLabel = new JTextArea("Number Type:");
JTextArea funLabel = new JTextArea("Functions:"); inputField = new JTextField();
JComboBox<String> numList = new JComboBox(); inputEnterButton = new JButton("Calculate");
JComboBox<String> funList = new JComboBox();
JButton funCheckButton = new JButton(check); inputPanel = new JPanel();
numCustom.add(numLabel); inputPanel.setLayout(new BorderLayout());
numCustom.add(numList, BorderLayout.PAGE_END); inputPanel.add(inputField);
funCustom.add(funList); inputPanel.add(inputEnterButton, BorderLayout.LINE_END);
funCustom.add(funCheckButton, BorderLayout.LINE_END);
funCustom.add(funLabel, BorderLayout.PAGE_START); historyArea = new JTextArea(history);
custom.add(numCustom); historyAreaScroll = new JScrollPane(historyArea);
custom.add(funCustom, BorderLayout.PAGE_END); lastOutputArea = new JTextArea(lastOutput);
super.add(custom, BorderLayout.LINE_END); lastOutputArea.setEditable(false);
super.add(input, BorderLayout.PAGE_END); lastOutputArea.setText(":)");
super.setVisible(true);
outputPanel = new JPanel();
outputPanel.setLayout(new BorderLayout());
outputPanel.add(historyAreaScroll);
outputPanel.add(lastOutputArea, BorderLayout.PAGE_END);
numberSystemList = new JComboBox<>();
numberSystemPanel = new JPanel();
numberSystemPanel.setLayout(new BorderLayout());
numberSystemPanel.add(new JLabel("Number Type:"));
numberSystemPanel.add(numberSystemList, BorderLayout.PAGE_END);
functionList = new JComboBox<>();
functionSelectButton = new JButton("Select");
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);
} }
} }