JTable(A few more queries )  
Author Message
hellbent4u





PostPosted: 2006-4-5 18:25:00 Top

java-programmer, JTable(A few more queries ) I had a couple of more queries -

1) how to prevent swapping of the columns as in, by default the columns
in the JTable are not fixed in terms of their placement. They can be
very well swapped with one another. I want to prevent this.

2) Also after feeding the JTable with the data in database, i want to
be keep one row always empty so that a row can be inserted. It's like
we have in MS-Access.

hope i was clear in explaining the query properly.

Thanx,
Ankur

 
IchBin





PostPosted: 2006-4-9 14:53:00 Top

java-programmer >> JTable(A few more queries ) email***@***.com wrote:
> I had a couple of more queries -
>
> 1) how to prevent swapping of the columns as in, by default the columns
> in the JTable are not fixed in terms of their placement. They can be
> very well swapped with one another. I want to prevent this.
>
> 2) Also after feeding the JTable with the data in database, i want to
> be keep one row always empty so that a row can be inserted. It's like
> we have in MS-Access.
>
> hope i was clear in explaining the query properly.
>
> Thanx,
> Ankur
>


1 - To prevent swapping columns:

jTable.getTableHeader().setReorderingAllowed(false);

2 - Once you have loaded the data from that database just insert a blank
row[?]. Either using a Vector or Object.

Object[] yourRowData = {" "," "," ",.....};

yourTableModel.addRow(Object[] yourRowData[]);

Vector yourRowData;

yourTableModel.addRow(Vector yourRowData);



Thanks in Advance...
IchBin, Pocono Lake, Pa, USA
http://weconsultants.servebeer.com/JHackerAppManager
__________________________________________________________________________

'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor, Regular Guy (1952-)
 
IchBin





PostPosted: 2006-4-9 15:00:00 Top

java-programmer >> JTable(A few more queries ) email***@***.com wrote:
> I had a couple of more queries -
>
> 1) how to prevent swapping of the columns as in, by default the columns
> in the JTable are not fixed in terms of their placement. They can be
> very well swapped with one another. I want to prevent this.
>
> 2) Also after feeding the JTable with the data in database, i want to
> be keep one row always empty so that a row can be inserted. It's like
> we have in MS-Access.
>
> hope i was clear in explaining the query properly.
>
> Thanx,
> Ankur
>

- To prevent table columns swapping use this:

yourJTable.getTableHeader().setReorderingAllowed(false);

- Just to append a blank row at the end: You can use either a
Vector or an an Object:

Object[] yourRowData = {"","","",....}

yourTableModel.addRow( yourRowData )

Thanks in Advance...
IchBin, Pocono Lake, Pa, USA
http://weconsultants.servebeer.com/JHackerAppManager
__________________________________________________________________________

'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor, Regular Guy (1952-)