Hello Daniweb users, I am developing a small client for messaging, the messaging part is okay! :)
Now the problem is with the GUI. I want to implement a "tabbed chat interface", similar to that of MSN or iChat. I am implementing a JTabbedPane for each "window".
My problem is, how would I add all of my components into each tabbed pane? As in, my text area, message output window, send button and etc., into each of the individual tabbed panes?
I am aware of the "add" function within the JTabbedPane, but could I implement a a layout system for it?
Also, how would I allow the program to know what tab to pass the messages into? As in, what JEditorPane, which was created dynamically?

Sorry for asking so many questions! But this is my first experience with a practical swing application (:
All help appreciated.

Recommended Answers

All 6 Replies

Ok I suggest having an object called conversation. Each object will have its own JScrollPane that contains the chat manuscript. Thus you will only need to add this to the JTabbedPane. Then below the JTabbedPane would be the text area and the button and when the button is clicked it adds to the currently selected JTabbedPane's pane's conversation. Does that make sense?

Yes it does. I have the layout formed! I have also read up on how to add multiple components to a JTabbedPane via a single JPanel component.

Now I need to solve how my program will know what specific tab to print the conversation out into?

JTabbedPane has a method called something like getSelectedTabIndex(). It returns an int which is the index of that tab. So if you have an arrayList of those objects I was suggesting earlier then you could manipulate the one at the selected index. Which is the selected tab and thus the one you should be editing. Iv done this before and it works pretty well.

So you are saying to simply fetch the selected tab index?
But how would I call the JEditorPane /specifically/?

Thanks BTW!

Ok lets say we call that object a chat. Now chat will store an arraylist of people involved in the conversation, the conversation and a jeditorPane that is the actual pane. So when you call the chat object from the arrayLists of chats you would just have a getter that gets the pane.

Okay so if I am understanding you correctly, I have my list of buddies.
When a person clicks from the JList a person, the tab is opened up, elements laid out, and the JList index value is added.
Or do you mean to add the tab index value?

I am not sure :(
Give some psuedo code?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.