How to change the location of a JTextArea at run-time?
I am using Swing, I have a JPanel and in it there is a JTextArea and a JButton. I want the JTextArea to move when the button is clicked on. I'm Not really sure how to do the action listener for the button. at the moment the JTextArea only moves once when the button is clicked on, but i want it to move every time the button is clicked on.
this is what i have so far:
moveButton = new JButton("MOVE");
moveButton.setBounds(20, 140, 70, 40);
text = new JTextArea("hello");
text.setBounds(x, 50, 40, 20);
In the actionPerformed method this is what it does:
text.setBounds(x + 50, 50, 40, 20);
any help is greatly appreciated.
Re: How to change the location of a JTextArea at run-time?
What layout are you using? Can you post an SSCCE instead of a disconnected snippet?