File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes Problem in JFrame Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Problem in JFrame" Watch "Problem in JFrame" New topic

Problem in JFrame

Vijay Chandran
Ranch Hand

Joined: Jan 07, 2007
Posts: 186

Dear Friends,

I'm building a chat application. I have a JFrame, which contains a JTextArea and below it a JTextField which is a chat window frame. Now i can type text in the JTextField and click send button to send the text to the JTextArea.

The chat request comes and gets added into a JTable from a custom server. By double clicking the row of a JTable, the chat window(JFrame) opens.

Similarly, when a second chat request comes and gets added into the JTable and on double clicking it, new chat window opens, but the existing chat window's contents get disappeared. What i mean is the JFrame (of the existing chat window) remains as it is, but whatever chat lines i typed and sent to the JTextArea gets disappeared. The JTextArea and the JTextField becomes untypable/uneditable.

One more problem is in teh second chat window, whatever chat i type in the JTextField and click "Send" button, the text disappears after clicking the Send button. If i press "Enter" key the text doesn't disappear and also it stays in the JTextField itself and doesb't pass to the JTextArea. The JTextArea is added on a JScrollPane. So that long chat texts can be viewed by scrolling down.

I couldn't post the code here as it is a part of a big application and it will be difficult for me to cut a part of the code and paste it here as it won't be helpful in resolving the issue.

I am using Java Version: 1.4.2_08

Kindly help me in resolving the problem.

Thank you very much,
pete stein

Joined: Feb 23, 2007
Posts: 1561
Sounds like you've got quite a problem, but I'm going to venture to say that without code, it'll be hard for others to figure out just how to solve it. I'll venture again though, this time to guess that there may be a static issue here (perhaps?). Does any of your code use static fields? Could you be reusing the same components of one frame in another?
Vijay Chandran
Ranch Hand

Joined: Jan 07, 2007
Posts: 186

Dear Pete,

Thanks for the reply. Its very difficult to analyze this problem without the code as you said. But i can't post the code since the code is scattered in various packages and it won't be easy to understand. Basically, its a poorly designed application. But its too late to change the design.

A small correction. There is no JTextFields anywhere. Both are JTextArea. In a single chat window (JFrame) one JTextArea to display the chat text. Below that a JTextArea to type the chat text

They are declared as static variables like this:

public static JTextArea txtranscript = new JTextArea(); \\ Display Chat Text in this JTextArea
public static JTextArea txMessagescript = new JTextArea(); \\ Type Chat text in this JTextArea

Please help.

I agree. Here's the link:
subject: Problem in JFrame
It's not a secret anymore!