mirror of
https://github.com/sethm/symon.git
synced 2024-06-01 08:41:32 +00:00
Cleanup and Bug Fixes
- Fixed a bug that left View menu items checked after the associated windows closed. - Cleaned up UI init code for several components.
This commit is contained in:
parent
933b09827a
commit
3636e78435
|
@ -36,9 +36,7 @@ import com.loomcom.symon.ui.Console;
|
|||
import javax.swing.*;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.*;
|
||||
import java.io.*;
|
||||
import java.util.Observable;
|
||||
import java.util.Observer;
|
||||
|
@ -170,10 +168,6 @@ public class Simulator implements Observer {
|
|||
mainWindow.setResizable(false);
|
||||
mainWindow.getContentPane().setLayout(new BorderLayout());
|
||||
|
||||
// The Menu
|
||||
menuBar = new SimulatorMenu();
|
||||
mainWindow.setJMenuBar(menuBar);
|
||||
|
||||
// UI components used for I/O.
|
||||
this.console = new com.loomcom.symon.ui.Console(80, 25, DEFAULT_FONT);
|
||||
this.statusPane = new StatusPanel();
|
||||
|
@ -239,6 +233,11 @@ public class Simulator implements Observer {
|
|||
|
||||
mainWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
|
||||
// The Menu. This comes last, because it relies on other components having
|
||||
// already been initialized.
|
||||
menuBar = new SimulatorMenu();
|
||||
mainWindow.setJMenuBar(menuBar);
|
||||
|
||||
console.requestFocus();
|
||||
|
||||
mainWindow.pack();
|
||||
|
@ -719,10 +718,24 @@ public class Simulator implements Observer {
|
|||
makeFontSizeMenuItem(20, fontSubMenu, fontSizeGroup);
|
||||
viewMenu.add(fontSubMenu);
|
||||
|
||||
JRadioButtonMenuItem showTraceLog = new JRadioButtonMenuItem(new ToggleTraceWindowAction());
|
||||
final JCheckBoxMenuItem showTraceLog = new JCheckBoxMenuItem(new ToggleTraceWindowAction());
|
||||
// Un-check the menu item if the user closes the window directly
|
||||
traceLog.addWindowListener(new WindowAdapter() {
|
||||
@Override
|
||||
public void windowClosing(WindowEvent e) {
|
||||
showTraceLog.setSelected(false);
|
||||
}
|
||||
});
|
||||
viewMenu.add(showTraceLog);
|
||||
|
||||
JRadioButtonMenuItem showMemoryTable = new JRadioButtonMenuItem(new ToggleMemoryWindowAction());
|
||||
final JCheckBoxMenuItem showMemoryTable = new JCheckBoxMenuItem(new ToggleMemoryWindowAction());
|
||||
// Un-check the menu item if the user closes the window directly
|
||||
memoryWindow.addWindowListener(new WindowAdapter() {
|
||||
@Override
|
||||
public void windowClosing(WindowEvent e) {
|
||||
showMemoryTable.setSelected(false);
|
||||
}
|
||||
});
|
||||
viewMenu.add(showMemoryTable);
|
||||
|
||||
add(viewMenu);
|
||||
|
@ -731,7 +744,7 @@ public class Simulator implements Observer {
|
|||
private void makeFontSizeMenuItem(int size, JMenu fontSubMenu, ButtonGroup group) {
|
||||
Action action = new SetFontAction(size);
|
||||
|
||||
JRadioButtonMenuItem item = new JRadioButtonMenuItem(action);
|
||||
JCheckBoxMenuItem item = new JCheckBoxMenuItem(action);
|
||||
item.setSelected(size == DEFAULT_FONT_SIZE);
|
||||
fontSubMenu.add(item);
|
||||
group.add(item);
|
||||
|
|
|
@ -45,11 +45,11 @@ public class MemoryWindow extends JFrame implements ActionListener {
|
|||
private JTable memoryTable;
|
||||
private JTextField pageNumberTextField;
|
||||
|
||||
private static final Dimension MINIMUM_SIZE = new Dimension(400, 450);
|
||||
private static final Dimension MINIMUM_SIZE = new Dimension(380, 580);
|
||||
|
||||
public MemoryWindow(Bus bus) {
|
||||
this.memoryTableModel = new MemoryTableModel(bus);
|
||||
this.createUi();
|
||||
createUi();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -48,7 +48,8 @@ public class PreferencesDialog extends Observable implements Preferences {
|
|||
|
||||
public PreferencesDialog(Frame parent, boolean modal) {
|
||||
this.dialog = new JDialog(parent, modal);
|
||||
initComponents();
|
||||
|
||||
createUi();
|
||||
updateUi();
|
||||
}
|
||||
|
||||
|
@ -59,7 +60,7 @@ public class PreferencesDialog extends Observable implements Preferences {
|
|||
/**
|
||||
* TODO: Validation of input.
|
||||
*/
|
||||
private void initComponents() {
|
||||
private void createUi() {
|
||||
dialog.setTitle("Preferences");
|
||||
Container contents = dialog.getContentPane();
|
||||
|
||||
|
|
|
@ -34,29 +34,29 @@ import java.awt.*;
|
|||
*/
|
||||
public class StatusPanel extends JPanel {
|
||||
|
||||
private final ImageIcon carryOn;
|
||||
private final ImageIcon carryOff;
|
||||
private final ImageIcon zeroOn;
|
||||
private final ImageIcon zeroOff;
|
||||
private final ImageIcon irqOn;
|
||||
private final ImageIcon irqOff;
|
||||
private final ImageIcon decimalOn;
|
||||
private final ImageIcon decimalOff;
|
||||
private final ImageIcon breakOn;
|
||||
private final ImageIcon breakOff;
|
||||
private final ImageIcon overflowOn;
|
||||
private final ImageIcon overflowOff;
|
||||
private final ImageIcon negativeOn;
|
||||
private final ImageIcon negativeOff;
|
||||
private ImageIcon carryOn;
|
||||
private ImageIcon carryOff;
|
||||
private ImageIcon zeroOn;
|
||||
private ImageIcon zeroOff;
|
||||
private ImageIcon irqOn;
|
||||
private ImageIcon irqOff;
|
||||
private ImageIcon decimalOn;
|
||||
private ImageIcon decimalOff;
|
||||
private ImageIcon breakOn;
|
||||
private ImageIcon breakOff;
|
||||
private ImageIcon overflowOn;
|
||||
private ImageIcon overflowOff;
|
||||
private ImageIcon negativeOn;
|
||||
private ImageIcon negativeOff;
|
||||
|
||||
private final JLabel statusFlagsLabel;
|
||||
private final JLabel carryFlagLabel;
|
||||
private final JLabel zeroFlagLabel;
|
||||
private final JLabel irqDisableFlagLabel;
|
||||
private final JLabel decimalModeFlagLabel;
|
||||
private final JLabel breakFlagLabel;
|
||||
private final JLabel overflowFlagLabel;
|
||||
private final JLabel negativeFlagLabel;
|
||||
private JLabel statusFlagsLabel;
|
||||
private JLabel carryFlagLabel;
|
||||
private JLabel zeroFlagLabel;
|
||||
private JLabel irqDisableFlagLabel;
|
||||
private JLabel decimalModeFlagLabel;
|
||||
private JLabel breakFlagLabel;
|
||||
private JLabel overflowFlagLabel;
|
||||
private JLabel negativeFlagLabel;
|
||||
|
||||
private JTextField opcodeField;
|
||||
private JTextField pcField;
|
||||
|
@ -65,12 +65,12 @@ public class StatusPanel extends JPanel {
|
|||
private JTextField xField;
|
||||
private JTextField yField;
|
||||
|
||||
private final JLabel opcodeLabel;
|
||||
private final JLabel pcLabel;
|
||||
private final JLabel spLabel;
|
||||
private final JLabel aLabel;
|
||||
private final JLabel xLabel;
|
||||
private final JLabel yLabel;
|
||||
private JLabel opcodeLabel;
|
||||
private JLabel pcLabel;
|
||||
private JLabel spLabel;
|
||||
private JLabel aLabel;
|
||||
private JLabel xLabel;
|
||||
private JLabel yLabel;
|
||||
|
||||
private static final int EMPTY_BORDER = 10;
|
||||
private static final Border LABEL_BORDER = BorderFactory.createEmptyBorder(0, 5, 0, 0);
|
||||
|
@ -80,7 +80,10 @@ public class StatusPanel extends JPanel {
|
|||
|
||||
public StatusPanel() {
|
||||
super();
|
||||
createUi();
|
||||
}
|
||||
|
||||
private void createUi() {
|
||||
Border emptyBorder = BorderFactory.createEmptyBorder(EMPTY_BORDER, EMPTY_BORDER,
|
||||
EMPTY_BORDER, EMPTY_BORDER);
|
||||
Border etchedBorder = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED);
|
||||
|
|
|
@ -34,10 +34,9 @@ import java.awt.*;
|
|||
* This frame displays a trace of CPU execution. The most recent <code>TRACE_LENGTH</code> lines
|
||||
* are captured in a buffer and rendered to the JFrame's main text area upon request.
|
||||
*/
|
||||
public class TraceLog {
|
||||
public class TraceLog extends JFrame {
|
||||
|
||||
private FifoRingBuffer<Cpu.CpuState> traceLog;
|
||||
private JFrame traceLogFrame;
|
||||
private JTextArea traceLogTextArea;
|
||||
|
||||
private static final Dimension MIN_SIZE = new Dimension(320, 200);
|
||||
|
@ -46,13 +45,12 @@ public class TraceLog {
|
|||
|
||||
public TraceLog() {
|
||||
traceLog = new FifoRingBuffer<Cpu.CpuState>(MAX_LOG_LENGTH);
|
||||
traceLogFrame = new JFrame();
|
||||
traceLogFrame.setMinimumSize(MIN_SIZE);
|
||||
traceLogFrame.setPreferredSize(PREFERRED_SIZE);
|
||||
traceLogFrame.setResizable(true);
|
||||
traceLogFrame.setTitle("Trace Log");
|
||||
setMinimumSize(MIN_SIZE);
|
||||
setPreferredSize(PREFERRED_SIZE);
|
||||
setResizable(true);
|
||||
setTitle("Trace Log");
|
||||
|
||||
traceLogFrame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
|
||||
setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
|
||||
|
||||
traceLogTextArea = new JTextArea();
|
||||
traceLogTextArea.setFont(new Font(Font.MONOSPACED, Font.BOLD, 12));
|
||||
|
@ -60,9 +58,8 @@ public class TraceLog {
|
|||
|
||||
JScrollPane scrollableView = new JScrollPane(traceLogTextArea);
|
||||
|
||||
traceLogFrame.getContentPane().add(scrollableView);
|
||||
traceLogFrame.pack();
|
||||
// Don't show the frame. That action is controlled by the Simulator.
|
||||
getContentPane().add(scrollableView);
|
||||
pack();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -110,20 +107,4 @@ public class TraceLog {
|
|||
traceLogTextArea.setEnabled(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the Trace Log window is currently visible.
|
||||
* @return ture if the Trace Log window is currently visible.
|
||||
*/
|
||||
public boolean isVisible() {
|
||||
return traceLogFrame.isVisible();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the visibility of the Trace Log window.
|
||||
*
|
||||
* @param b True to make the Trace Log window visible, false to hide it.
|
||||
*/
|
||||
public void setVisible(boolean b) {
|
||||
traceLogFrame.setVisible(b);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user