aspose file tools*
The moose likes Beginning Java and the fly likes JInternalFrame JScrollPane JTextarea Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "JInternalFrame JScrollPane JTextarea" Watch "JInternalFrame JScrollPane JTextarea" New topic
Author

JInternalFrame JScrollPane JTextarea

Raul Elizondo
Greenhorn

Joined: May 09, 2006
Posts: 10
Hi,
I am developing a small chat applet for my page in which i want to do private messages windows. I took the samples of Swing2 to do a menu and open an JInternalFrame as a console inside a JDesktopPane. Everything works fine within one JInternalFrame. Problem comes (to understand) when i want to add more JInternalFrames, i can identify them by using getAllFrames(), but i cant target their JScollPane or the JTextArea inside the JInternalFrame on the new JInternalFrames.

Is there a way to do any kind of "getallchild" or something like that so i can reach the JScrollPane/JTextArea to append and repaint them?

Regards...

-=Raul=-
Shyam Prasad Murarka
Ranch Hand

Joined: May 02, 2005
Posts: 209
Dear Reader,
I solve this problem in my programs by including a public method in the required class. In you case you could place a method like this:


There may be other alternatives like putting a method like this:


But, I prefer to use the first method as it does not involve any hassles.


With Best Regards,
Shyam Prasad Murarka
Raul Elizondo
Greenhorn

Joined: May 09, 2006
Posts: 10
Thanks Shyam. Thats already considered for the console JInternalFrame in which all public messages appear. But the thing is when new internal frames are open. I can identify them with no problem, but i can not identified its JScrollPane/JTextArea inside the new internal frames. Here is the code:



When a user sends a message to the client, it opens an internal frame with the user's name in the Title, but thats as far as i could get, still dont know how to identify the JScrollPane and the JTextArea requested in order to add the text thru addmsg method.

Any hint?

Regards,

-=Raul=-

PD. this is my very first applet in java, but I do other languages. I am still getting a little bit confused.
Shyam Prasad Murarka
Ranch Hand

Joined: May 02, 2005
Posts: 209
Dear Reader,
I didn't go through your code in great detail. This is what I am thinking. When a user sends a message, the code should open a JInternalFrame that is being extended by another class. And then, you could add your JTextArea to these frames. I guess it will be better to show a bit of code.


Now, in your main class, you have to keep track of all the PrivatePane's that are opened.
When the user send a message, iterate through all the PrivatePane's searching for the one that has the same name as the client who sent it. Then call the appendInfo() method on that PrivatePane.
Do you get me?
Raul Elizondo
Greenhorn

Joined: May 09, 2006
Posts: 10
Thats exactly the thing... how to keep track of those privatepanes? If you look at my code, you will see i already got an append method (public void addmsg), which is called at the time the JInternalFrame is opened. But after that, i cant reidentify the scroll and textarea to do a call to the append method (addmsg) and append a new msg to the right internal frame, even though i can identify all internal frames already opened.

I see your point, adding a class to the internal frame, but... how?

When the applet receive a message from another user, it opens an internal frame, and thru an actionlistener set in the Textfield, anything written in the textfield of that internal frame its sent to the class that handles the socket. So, sending from the internal frame works fine. Receiving it and identifiying the right internal frame to display what is received its the matter.

Regards,

-=Raul=-
Raul Elizondo
Greenhorn

Joined: May 09, 2006
Posts: 10
oh! finally got that about the extend!
now the matter would be to keep track of all PrivatePanes, i think in an array (so lets do another dig in google to know how to work with arrays in java).

Thanks Shyam,

Regards,

-=Raul=-
 
Consider Paul's rocket mass heater.
 
subject: JInternalFrame JScrollPane JTextarea