Hi :)
I am Writing a program that takes text from a JTextArea and uses the string to do things upon clicking a button. I used an ActionListener for the button. My problem is that I recieve an empty string when I try to access the text from the JTextArea from another method. I'm sure its a simple solution, but my googleing has gotten me nowhere :(
public class Braille{
private static JTextArea textarea;
public Braille(){
//some code
JTextArea textarea = new JTextArea(36, 40);
JButton button = new JButton("button");
panel.add(textarea);
panel.add(button);
textarea.setText("Test String");
button.addActionListener(this);
//some code
}
public void actionPerformed(ActionEvent event) {
pnt();
}
public static void pnt(){
textarea.getText(); // this is null :(
//some code
}}
Is there a way to use the text from a JTextArea in a different method (I think that's what its called)?
Thx :)