• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JInternalFrame JScrollPane JTextarea

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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=-
 
Ranch Hand
Posts: 209
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Raul Elizondo
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 209
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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=-
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic