i've been trying action listener select row mouse right clicks. referred alot of posts , these of them:
heres code:
t1 name of table
public void clicklistener(){ final rowpopup pops = new rowpopup(jtable1); jtable1.addmouselistener(new mouseadapter(){ public void mouseclicked(mouseevent me){ if(swingutilities.isrightmousebutton(me)){ int row = jtable1.rowatpoint( me.getpoint() ); jtable1.changeselection( row, 0, false, false ); pops.getrow(jtable1.getselectedrow()); pops.show(me.getcomponent(),me.getx(),me.gety()); } } }); }
now heres happens.
when right click on table no selected row, exception in thread "awt-eventqueue-0" java.lang.arrayindexoutofboundsexception: -1
error however, when there existing selected row on table, code works , chooses on row right click into.
what want achieve when right click anywhere on rows if there no selected row, part right click selected. ideas how work?
Comments
Post a Comment