Link to home
Start Free TrialLog in
Avatar of kibkid
kibkid

asked on

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);
               textarea.setEditable(false);
          pane.add(textarea);

          textarea.setBackground(Color.getHSBColor(0.6F,0.200F,1.0F));

          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.
Avatar of sciuriware
sciuriware

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 ?
;JOOP!
Avatar of kibkid

ASKER

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.

;JOOP!
Gonna sleep now. See you tomorrow.
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.
Avatar of kibkid

ASKER

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...

Venabili
Java PE
Avatar of kibkid

ASKER

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.setIconImage(icon);
            edit.setSize(740, 630);
            edit.setVisible(true);
            edit.setResizable(false);
            edit.setLocationRelativeTo(null);
      }


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

        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.
ASKER CERTIFIED SOLUTION
Avatar of edwardiii
edwardiii

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of kibkid

ASKER

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?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of kibkid

ASKER

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:)
ditto!