How do I make a jTable public?

-1

I need to use a value of one jTable (the table is located in another jFrame, inside the same Package) in another jFrame of Java, for this I am using a getSelectedRow (), so far everything is fine, but the code throws me an error, saying that: "jTable has private access in ...." Apparently the only thing I need is to make the table go from being private to public, but I do not know how to do it ... By the way, I'm using netbeans;)

    
asked by Ariel.Malone 29.11.2017 в 21:14
source

1 answer

1
First of all we must check how you are creating the jTable, to be able to share information between forms you must invoke one instance of the active form and pass a copy to the other form and the jTable should be a public class variable (or private with its respective getter () and setter () preferably) and there if you could use it

public class FormA{

public jTable tabla;

//constructor vacio
public formA(){
}

}

public class FormB{

public FormB(){
FormA formulario = new FormA();
//acá ahora puedes usar formulario.tabla y obtener toda la data que //necesites
}

}
    
answered by 29.11.2017 / 21:59
source