codice:import java.awt.*; import javax.swing.text.JTextComponent; import javax.swing.*; public class Panel extends JPanel { private JTextField a,b; private JLabel l,l1; private JButton b1; private String nome,cognome; public Panel(){ a=new JTextField(); l=new JLabel("NOME:"); l1=new JLabel("COGNOME:"); b=new JTextField(); this.setLayout(null); l.setBounds(20, 20, 100, 30); a.setBounds(120,20,200,30); l1.setBounds(20, 80, 100, 30); b.setBounds(120,80,200,30); add(a); add(b); add(l1); add(l); nome =a.getText(); cognome=b.getText(); JOptionPane.showMessageDialog(null, "premi FINITO quando hai fatto"); b1=new JButton("FINITO"); b1.setBounds(20, 150, 100, 60); add(b1); System.out.println(""+nome+""+cognome); b1.addActionListener(new Listener(b1,nome,cognome)); } }
se provo a stampare le stringhe nome e cognome, il risultato è sempre lo
stesso, sono vuote.
Qualcuno sa dirmi il perché ???
grazie