i need to access the current text of a JTextField from another method but i get an error here is the code
public Calc(){
JTextField textBox1, textBox2;
setLayout(new FlowLayout());
textBox1 = new JTextField(" Time ");
textBox2 = new JTextField(" Exp ");
JLabel lRate = new JLabel("Rate");
JButton calc = new JButton("Calculate");
textBox1.setSize(100, 10);
textBox2.setSize(100, 10);
calc.setToolTipText("Click to Calculate");
calc.setActionCommand("disable");
calc.setMnemonic(KeyEvent.VK_D);
calc.addActionListener(this);
add(textBox1);
add(textBox2);
add(calc);
add(lRate);
}
public void actionPerformed(ActionEvent e) {
if ("disable".equals(e.getActionCommand())) {
String rate = calcu(textBox1.getText(), textBox2.getText());
lRate.setText(rate);
try{
write(rate);
} catch(IOException e1){System.err.println(e1);}
}
}