• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
  • Mikalai Zaikin

Dyanmically adding a Row to JTable

Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Class A extends MasterTable
JComboBox jCType;

String type_arr[]=


JFrame parentFrame;
String columnNames[]=

int columnsize[]= {120,80,190};

Object data[][]={
" ","",new Boolean(false)
public InfoDefn(JFrame parent)
String titleString = "Definition";

parentFrame =parent;
jCType=new JComboBox(type_arr);
ListSelectionModel rowSM = table.getSelectionModel();
rowSM.addListSelectionListener(new RowSelectionListener());


public static void main(String args[])
JFrame test=new JFrame("test");
test.getContentPane().add(new InfoDefn(test),BorderLayout.CENTER);

public void addfunc()
** This Add Null Row
System.out.println("The Value Added is ");

Object nulldata[]=
"","",new Boolean(false)


public void deletefunc()


public void modifyfunc()


public void pastefunc()

public void cutfunc()

public void copyfunc()


Here is the brief descr of the above code
i am displaying a table with first row uneditable
second row is sometimes combobox and third row boolean
I have a master table class which implements the listeners from various
events like popupmenu,enter key.
MasterTable Class has inside it a inner class extending
DefaultTableModel which has the setValueAt function
Mastertable is abstract which will addfunc for adding row
similar call deletefunc for deleting row

Intially my table had no data..
implies it will show one row.
hence we have
Object [][]data = {{"","",new Boolean(false)}};
i add data and then i press enter ...
addfunc is called
my problem starts here
i am using setValueAt in MasterTable ,
where in data[row][col] is used ,
which intially is set to 1 row and 3 column
now i am adding one more row! but data is 2D array
i can't increment size of data array...
so ! i will get Array Index out of BoundExpection
further i want dynamic tooltip...
{tooltip will show complete value in the cell}
so i have added tootip code in setValueAt.
if i comment out the setValueAt code,
i am able to add new row,but
1) boolean column shows false instead of the jcheckbox.
2) How do i add Dynamic Tool Tip...
whatz the work around for this...
Thanks a Lot in Advance

when i press enter i should getj
[ February 09, 2002: Message edited by: vinaya kumar ]
    Bookmark Topic Watch Topic
  • New Topic