Results 1 to 2 of 2
- 12-12-2009, 12:11 PM #1
Member
- Join Date
- Oct 2009
- Posts
- 88
- Rep Power
- 0
Complet details of jtable and renderer
Hello user based on my search on JTable i am posting this thread, If any correction in this post please reply.
JTable is one of the difficult component in swings.
Creating a JTable
JTable jt=new JTable();
The above create code create jtable.
Adding ScrollPane to table
JScrollPane jsb=new JScrollPane(jt);
Creating a Default Table Model
DefaultTableModel dt=new DefaultTableModel( new Object[][] , new Object[] {" Column Name1 ", ".....", "Column nth name"});
jt.setModel(dt);
Setting Number of rows
we cant set no.of rows to using jtable.
First get the table model and set number of rows
jt.getModel().setRowCount(n); //n is any integer
these are the simple task on jtable.
Add a component to jtable column model
For add a component to jtable column we should use ediotors/ renders
i am explaining using jcombobox.
first get the column model
TableColumnModel tcm=JTable.getColumnModel();
Then use Editor
tcm.getColumn(nth column).setCellEditor(new DefaultCellEditor(jcombobox));
in the similar way we can add diffrent components in jtable column.
The above procuder will create a jcombobox in nth column in every row of nth column.
if we need to add diffrent components in single column in diffrent rows use cell render.Last edited by anilkumar_vist; 12-12-2009 at 02:17 PM.
-
On first glance, this appears wrong:
Better:Java Code://Adding ScrollPane to table JScrollPane jsb=new JScrollPane(); jsb.add(jt);
orJava Code://Adding ScrollPane to table JScrollPane jsb=new JScrollPane(jt); //jsb.add(jt);
The JScrollPane tutorial and API will explain all this.Java Code://Adding ScrollPane to table JScrollPane jsb=new JScrollPane(); jsb.getViewport.add(jt);
So, rather than have us grunge through your other bits of code and such, why not tell us exactly where you're having problems.
Similar Threads
-
what is and how works the first ?, example.com/details?page=4
By lse123 in forum JavaServer Pages (JSP) and JSTLReplies: 4Last Post: 10-29-2009, 02:18 PM -
jtable cell renderer
By ankitmcgill in forum New To JavaReplies: 2Last Post: 05-22-2009, 01:08 AM -
socket details
By rob in forum Advanced JavaReplies: 8Last Post: 03-03-2009, 02:33 PM -
how to use renderer in JTable
By sunilpatel28 in forum Advanced JavaReplies: 0Last Post: 12-09-2008, 08:01 AM -
WAR issue,please see the details
By milindvijayshah@gmail.com in forum Advanced JavaReplies: 0Last Post: 07-25-2008, 10:51 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks