java界面窗口有表格方法,但窗口没显示,如何调用这个表格方法或是添加到窗口中,使它呈现出来。如图,有窗口,咋么调用print()方法或是还有别的方法让它在窗口中体现出来 非常感谢!!
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JTable;
public class Yard {
private JFrame frame;
private JTable table;
String[] columnNames = { "行号", "代码"}; //用于显示输入测试样例
Object[][] obj = new Object[100][2];// //用于显示输入测试样例
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
qwe window = new qwe();
window.frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the application.
*/
public qwe() {
initialize();
}
/**
* Initialize the contents of the frame.
*/
private void initialize() {
frame = new JFrame();
frame.setBounds(100, 100, 450, 300);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().setLayout(null);
table = new JTable(obj,columnNames);
table.setBounds(68, 58, 178, 136);
frame.getContentPane().add(table);
}