java - how to select an object from a jTable by a click -


i have made class called clients, has simple attributes client_id, client_name , client_age. have programmed small gui netbeans after input data client pressing button displayed in jtable.

the source code adding in jtable is:

for (int i=0;i<customerv.length;i++){                 jtable2.setvalueat(customerv[i].getname(), i, 0); } 

i if click 1 element on jtable able add orders client making using of jbutton. if program in console like:

order order1=new order("1000","41211") 

in first field order id , second order number, if want assign customer 1 like.

c1.assignorder(order1) 

how can using java swing? mean select whole object element click in jtable

  • set instances of clients table model instead of client names (like: jtable2.setvalueat(customerv[i], i, 0);)
  • implement custom renderer render client class needed (e.g. display client's name) , set table. (easier) option override tostring on clients return client's name, or whatever want displayed , not bother renderer.
  • call getvalueat() clients instance bound particular cell in button click handler.

Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -