mirror of
https://github.com/DanilaFe/abacus
synced 2024-12-23 16:00:09 -08:00
Merge branch 'master' of https://github.com/DanilaFe/abacus
This commit is contained in:
commit
56c7b6f15e
|
@ -7,6 +7,7 @@ import org.nwapw.abacus.tree.TreeNode;
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.datatransfer.StringSelection;
|
import java.awt.datatransfer.StringSelection;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
import java.awt.event.MouseAdapter;
|
import java.awt.event.MouseAdapter;
|
||||||
import java.awt.event.MouseEvent;
|
import java.awt.event.MouseEvent;
|
||||||
|
|
||||||
|
@ -119,6 +120,7 @@ public class Window extends JFrame {
|
||||||
history = "";
|
history = "";
|
||||||
lastOutput = "";
|
lastOutput = "";
|
||||||
|
|
||||||
|
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
|
||||||
setSize(640, 480);
|
setSize(640, 480);
|
||||||
|
|
||||||
inputField = new JTextField();
|
inputField = new JTextField();
|
||||||
|
@ -127,7 +129,7 @@ public class Window extends JFrame {
|
||||||
inputPanel = new JPanel();
|
inputPanel = new JPanel();
|
||||||
inputPanel.setLayout(new BorderLayout());
|
inputPanel.setLayout(new BorderLayout());
|
||||||
inputPanel.add(inputField, BorderLayout.CENTER);
|
inputPanel.add(inputField, BorderLayout.CENTER);
|
||||||
inputPanel.add(inputEnterButton, BorderLayout.EAST);
|
inputPanel.add(inputEnterButton, BorderLayout.SOUTH);
|
||||||
|
|
||||||
historyModel = new HistoryTableModel();
|
historyModel = new HistoryTableModel();
|
||||||
historyTable = new JTable(historyModel);
|
historyTable = new JTable(historyModel);
|
||||||
|
@ -165,7 +167,7 @@ public class Window extends JFrame {
|
||||||
add(sidePanel, BorderLayout.EAST);
|
add(sidePanel, BorderLayout.EAST);
|
||||||
add(inputPanel, BorderLayout.SOUTH);
|
add(inputPanel, BorderLayout.SOUTH);
|
||||||
|
|
||||||
inputEnterButton.addActionListener((event) -> {
|
ActionListener actionListener = (event) -> {
|
||||||
TreeNode parsedExpression = TreeNode.fromString(inputField.getText());
|
TreeNode parsedExpression = TreeNode.fromString(inputField.getText());
|
||||||
if(parsedExpression == null){
|
if(parsedExpression == null){
|
||||||
lastOutputArea.setText(SYNTAX_ERR_STRING);
|
lastOutputArea.setText(SYNTAX_ERR_STRING);
|
||||||
|
@ -178,8 +180,9 @@ public class Window extends JFrame {
|
||||||
historyModel.addEntry(new HistoryTableModel.HistoryEntry(inputField.getText(), parsedExpression, lastOutput));
|
historyModel.addEntry(new HistoryTableModel.HistoryEntry(inputField.getText(), parsedExpression, lastOutput));
|
||||||
historyTable.invalidate();
|
historyTable.invalidate();
|
||||||
lastOutputArea.setText(lastOutput);
|
lastOutputArea.setText(lastOutput);
|
||||||
inputField.setText(lastOutput);
|
};
|
||||||
});
|
inputEnterButton.addActionListener(actionListener);
|
||||||
|
inputField.addActionListener(actionListener);
|
||||||
historyTable.addMouseListener(new MouseAdapter() {
|
historyTable.addMouseListener(new MouseAdapter() {
|
||||||
@Override
|
@Override
|
||||||
public void mouseClicked(MouseEvent e) {
|
public void mouseClicked(MouseEvent e) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user