0

i want to linked JSpinner with JTable. if i want to click a row in JTable, value in JSpinner change with value in that row JTable. I have source code like this :

 void select(){
     try{
        int row = TabelKebutuhan.getSelectedRow();

        txtJumlahButuh.setValue(TabelKebutuhan.getModel().getValueAt(row,0).toString());
        txtJumlahAda.setValue(TabelKebutuhan.getModel().getValueAt(row,1).toString());
    }catch(Exception e){}
}

but, thats source code can't work like i want. so, what the solution for this case?

user3440030
  • 45
  • 1
  • 8
  • What is it doing? What do you want it to do that it's not doing? Can you post a SSCCE? – KathyA. Apr 01 '14 at 15:50
  • what a SSCCE?, created value in JSpinner from JTable – user3440030 Apr 01 '14 at 22:52
  • Check out http://www.sscce.org/ to see what an SSCCE is. (Short Self Contained Compilable Example). And we still don't know what behavior you are seeing and what behavior you want. Please help us to help you! :) – KathyA. Apr 02 '14 at 14:51

1 Answers1

1

Try this :

txtJumlahButuh.setValue(Integer.parseInt((String)TabelKebutuhan.getValueAt(row,0)));
txtJumlahAda.setValue(Integer.parseInt((String)TabelKebutuhan.getValueAt(row,1)));

try replace variable as needed setModel(new javax.swing.SpinnerNumberModel(Integer.parseInt((String) value), 0, 15, 1));

  • Hello and welcome to Stack Overflow! While your answer may be correct, some additional details or explanations of how this works would help future readers in understanding your answer. – xrisk Nov 26 '16 at 04:56