public class Clase { private TextField cajaDeTexto = null; //Otras variables miembro ... ... ... public Clase() { //Constructor (Aquí inicializas todos los componentes graficos) cajaDeTexto = new JTextField(); ... ...Aqui siguen mas declaraciones de componentes } //Declaracion de metodos getters y setters public void setTextCajaDeTexto(String text) { cajaDeTexto.setText(text); } public String getTextoCajaDeTexto() { return cajaDeTexto.getText(); } //Mas metodos getters y setter, para cada miembro de la clase}//En otra clasepublic class Clase_2 { private Clase objeto = new Clase(); //Creamos un objeto de la clase "Clase" para //obtener acceso a los métodos getters y setters. Los cuales tienen acceso a las variables miembro. public void hacerAlgo() { objeto.setTextCajaDeTexto("Este texto se pasara al campo de texto ;)"); } public void hacerOtraCosa() { String textoCapturado = objeto.getTextoCajaDeTexto(); }}
private ClaseB objeto = new ClaseB();public void onItemClick(AdapterView<?> av, View v, int position, long id) { HashMap<String, String> entry = data.get(position); Intent browserAction = new Intent(Intent.ACTION_VIEW, Uri.parse(entry.get(DATA_LINK))); objeto.setTextCajaDeTexto(entry.get(DATA_LINK)); } }); }
private EditText CajaDeTexto;public void setTextCajaDeTexto(String text) { CajaDeTexto.setText(text); }