From 7ef8a285e0fcc661ecdcf9393ccf8052f937e8e5 Mon Sep 17 00:00:00 2001 From: Darkress <30271678+DarkressX@users.noreply.github.com> Date: Wed, 7 Jun 2023 22:05:38 +0200 Subject: [PATCH] test table --- de/darkress/pic16f84sim/Main.java | 3 ++ de/darkress/pic16f84sim/gui/SramTable.java | 45 ++++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 de/darkress/pic16f84sim/gui/SramTable.java diff --git a/de/darkress/pic16f84sim/Main.java b/de/darkress/pic16f84sim/Main.java index 229b7e7..442d860 100644 --- a/de/darkress/pic16f84sim/Main.java +++ b/de/darkress/pic16f84sim/Main.java @@ -2,6 +2,7 @@ package de.darkress.pic16f84sim; import de.darkress.pic16f84sim.commands.Command; import de.darkress.pic16f84sim.decoder.CommandDecoder; +import de.darkress.pic16f84sim.gui.SramTable; import de.darkress.pic16f84sim.microcontroller.Memory; import de.darkress.pic16f84sim.microcontroller.ProgramCounter; @@ -19,5 +20,7 @@ class Main { program.get(ProgramCounter.getPc()).execute(); } + + SramTable.table(); } } \ No newline at end of file diff --git a/de/darkress/pic16f84sim/gui/SramTable.java b/de/darkress/pic16f84sim/gui/SramTable.java new file mode 100644 index 0000000..270d220 --- /dev/null +++ b/de/darkress/pic16f84sim/gui/SramTable.java @@ -0,0 +1,45 @@ +package de.darkress.pic16f84sim.gui; + +import javax.swing.*; + +public class SramTable +{ + public static void table() { + int rows = 16; + int columns = 8; + int count = 0; + // Create the data for the table + Object[][] data = new Object[rows][columns]; + for (int i = 0; i < rows; i++) { + for (int j = 0; j < columns; j++) { + data[i][j] = count; + count++; + } + } + + // Create the column names + Object[] columnNames = new Object[columns]; + for (int j = 0; j < columns; j++) { + columnNames[j] = "Column " + (j + 1); + } + + // Create the JTable + JTable table = new JTable(data, columnNames); + + // Create a scroll pane and add the table to it + JScrollPane scrollPane = new JScrollPane(table); + + // Create a panel and add the scroll pane to it + JPanel panel = new JPanel(); + panel.add(scrollPane); + + // Create a frame and add the panel to it + JFrame frame = new JFrame("Table Example"); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + frame.add(panel); + frame.pack(); + frame.setVisible(true); + + System.out.println(data[15][7]); + } +}