Skip to content

Commit

Permalink
[#314, #342] Fix audio tape GUI
Browse files Browse the repository at this point in the history
  • Loading branch information
vbmacher committed Aug 29, 2023
1 parent 40c8b99 commit 25e2a2a
Show file tree
Hide file tree
Showing 13 changed files with 99 additions and 103 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public void actionPerformed(ActionEvent actionEvent) {
action.accept(actionEvent);
}
});
setIcon(new ImageIcon(getClass().getResource(iconResource)));
setIcon(new ImageIcon(ClassLoader.getSystemResource(iconResource)));
setToolTipText(tooltipText);

setFocusable(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ private void initComponents() {

lblLogo.setBackground(Color.WHITE);
lblLogo.setHorizontalAlignment(SwingConstants.CENTER);
lblLogo.setIcon(new ImageIcon(getClass().getResource("/net/emustudio/application/gui/dialogs/logo.png")));
lblLogo.setIcon(new ImageIcon(ClassLoader.getSystemResource("/net/emustudio/application/gui/dialogs/logo.png")));
lblLogo.setBorder(BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
lblLogo.setDoubleBuffered(true);
lblLogo.setFocusable(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ private void initComponents() {
setResizable(false);

lblPerforming.setFont(lblPerforming.getFont().deriveFont(lblPerforming.getFont().getStyle() | java.awt.Font.BOLD));
lblPerforming.setIcon(new ImageIcon(getClass().getResource("/net/emustudio/application/gui/dialogs/motherboard-icon.gif")));
lblPerforming.setIcon(new ImageIcon(ClassLoader.getSystemResource("/net/emustudio/application/gui/dialogs/motherboard-icon.gif")));
lblPerforming.setText("Running automatic emulation, please wait...");

lblAction.setText("Initializing...");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ private void resizeComponents() {
}

private void initComponents() {
setIconImage(new ImageIcon(getClass().getResource("/net/emustudio/application/gui/favicon16.png")).getImage());
setIconImage(new ImageIcon(ClassLoader.getSystemResource("/net/emustudio/application/gui/favicon16.png")).getImage());

setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,29 +161,29 @@ private void initComponents() {
jToolBar1.setDoubleBuffered(true);

buttonGroup1.add(btnCompiler);
btnCompiler.setIcon(new ImageIcon(getClass().getResource("/net/emustudio/application/gui/dialogs/compile.png")));
btnCompiler.setIcon(new ImageIcon(ClassLoader.getSystemResource("/net/emustudio/application/gui/dialogs/compile.png")));
btnCompiler.setToolTipText("Compiler information");
btnCompiler.setFocusable(false);
btnCompiler.addActionListener(this::btnCompilerActionPerformed);
jToolBar1.add(btnCompiler);

buttonGroup1.add(btnCPU);
btnCPU.setIcon(new ImageIcon(getClass().getResource("/net/emustudio/application/gui/dialogs/cpu.gif")));
btnCPU.setIcon(new ImageIcon(ClassLoader.getSystemResource("/net/emustudio/application/gui/dialogs/cpu.gif")));
btnCPU.setSelected(true);
btnCPU.setToolTipText("CPU information");
btnCPU.setFocusable(false);
btnCPU.addActionListener(this::btnCPUActionPerformed);
jToolBar1.add(btnCPU);

buttonGroup1.add(btnMemory);
btnMemory.setIcon(new ImageIcon(getClass().getResource("/net/emustudio/application/gui/dialogs/ram.gif")));
btnMemory.setIcon(new ImageIcon(ClassLoader.getSystemResource("/net/emustudio/application/gui/dialogs/ram.gif")));
btnMemory.setToolTipText("Memory information");
btnMemory.setFocusable(false);
btnMemory.addActionListener(this::btnMemoryActionPerformed);
jToolBar1.add(btnMemory);

buttonGroup1.add(btnDevice);
btnDevice.setIcon(new ImageIcon(getClass().getResource("/net/emustudio/application/gui/dialogs/device.png")));
btnDevice.setIcon(new ImageIcon(ClassLoader.getSystemResource("/net/emustudio/application/gui/dialogs/device.png")));
btnDevice.setToolTipText("Devices information");
btnDevice.setFocusable(false);
btnDevice.addActionListener(this::btnDeviceActionPerformed);
Expand Down Expand Up @@ -291,7 +291,7 @@ private void initComponents() {
jToolBar2.setOrientation(SwingConstants.VERTICAL);
jToolBar2.setRollover(true);

btnSaveSchema.setIcon(new ImageIcon(getClass().getResource("/net/emustudio/application/gui/dialogs/document-save.png")));
btnSaveSchema.setIcon(new ImageIcon(ClassLoader.getSystemResource("/net/emustudio/application/gui/dialogs/document-save.png")));
btnSaveSchema.setToolTipText("Save schema image");
btnSaveSchema.setFocusable(false);
btnSaveSchema.setHorizontalTextPosition(SwingConstants.CENTER);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class IncludeTest extends AbstractCompilerTest {

@Test
public void testIncludeAndForwardCall() throws Exception {
File includeFile = new File(getClass().getResource("/sample.asm").toURI());
File includeFile = new File(ClassLoader.getSystemResource("/sample.asm").toURI());
compile(
"call sample\n"
+ "include '" + includeFile.getAbsolutePath() + "'\n"
Expand All @@ -36,7 +36,7 @@ public void testIncludeAndForwardCall() throws Exception {

@Test
public void testCallDataInclude() throws Exception {
File includeFile = new File(getClass().getResource("/sample.asm").toURI());
File includeFile = new File(ClassLoader.getSystemResource("/sample.asm").toURI());
compile(
"call sample\n" +
"label: db 'hello'\n" +
Expand All @@ -49,8 +49,8 @@ public void testCallDataInclude() throws Exception {

@Test
public void testDoubleIncludeAndForwardCall() throws Exception {
File first = new File(getClass().getResource("/sample.asm").toURI());
File second = new File(getClass().getResource("/sample2.asm").toURI());
File first = new File(ClassLoader.getSystemResource("/sample.asm").toURI());
File second = new File(ClassLoader.getSystemResource("/sample2.asm").toURI());
compile(
"call sample2\n"
+ "include '" + first.getAbsolutePath() + "'\n"
Expand All @@ -64,7 +64,7 @@ public void testDoubleIncludeAndForwardCall() throws Exception {

@Test
public void testIncludeAndBackwardCall() throws Exception {
File includeFile = new File(getClass().getResource("/sample.asm").toURI());
File includeFile = new File(ClassLoader.getSystemResource("/sample.asm").toURI());
compile(
"include '" + includeFile.getAbsolutePath() + "'\n"
+ "call sample\n"
Expand All @@ -77,8 +77,8 @@ public void testIncludeAndBackwardCall() throws Exception {

@Test
public void testDoubleIncludeAndBackwardCall() throws Exception {
File first = new File(getClass().getResource("/sample.asm").toURI());
File second = new File(getClass().getResource("/sample2.asm").toURI());
File first = new File(ClassLoader.getSystemResource("/sample.asm").toURI());
File second = new File(ClassLoader.getSystemResource("/sample2.asm").toURI());
compile(
"include '" + first.getAbsolutePath() + "'\n"
+ "include '" + second.getAbsolutePath() + "'\n"
Expand All @@ -92,7 +92,7 @@ public void testDoubleIncludeAndBackwardCall() throws Exception {

@Test
public void testIncludeAndJMPafter() throws Exception {
File includeFile = new File(getClass().getResource("/sample.asm").toURI());
File includeFile = new File(ClassLoader.getSystemResource("/sample.asm").toURI());
compile(
"jmp next\n"
+ "include '" + includeFile.getAbsolutePath() + "'\n"
Expand All @@ -107,8 +107,8 @@ public void testIncludeAndJMPafter() throws Exception {

@Test
public void testDoubleIncludeAndJMPafter() throws Exception {
File first = new File(getClass().getResource("/sample.asm").toURI());
File second = new File(getClass().getResource("/sample2.asm").toURI());
File first = new File(ClassLoader.getSystemResource("/sample.asm").toURI());
File second = new File(ClassLoader.getSystemResource("/sample2.asm").toURI());
compile(
"jmp next\n"
+ "include '" + first.getAbsolutePath() + "'\n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ public class PseudoOrgTest extends AbstractCompilerTest {

@Before
public void setup() {
sampleFile = Objects.requireNonNull(getClass().getResource("/sample.asm")).getFile();
sample2File = Objects.requireNonNull(getClass().getResource("/sample2.asm")).getFile();
sampleFile = Objects.requireNonNull(ClassLoader.getSystemResource("/sample.asm")).getFile();
sample2File = Objects.requireNonNull(ClassLoader.getSystemResource("/sample2.asm")).getFile();
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class IncludeTest extends AbstractCompilerTest {

@Test
public void testIncludeAndForwardCall() throws Exception {
File includeFile = new File(getClass().getResource("/sample.asm").toURI());
File includeFile = new File(ClassLoader.getSystemResource("/sample.asm").toURI());
compile(
"call sample\n"
+ "include '" + includeFile.getAbsolutePath() + "'\n"
Expand All @@ -39,7 +39,7 @@ public void testIncludeAndForwardCall() throws Exception {

@Test
public void testCallDataInclude() throws Exception {
File includeFile = new File(getClass().getResource("/sample.asm").toURI());
File includeFile = new File(ClassLoader.getSystemResource("/sample.asm").toURI());
compile(
"call sample\n" +
"label: db 'hello'\n" +
Expand All @@ -52,8 +52,8 @@ public void testCallDataInclude() throws Exception {

@Test
public void testDoubleIncludeAndForwardCall() throws Exception {
File first = new File(getClass().getResource("/sample.asm").toURI());
File second = new File(getClass().getResource("/sample2.asm").toURI());
File first = new File(ClassLoader.getSystemResource("/sample.asm").toURI());
File second = new File(ClassLoader.getSystemResource("/sample2.asm").toURI());
compile(
"call sample2\n"
+ "include '" + first.getAbsolutePath() + "'\n"
Expand All @@ -67,7 +67,7 @@ public void testDoubleIncludeAndForwardCall() throws Exception {

@Test
public void testIncludeAndBackwardCall() throws Exception {
File includeFile = new File(getClass().getResource("/sample.asm").toURI());
File includeFile = new File(ClassLoader.getSystemResource("/sample.asm").toURI());
compile(
"include '" + includeFile.getAbsolutePath() + "'\n"
+ "call sample\n"
Expand All @@ -80,8 +80,8 @@ public void testIncludeAndBackwardCall() throws Exception {

@Test
public void testDoubleIncludeAndBackwardCall() throws Exception {
File first = new File(getClass().getResource("/sample.asm").toURI());
File second = new File(getClass().getResource("/sample2.asm").toURI());
File first = new File(ClassLoader.getSystemResource("/sample.asm").toURI());
File second = new File(ClassLoader.getSystemResource("/sample2.asm").toURI());
compile(
"include '" + first.getAbsolutePath() + "'\n"
+ "include '" + second.getAbsolutePath() + "'\n"
Expand All @@ -95,7 +95,7 @@ public void testDoubleIncludeAndBackwardCall() throws Exception {

@Test
public void testIncludeAndJMPafter() throws Exception {
File includeFile = new File(getClass().getResource("/sample.asm").toURI());
File includeFile = new File(ClassLoader.getSystemResource("/sample.asm").toURI());
compile(
"jp next\n"
+ "include '" + includeFile.getAbsolutePath() + "'\n"
Expand All @@ -110,8 +110,8 @@ public void testIncludeAndJMPafter() throws Exception {

@Test
public void testDoubleIncludeAndJMPafter() throws Exception {
File first = new File(getClass().getResource("/sample.asm").toURI());
File second = new File(getClass().getResource("/sample2.asm").toURI());
File first = new File(ClassLoader.getSystemResource("/sample.asm").toURI());
File second = new File(ClassLoader.getSystemResource("/sample2.asm").toURI());
compile(
"jp next\n"
+ "include '" + first.getAbsolutePath() + "'\n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ public class PseudoOrgTest extends AbstractCompilerTest {

@Before
public void setup() {
sampleFile = Objects.requireNonNull(getClass().getResource("/sample.asm")).getFile();
sample2File = Objects.requireNonNull(getClass().getResource("/sample2.asm")).getFile();
sampleFile = Objects.requireNonNull(ClassLoader.getSystemResource("/sample.asm")).getFile();
sample2File = Objects.requireNonNull(ClassLoader.getSystemResource("/sample2.asm")).getFile();
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ private void initComponents() {
lstTape.setCellRenderer(new TapeCellRenderer(tapeContext));
scrollTape.setViewportView(lstTape);

btnAddFirst.setIcon(new ImageIcon(getClass().getResource("/net/emustudio/plugins/device/abstracttape/gui/go-up.png")));
btnAddFirst.setIcon(new ImageIcon(ClassLoader.getSystemResource("/net/emustudio/plugins/device/abstracttape/gui/go-up.png")));
btnAddFirst.addActionListener(e -> dialogs
.readString("Symbol value:", "Add symbol (on top)")
.map(TapeSymbol::guess)
Expand All @@ -99,7 +99,7 @@ private void initComponents() {
}
}));

btnAddLast.setIcon(new ImageIcon(getClass().getResource("/net/emustudio/plugins/device/abstracttape/gui/go-down.png")));
btnAddLast.setIcon(new ImageIcon(ClassLoader.getSystemResource("/net/emustudio/plugins/device/abstracttape/gui/go-down.png")));
btnAddLast.addActionListener(e -> dialogs
.readString("Symbol value:", "Add symbol (on bottom)")
.map(TapeSymbol::guess)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public void setDisplayFont(DisplayFont displayFont) {

private void initComponents() {
JLabel lblBack = new JLabel();
ImageIcon backgroundImage = new ImageIcon(getClass().getResource(BACKGROUND_IMAGE));
ImageIcon backgroundImage = new ImageIcon(ClassLoader.getSystemResource(BACKGROUND_IMAGE));

setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
setTitle("LSI ADM-3A");
Expand All @@ -89,13 +89,13 @@ private void initComponents() {

JButton btnClear = new JButton();
btnClear.setFocusable(false);
btnClear.setIcon(new ImageIcon(getClass().getResource(CLEAR_SCREEN_ICON)));
btnClear.setIcon(new ImageIcon(ClassLoader.getSystemResource(CLEAR_SCREEN_ICON)));
btnClear.setToolTipText("Clear screen");
btnClear.addActionListener(e -> clearScreen());

JButton btnRoll = new JButton();
btnRoll.setFocusable(false);
btnRoll.setIcon(new ImageIcon(getClass().getResource(ROLL_LINE_ICON)));
btnRoll.setIcon(new ImageIcon(ClassLoader.getSystemResource(ROLL_LINE_ICON)));
btnRoll.setToolTipText("Roll line up");
btnRoll.addActionListener(e -> rollLine());

Expand Down
Loading

0 comments on commit 25e2a2a

Please sign in to comment.