Adding rows in JTable

How t to add rows one by one in JTable
[45 byte] By [aruntsa] at [2007-10-3 10:00:45]
# 1
if you are using DefaultTableModel for table in your code then you can try out this Table.getModel().addRow(Object[] rowData)
Prashant_SDNa at 2007-7-15 5:19:23 > top of Java-index,Desktop,Core GUI APIs...
# 2
thanks, how to give color for a particular row
aruntsa at 2007-7-15 5:19:23 > top of Java-index,Desktop,Core GUI APIs...
# 3

write your TableRenderer using DefaultTableCellRenderer

and do your code in method

public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column)

{

// check your condition here

if (row==1)

{

// what color do u want

setBackground(Color.GREEN);

}

}

in which you can set back ground to row

null

Message was edited by:

Prashant_SDN

Prashant_SDNa at 2007-7-15 5:19:23 > top of Java-index,Desktop,Core GUI APIs...
# 4

> write your TableRenderer using

> DefaultTableCellRenderer

> and do your code in method

>

> public Component

> getTableCellRendererComponent(JTable table, Object

> value, boolean isSelected, boolean hasFocus, int

> row, int column)

>{

> k your condition here

> if (row==1)

> {

> // what color do u want

> setBackground(Color.GREEN);

> }

> }

> h you can set back ground to row

>

> null

>

> Message was edited by:

> Prashant_SDN

thank u

aruntsa at 2007-7-15 5:19:23 > top of Java-index,Desktop,Core GUI APIs...
# 5
HOw to add JCheckBox in JTable
aruntsa at 2007-7-15 5:19:23 > top of Java-index,Desktop,Core GUI APIs...
# 6
> HOw to add JCheckBox in JTable Did you read the API? It contains a like to the Swing tutorial on "How to Use Tables', which contains a working example.
camickra at 2007-7-15 5:19:23 > top of Java-index,Desktop,Core GUI APIs...