J. Ryan

Greenhorn
+ Follow
since Jul 24, 2006
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by J. Ryan

Thanks, Darryl.

After looking at the source for javax.swing.Timer, it makes sense to me now. I like the approach of adding a dispose() method. I can easily call it when the window is closed.
13 years ago
Hello,

I am working with an existing custom component that updates itself periodically. The component resides in its own JFrame which can be launched from my main application. The problem I'm having is that the component is not being garbage collected after its window has been closed. I've posted some simple sample code below. This is not the actual code, but it illustrates the issue.

The main class...


The custom component...


In the sample code, a Swing Timer is used to periodically update the label text. I also print out the value of count. But when the secondary frame is closed, the custom component continues to print out the value.

What am I doing wrong? How can I get the component to go out of scope and be garbage collected. What is the best practice for doing this type of thing? I would appreciate any insight. Thanks.
13 years ago
OK, that all makes sense. That was my initial guess, but I just wanted confirmation. Thanks for all the replies.
16 years ago
Thank you. That fixed it!
16 years ago
Can someone provide an explanation into exactly what happens when you use the import statement? Specifically, do you suffer a performance hit at runtime by doing something like



as opposed to

?

When do classes actually get loaded--when they're first imported, when they're first used, or at some other time? Thanks.
16 years ago
I'm writing a simple client/server application that will make use of logging over a network. My client sends LogRecord objects to a SocketHandler which sends XML data to the server. For some reason when I read the data on the server I'm not getting the closing tag for the root element, </log>.

I'm basing my code on this example posted on Sun's website. Running their code will demonstrate the problem. I duplicated their code below...

Client


Server


Is there something I'm missing here? Thanks.
16 years ago
I mean I am modifiying the fields of custom objects, deleting objects, creating new ones, etc. So for anything other than simple text edits of text fields I should use my own history manager?
16 years ago
I'm trying to implement an undo/redo mechanism in my application, and I want to be able to handle actions which are more complex than text events. For example, I want undo/redo operations (e.g. update, delete, etc.) for custom objects used by my application.

Would it be possible to use the API provided by Swing (UndoManager, etc.) to handle these types of operations or would I need to write something myself? From what I've read so far, it seems like I'll need to do it myself since the API seems to only support text edits. Am I heading down the right track or do I need to use the API? Thanks for any input.
16 years ago
Yes, both client and server are written in Java. But I think I see what you're saying. Apache really has nothing to do with it, right? Am I correct in thinking that all I have to do to deploy it is run the server program (written in Java) on the machine I want and open the correct port, then connect clients to it?

If this belongs on another forum, please move it. Thanks.
I have a simple Java client-server application that works like I want it to when I run it using localhost. This is probably a real beginner's question, but how I go about deploying the server side of the application to a web server running Apache? What directory does it go in? When using a localhost, I have to start the server application first before connecting clients. How do I do this using Apache? Thank you for any insight.
I have a simple question about when memory is actually allocated. What is the difference between the following two code snippets?



and



Thanks.
[ June 30, 2007: Message edited by: J Ryan ]
16 years ago
Here is the general pseudo-code:



The method above has many if statements to determine the exact look of the label. In most cases, it just returns a JLabel without much being done to it. The problem is when many cells are created with actual contents, the table slows down incredibly.

I've thought about doing something using Java2D, but it would mean way to much refactoring of existing code. Is there any way to improve the speed without totally throwing away the JTable?
16 years ago
I have a JTable attached to a JScrollPane that uses a custom table cell renderer (a JLabel). My problem is that when several labels are "filled" with contents, the JTable scrolls at a terribly slow speed. Any ideas on how to improve the performance here?

Before you ask, I cannot scrap the JTable and use 2D or anything like that. The application already uses a JTable, and I am not able to change that.
16 years ago
Hi,

The program I'm writing needs to run using an older JRE installed on the client's machine. Is there some way to have Java use the older JRE without uninstalling the newer ones? Thanks.
17 years ago