Em que estou errando? Fiz um programinha só pra tentar entender a funcionalidade de um bean genérico só que não esta dando certo. O programinha deveria mostrar o conteudo digitado em dois JTextfields dentro de uma TextArea pegando os valores que eu setei no meu bean genérico, só que quando eu seto o conteúdo das variáveis que estão no bean e tento mostrá-las na TextArea não aparece nada.Aqui estão os códigos.
public class Cadastro {
String nome, sobrenome;
/**
* Constructor for Cadastro.
*/
public Cadastro() {
super();
}
public static void main(String[] args) {
}
/**
* Returns the nome.
* @return String
*/
public String getNome() {
return nome;
}
/**
* Returns the sobrenome.
* @return String
*/
public String getSobrenome() {
return sobrenome;
}
/**
* Sets the nome.
* @param nome The nome to set
*/
public void setNome(String nome) {
this.nome = nome;
}
/**
* Sets the sobrenome.
* @param sobrenome The sobrenome to set
*/
public void setSobrenome(String sobrenome) {
this.sobrenome = sobrenome;
}
}
public class Tela extends javax.swing.JFrame {
/** Creates new form Tela */
public Tela() {
initComponents();
Cadastro c = new Cadastro();
c.setNome(tnome.getText());
c.setSobrenome(tsobre.getText());
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
private void initComponents() {
lnome = new javax.swing.JLabel();
tnome = new javax.swing.JTextField();
lsobre = new javax.swing.JLabel();
tsobre = new javax.swing.JTextField();
bmostra = new javax.swing.JButton();
text = new javax.swing.JTextArea();
getContentPane().setLayout(null);
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent evt) {
exitForm(evt);
}
});
lnome.setText("Nome:");
getContentPane().add(lnome);
lnome.setBounds(40, 60, 36, 16);
getContentPane().add(tnome);
tnome.setBounds(80, 60, 240, 20);
lsobre.setText("Sobrenome:");
getContentPane().add(lsobre);
lsobre.setBounds(40, 90, 80, 16);
getContentPane().add(tsobre);
tsobre.setBounds(120, 90, 200, 20);
bmostra.setText("Mostrar");
bmostra.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
bmostraActionPerformed(evt);
}
});
getContentPane().add(bmostra);
bmostra.setBounds(40, 170, 81, 26);
text.setBorder(new javax.swing.border.EtchedBorder());
getContentPane().add(text);
text.setBounds(150, 150, 300, 120);
pack();
java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
setSize(new java.awt.Dimension(600, 400));
setLocation((screenSize.width-600)/2,(screenSize.height-400)/2);
}
private void bmostraActionPerformed(java.awt.event.ActionEvent evt) {
// Add your handling code here:
Cadastro c = new Cadastro();
text.setText(c.getNome());
}
/** Exit the Application */
private void exitForm(java.awt.event.WindowEvent evt) {
System.exit(0);
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
new Tela().show();
}
// Variables declaration - do not modify
private javax.swing.JTextArea text;
private javax.swing.JButton bmostra;
private javax.swing.JLabel lsobre;
private javax.swing.JTextField tnome;
private javax.swing.JTextField tsobre;
private javax.swing.JLabel lnome;
// End of variables declaration
}