My code is:
import java.awt.*;
import javax.swing.*;
import javax.swing.JTable;
import java.awt.event.*;
public class GUIInterface extends JFrame
{
private final static int NUMBER_OF_STUDENTS = Database.NUMBER_OF_STUDENTS;
GUIInterface()
{
JFrame studentGUI = new JFrame("Student Registration");
studentGUI.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
String[][] transferArray = Program.studentsData;
String[] columnNames = {"First Name", "Last Name", "Address", "Credit Hours"};
JTable studentTable = new JTable(transferArray, columnNames);
studentTable.setOpaque(true);
studentTable.setPreferredScrollableViewportSize(new Dimension(500, 70));
studentTable.setFillsViewportHeight(true);
JScrollPane scrollPane = new JScrollPane(studentTable);
add(scrollPane);
studentGUI.setContentPane(studentTable);
studentGUI.pack();
studentGUI.setVisible(true);
}
}
When it runs, all that shows is in the attached picture. It shows the data I wanted in the table, but ignores the column names completely.
What am I missing?

New Topic/Question
Reply




MultiQuote





|