test table

This commit is contained in:
Darkress
2023-06-07 22:05:38 +02:00
parent 184c49f3ae
commit 7ef8a285e0
2 changed files with 48 additions and 0 deletions

View 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]);
}
}