I am trying to convert an object (selected item on jList1) to a string but it is returning null.
I have tried:
Object object1 = jList1.getSelectedValue();
String string1 = object.toString();
&
String string1 = jList1.getSelectedValue().toString();
But they are both returning null for me, is there something I am doing wrong?
This is what happens when button1 is pressed:
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
Object object1 = jList1.getSelectedValue();
String string1 = object1.toString();
System.out.println(string1)
}
Sorted this myself, not sure what was wrong but I copied the GUI and most of the code (apart from that section causing problems) to a new project re-wrote that part and it worked.