Gui refreshing problem.

Hi friends/experts.

I have a problem. I'm working on a little app, which has a text area in it. Now, my problem is that when I write something to the text area, and then  when I highlite it, the whole screen (the app plus the icons and desktop) begin flashing.
I think the reason is because I'm not refreshing or I'm doing something wrong.

To declare the area I do it like so:
     textarea = new TextArea(15,45);


          layout.putConstraint(SpringLayout.WEST, textarea, 100, SpringLayout.WEST, pane);
          layout.putConstraint(SpringLayout.NORTH, textarea, 50,SpringLayout.NORTH, pane);
And to write to it I just write  textarea.setText("mehmehmeh");

 Have you got an idea how can I fix this?

Thank you.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

The above code is not obviously wrong, but should not be practised
from the event thread without returning from it.
What does the rest of your program look like?

Where's the declaration for :  textarea, pane, layout ?
kibkidAuthor Commented:
Well that is pretty much the content of a method.
Which I call when I want to display something to that area; usually an input error.

The pane and the textarea are declared globally. Yes I know I shouldn't declare stuff globaly but if I don't do that then I can't access the pane from anywhere, which is what I need.

Only the textarea is needed to display a text.
Still I think that the declarations are incorrect.
You just can't present us with some code and pretend that "the rest is OK".
The error could be there.

Gonna sleep now. See you tomorrow.
Rowby Goren Makes an Impact on Screen and Online

Learn about longtime user Rowby Goren and his great contributions to the site. We explore his method for posing questions that are likely to yield a solution, and take a look at how his career transformed from a Hollywood writer to a website entrepreneur.

Hi, kibkid. Does your code work fine if you comment out these two lines?:

     //layout.putConstraint(SpringLayout.WEST, textarea, 100, SpringLayout.WEST, pane);
     //layout.putConstraint(SpringLayout.NORTH, textarea, 50,SpringLayout.NORTH, pane);

If so, then what are the lines above supposed to do, and (as sciuriware mentioned) please show the layout/SpringLayout declarations.
kibkidAuthor Commented:
layout.putConstraint(SpringLayout.WEST, textarea, 100, SpringLayout.WEST, pane);
     //layout.putConstraint(SpringLayout.NORTH, textarea, 50,SpringLayout.NORTH, pane);

Those lines are what defines the locations in which to put the textarea.

I will post the code but first I need to clean it out so you can understand it.
We still wait for the code...

Java PE
kibkidAuthor Commented:
Sorry for the delay guys but I work and sometimes get a little busy. I never forgot about the thread I just didn't have the time. Thank you for your patience and help.

Now, this is a subclass of my program its a simple editor with a textarea which shows the problem i was talking about, although i figured out what the problem was.

class editor extends JFrame
      public static void mains()
            editor edit = new editor();
            Image icon = Toolkit.getDefaultToolkit().getImage("top.png");
            edit.setSize(740, 630);

       TextArea textarea = new TextArea();
      public editor(){
      setTitle("Editor Ver 1.0");
      Container pane = getContentPane();
      SpringLayout layout = new SpringLayout();
        textarea = new TextArea(38,102);

        layout.putConstraint(SpringLayout.WEST, textarea, 0, SpringLayout.WEST, pane);
        layout.putConstraint(SpringLayout.NORTH, textarea, 0,SpringLayout.NORTH, pane);



Well if you see I declared textarea as TextArea which supposedly uses windows API. This worked perfectly for JVMs prior to 1.5 but since I downloaded 1.5 i begun getting this problem. Every time I declare the text area like that, i get that refreshing problem, so I decided just to test and declared the text area as JTextArea and every thing worked perfectly.

So I'm thinking that the new JVM either has a bug or they released new information about how to use the windows API and I haven't read about it.

Tell me what you guys think.
I would recommend going with Swing (e.g. "J" precedes everything, as in JTextArea, JPanel, JApplet, etc.) rather than the older AWT anytime. You get more options and less likelihood of glitches as new Java versions are released.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
kibkidAuthor Commented:
Yeah I'm just using swing because well, even though it's not as pretty, it works.
Hey I have a problem, I really don't know who to give the points or what to do because in this case no one really helped.

Sciuriware and edwardiii were the two who participated most in this thread, should I divide the points between you two? Does that sound fair?
I think edwardiii did a little more; to get even with him I'll add an advice:

add this to your code:


And SWING will look better!

kibkidAuthor Commented:
I was waiting to see if edwardii had any problems with my suggestion, but apperently not.

Thanx to all
Sorry for the late response; my ISP (Adelphia) is down more often than not, so I rarely get the notification emails during the last month. Thanks for the points:)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.