Image

Imagenullset wrote in Imagejava_dev

Questions about Swing.

I don't know how many people use the Swing class for making GUI's but I've been picking it up (slowly), and have been using the Eclipse visual class to help me along (it's quite nice). I have a question, and I'm going to use this situation to explain it:

Think about a pseudo-instant messenger client where there is a server and a client who are connected. When the client types something and presses enter, it ends up on the server's machine and vice versa (like an aim client would, except without that direct connect -but that's just for this example-).

1) So my question(s) deals with how the text shows up. I want the text to add on to what's already there (on a new line, like an IM client). If I use setText() in the JtextFrame then it will just reset the text to whatever the new text is. I could make a string variable and keep adding onto it every time a new message is sent, and then do a setText() with the new variable, but that is a patchwork way of doing what I want to do. Anyone have a better idea?

2) Can Swing (or Java in general) deal with text colours? I believe with Swing you can do a setFont() but is there any way to do multiple colours within 1 message, especially when dealing with question 1?

3) Directed towards people who create GUI's for programs, using Java: Any kits besides Swing that you use? I know there's a lot of arguments between the different types, but what are the pros and cons?


Thanks for any answers.