java - How to insert data into JTable? -
i write code showing strings in table.
but doesnt shown , has no effect.
what problrem?
public pamnel() { initcomponents(); 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)} }; jtable1 = new jtable(data, columnnames); }
edit: add jtable on panel.
in main add panel jframe.
jframe frame = new jframe(); frame.add(new pamnel()); frame.setvisible(true); frame.setsize(600, 600); frame.setdefaultcloseoperation(jframe.exit_on_close);
the table shown data isn't show. row , column of table empty!
you have add jtable parent-component , setvisible().
Comments
Post a Comment