So, textOne and textTwo are two text areas. Their Editable feature is set by a boolean named writeMode. In the beginning, it is set to true. So I can type whatever I want into the areas. However, I want to disable this after a while.
Under the Mod menu, there are two choices: Edit Mode (mmEdit menu item) and View Mode (mmView menu item). I thought I can perform this task easily by changing the value of writeMode. But nothing happened. So I googled it a little. I found out that revalidate invalidates and revalidates the components. I tried this, but it did not help. Then I tried repaint() with it. That did not help either.

I also tried revalidating and repainting the textOne and textTwo components. But that failed too.

So, I want to change the Editable feature of these components, but I cannot do it. Can you guide me please?

EDIT: I put some sysout statements to see if the value really changes. It does change.
This frame was created using WindowBuilder.
It does not give me any errors about anything.

February 21st, 2013, 12:52 PM

Norm

Re: TextArea Editable value does not change

Quote:

by changing the value of writeMode.

Then you have to pass its value to the object whose state you want to change by calling the set method.

Values are given to variables as statements are executed. The value is copied to the receiving variable which does not retain a connection to where it got the value from.

February 21st, 2013, 01:29 PM

beer-in-box

Re: TextArea Editable value does not change

Thanks for the reply Norm.

So you say, when I pass a value of a boolean variable to a JTextArea object, it does not get the variable, but it only gets the value of the variable?
Then when I change the value of the boolean variable (writeMode in this case), the JTextArea does not know about it?

February 21st, 2013, 01:33 PM

Norm

Re: TextArea Editable value does not change

Yes. There will not be a connection to the variable that was used to pass the value. The value at the time of the call to the set method was saved and used. No changes to the variable will change the original value that was passed.