为甚么不显示table的标题?有什么问题存在,请各位大大指教,谢谢import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTable;
import javax.swing.table.JTableHeader;public class tableExercise extends JFrame { private JPanel jContentPane = null; private JTable table = null; private JTableHeader tblheader = null; Object[][] content = { { "george", "Linux", new Integer(34) },
{ "Bill", "Unix", new Integer(30) },
{ "Sam", "Windows", new Integer(32) }, }; Object[] title = { "姓名", "课程", "年龄" }; /**
 * This is the default constructor
 */
public tableExercise() {
super();
initialize();
} /**
 * This method initializes this
 * 
 * @return void
 */
private void initialize() {
this.setSize(300, 200);
this.setContentPane(getJContentPane());
this.setTitle("表");
} /**
 * This method initializes jContentPane
 * 
 * @return javax.swing.JPanel
 */
private JPanel getJContentPane() {
if (jContentPane == null) {
jContentPane = new JPanel();
jContentPane.setLayout(null);
jContentPane.add(getTable(), null);
jContentPane.add(gettblHeader(), null);
}
return jContentPane;
} /**
 * This method initializes jTable
 * 
 * @return javax.swing.JTable
 */
private JTable getTable() {
if (table == null) {
table = new JTable(content, title);
table.setBounds(new java.awt.Rectangle(20, 20, 250, 120));
}
return table;
} private JTableHeader gettblHeader() {
if (tblheader == null) {
tblheader = table.getTableHeader();
}
return tblheader;
}
}

解决方案 »

  1.   

    //Overload.java  for ChenSinan
    public class Overload{ public static void display()
    { System.out.println( "\nThis is the default message;" ); } public static void display(int num)
    { System.out.println("Integer value is: "+ num); } public static void display(char ch)
    { System.out.println("Char value is: "+ ch);  } public static void display(String string)
    { System.out.println("Char value is: "+ string);  } public static void main(String argv[]){
        try{
    display();  //print the default message

    int integer = 233;
    display(integer);   //print ... char ch = 'c';
    display(ch); String string1 = "string";
    display(string1); String string2 = "0001";
    display(string2);
        } catch (Exception e) {
    System.out.println("error happened in main() when involve display();");};
    }}