user interface - Java- how do I make the cells in a JTable editable? -


i have jtable displayed in gui- currently, when program loads, table empty- showing column headings (there isn't empty table there).

i have button which, when clicked, add new empty row table, underneath column headings. however, although can select each of individual cells added table, cannot type them.

i adding row table using following code:

/*create button, , add actionlistener */ jbutton addbtn = new jbutton("add"); addbtn.addactionlistener(new actionlistener(){     public void actionperformed(actionevent e){      } });  public void actionperformed(actionevent arg0){     system.out.println("add button pressed. ");     defaulttablemodel model = (defaulttablemodel)jentityfiltertable.getmodel();      object[] obj = new object[]{};     model.addrow(obj); } 

this code works- mentioned, whenever click button, new row added table, , can select each individual cell.

what need make selected cell editable? have button ('edit'), want user able click when have selected cell table, , once have clicked it, should able type data cell. i'm not sure how this, , couldn't find online how add functionality button in gui.

any appreciated.

@override public boolean iscelleditable(int row, int col) {      return true;  } 

you may replace true variable may toggle


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -