46 lines
1.2 KiB
Java
46 lines
1.2 KiB
Java
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]);
|
|
}
|
|
}
|