Hello All, I'm trying to create an applet which displays a simple table with no headers or other decoration. Could anyone be so kind as to show me the code for this? All the examples I've found haven't compiled or have included extra features which I don't need. A simple 2 x 2 table with empty cells and no headers is what I'm looking for. Thanks to all in advance...
Code for skaffman:
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class danTeamProject extends Applet implements ActionListener
{
char[][] charValues = new char[10][10];
danTable aTable;
boolean allowUserInput = false;
public void init()
{
Button BtnStart = new Button("Start");
BtnStart.addActionListener((ActionListener)this); //cast
this.add(BtnStart); //add action listener to button
aTable = new danTable();
aTable.setVisible(true);
}
public void paint(Graphics g)
{
g.setColor(Color.black);
aTable.draw(g);
}
public void actionPerformed(ActionEvent arg0)
{
}
}
and
import java.awt.*;
import java.util.*;
import javax.swing.*;
public class danTable extends JPanel
{
public danTable()
{
// Create with initial data
Object[][] cellData = {
{"row1-col1", "row1-col2"},
{"row2-col1", "row2-col2"}};
String[] columnNames = {"col1", "col2"};
JTable table = new JTable(cellData, columnNames);
}
}