我是一名 Java 初学者,我正在使用 Eclipse 创建一个简单的应用程序,其中包含一个SpringLayout
和一个按钮。我称该按钮为“btnTABLE”,这是它的actionPerformed
代码:
btnTABLE.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
String[] columnNames = {"First Name",
"Last Name",
"Sport",
"# of Years",
"Vegetarian"};
Object[][] data = {
{"Kathy", "Smith",
"Snowboarding", new Integer(5), new Boolean(false)},
{"John", "Doe",
"Rowing", new Integer(3), new Boolean(true)},
{"Sue", "Black",
"Knitting", new Integer(2), new Boolean(false)},
{"Jane", "White",
"Speed reading", new Integer(20), new Boolean(true)},
{"Joe", "Brown",
"Pool", new Integer(10), new Boolean(false)}
};
JTable table = new JTable(data, columnNames);
JScrollPane scrollPane = new JScrollPane(table);
table.setFillsViewportHeight(true);
}
});
但是当我点击那个按钮时,表格没有出现。