test table
This commit is contained in:
@@ -2,6 +2,7 @@ package de.darkress.pic16f84sim;
|
|||||||
|
|
||||||
import de.darkress.pic16f84sim.commands.Command;
|
import de.darkress.pic16f84sim.commands.Command;
|
||||||
import de.darkress.pic16f84sim.decoder.CommandDecoder;
|
import de.darkress.pic16f84sim.decoder.CommandDecoder;
|
||||||
|
import de.darkress.pic16f84sim.gui.SramTable;
|
||||||
import de.darkress.pic16f84sim.microcontroller.Memory;
|
import de.darkress.pic16f84sim.microcontroller.Memory;
|
||||||
import de.darkress.pic16f84sim.microcontroller.ProgramCounter;
|
import de.darkress.pic16f84sim.microcontroller.ProgramCounter;
|
||||||
|
|
||||||
@@ -19,5 +20,7 @@ class Main
|
|||||||
{
|
{
|
||||||
program.get(ProgramCounter.getPc()).execute();
|
program.get(ProgramCounter.getPc()).execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SramTable.table();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
45
de/darkress/pic16f84sim/gui/SramTable.java
Normal file
45
de/darkress/pic16f84sim/gui/SramTable.java
Normal file
@@ -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]);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user