Right in class1 i have a JTable. When the user selects a row i have done coding to return the value displayed in the selected row (column 0). Class1 coding is as follows:
class1
public static string s1;
class1Constructor(){
tableGUI
insertDataInTable
}
mousepressed(){
row = table.getSelectedRow()
Object ob = table.getValueAt(row,0)
s1 = ob.toString()
}
//end class1
This class works fine. When the user selects a row the coding gets the selected value and each time the user selects a different row the getValue is updated.
However what I want is to display this value in a different class.
class2
String s2
class2Constructor(){
s2 = class1.s1
}
//end class2
Also each time the user selects a different row in class1 the string in s2 should also be updated. class2 coding:
class1
public static string s1;
class1Constructor(){
tableGUI
insertDataInTable
}
mousepressed(){
row = table.getSelectedRow()
Object ob = table.getValueAt(row,0)
s1 = ob.toString()
}
//end class1
This class works fine. When the user selects a row the coding gets the selected value and each time the user selects a different row the getValue is updated.
However what I want is to display this value in a different class.
class2
String s2
class2Constructor(){
s2 = class1.s1
}
//end class2
Also each time the user selects a different row in class1 the string in s2 should also be updated. class2 coding: