Hello, i want to write a calculator with buttons and a JTextField. I want to use StringTokenizer to separate the two numbers and the operator.
I have tried this:
|
Code:
|
import java.awt.*;
import javax.swing.*;
import java.util.*;
public class Calculator extends JFrame {
StringTokenizer stok = new StringTokenizer(input.getText());
JTextField input = new JTextField();
public Calculator(){
Container c = getContentPane();
setTitle("Calculator by keffie91");
setVisible(true);
setDefaultCloseOperation(EXIT_ON_CLOSE);
}
public static void main(String[] args) {
new Calculator();
}
} |
and like this
|
Code:
|
StringTokenizer stok = new StringTokenizer(input); |
But I get the following error message: illegal forward reference.
I don't know what that mean. Is it even possible to use a JTextField with a StringTokenizer?
I have searched google but notting found.
Thanks keffie91