This commit is contained in:
@@ -37,15 +37,13 @@ public class Calculator extends JFrame implements KeyListener {
|
|||||||
private static final String PREF_ALWAYS_ON_TOP = "alwaysOnTop";
|
private static final String PREF_ALWAYS_ON_TOP = "alwaysOnTop";
|
||||||
public static final Preferences prefs = Preferences.userRoot().node(PREF_NODE_NAME);
|
public static final Preferences prefs = Preferences.userRoot().node(PREF_NODE_NAME);
|
||||||
public static String APPLICATION_VERSION = "1.0.0pre";
|
public static String APPLICATION_VERSION = "1.0.0pre";
|
||||||
private JPanel contentPane;
|
private JTextField display;
|
||||||
private JTextField display;
|
|
||||||
private String operand1;
|
private String operand1;
|
||||||
private String operator;
|
private String operator;
|
||||||
private String operand2;
|
private String operand2;
|
||||||
protected boolean resultVisible;
|
protected boolean resultVisible;
|
||||||
protected double result;
|
protected double result;
|
||||||
private JComboBox<String> modeselect;
|
private final CalculatorHistory history;
|
||||||
private final CalculatorHistory history;
|
|
||||||
private final List<String> undoStack = new ArrayList<>();
|
private final List<String> undoStack = new ArrayList<>();
|
||||||
private int undoIndex = -1;
|
private int undoIndex = -1;
|
||||||
|
|
||||||
@@ -113,11 +111,12 @@ public class Calculator extends JFrame implements KeyListener {
|
|||||||
setFocusable(true);
|
setFocusable(true);
|
||||||
addKeyListener(this);
|
addKeyListener(this);
|
||||||
|
|
||||||
contentPane = new JPanel();
|
JPanel contentPane = new JPanel();
|
||||||
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||||
setContentPane(contentPane);
|
setContentPane(contentPane);
|
||||||
|
|
||||||
display = new JTextField();
|
display = new JTextField();
|
||||||
|
display.setFocusable(false);
|
||||||
display.setEditable(false);
|
display.setEditable(false);
|
||||||
display.setFont(new Font("Segoe UI", Font.PLAIN, 22));
|
display.setFont(new Font("Segoe UI", Font.PLAIN, 22));
|
||||||
display.setColumns(10);
|
display.setColumns(10);
|
||||||
@@ -194,6 +193,11 @@ public class Calculator extends JFrame implements KeyListener {
|
|||||||
JMenuItem preferencesm = new JMenuItem("Preferences");
|
JMenuItem preferencesm = new JMenuItem("Preferences");
|
||||||
preferencesm.setMnemonic('P');
|
preferencesm.setMnemonic('P');
|
||||||
preferencesm.addActionListener(e -> PreferencesAction());
|
preferencesm.addActionListener(e -> PreferencesAction());
|
||||||
|
undo.addActionListener(e -> undoAction());
|
||||||
|
redo.addActionListener(e -> redoAction());
|
||||||
|
cut.addActionListener(e -> cutAction());
|
||||||
|
copy.addActionListener(e -> copyAction());
|
||||||
|
paste.addActionListener(e -> pasteAction());
|
||||||
|
|
||||||
edit.add(undo);
|
edit.add(undo);
|
||||||
edit.add(redo);
|
edit.add(redo);
|
||||||
@@ -214,7 +218,7 @@ public class Calculator extends JFrame implements KeyListener {
|
|||||||
setJMenuBar(menubar);
|
setJMenuBar(menubar);
|
||||||
|
|
||||||
String[] modes = new String[]{"Standard", "Scientific", "Data calculation"};
|
String[] modes = new String[]{"Standard", "Scientific", "Data calculation"};
|
||||||
modeselect = new JComboBox<>(modes);
|
JComboBox<String> modeselect = new JComboBox<>(modes);
|
||||||
modeselect.addActionListener(new ActionListener() {
|
modeselect.addActionListener(new ActionListener() {
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
|||||||
Reference in New Issue
Block a user