Gideon Goodwin

Greenhorn
+ Follow
since Dec 10, 2004
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 Gideon Goodwin

You asked whether it was necessary to obtain a fresh Graphics each frame...in general, it is recommended to do this. You need to time the call to getGraphics() to see whether it's even worth worrying about (I'd suspect that the time-cost for this call is minimal).

You might be able to gain some performance by skipping the background clear. Recode your drawGround() method so that you take care of the background in one pass. That will save you from redrawing quite a few pixels.

Also, you could use your timing information to change the amount of time you sleep. This isn't exactly a performance increase, instead, you're just wasting less time if needed. If your main loop calculated that it was taking more than 15 milliseconds per loop, you might just want to skip the sleep period all together.
18 years ago
In general, I have seen applets running on Mac OSX JVM run much slower than on windows or linux. That is strange in your case that the windows performance is also bad, usually I haven't seen that.

In any case, your main loops look fairly straightforward. It seems that you are making a game, in which case it is likely that a major portion of your screen will have to be redrawn each frame. If this is the case, you will in fact have to redraw the entire buffer. In some applications, you might be able to get more performance by only redrawing the "dirty rectangles", but if you have a lot of full-screen motion, the logic required to track dirty rectangles will take longer than any draw time you might be saving.

Have you profiled this code to see exactly which parts are taking up your cycles? This would be my next recommendation.
18 years ago
Hello,
I am setting dynamically generated HTML to a JEditorPane using the String version of JEditorPane.setText(). My JEditorPane is given a default size which is usually too big for the generated HTML content. I would like to find the exact height required to display the content with a given (definite) component width. Is this possible, and if so, what is the best way to do it?

Thanks in advance.
18 years ago
Hello, I am getting some JVM-dependant behavior which I can't explain. My client applet is using a TextArea to display a paragraph worth of text. When run on some target JVMs, this text is wrapped correctly to display in the actual size of the TextArea. On other JVMs, however, the text doesn't wrap correctly and extends past the actual right edge of the component, but eventually wraps on its own (no line break present in content string). Apparently this component is getting different default values on different platforms for some property which controls how text wraps, but I can't seem to find this property in the docs. I tried setColumns(x) but that didn't help. I am not using scrollbars on this component. Any ideas?
18 years ago
Thanks for the information.
18 years ago
Thanks for the reply.

We had been hoping to avoid Swing components because we are still trying to target Java2 without the swing extension. So can I infer from your post that it is not possible to supress borders on AWT TextAreas? If so, I can look for another solution.

Thanks again.
18 years ago
Hello, hopefully this should be an easy question to answer:

I have added a TextArea to a custom Panel subclass and I would like it to display its text contents without drawing standard AWT borders. I looked at the API and couldn't find any suitable methods for supressing border-draw in either the TextArea, TextComponent, or Component classes. What is the easiest way to accomplish this? Even if I could set the border to a fixed color to match my background color...

Thanks in advance.
18 years ago
This should be a simple matter of multiplying the x and y coord of each point in the shape by your scale factor. Depending on how the points are situated relative to the shape-origin, you might need to renormalize your coords after the scale so that they are still optimized to the origin.
19 years ago
That's exactly what I needed...thank you. Not sure how I missed this in the first place!
19 years ago
Hello all,

I have encountered a problem that seems like it ought to have an easy fix, but I can't seem to find any info about it, anywhere.

My applet is restricted to using AWT with a target JVM version of 1.3.1. After a loading sequence, the applet creates a Frame and proceeds to add components to the frame according to a specific layout. No layout manager is being used. The problem is that if I try to add one of my custom components at (0, 0), it appears underneath the title bar of the Frame. This title bar varies in size depending on the browser that was used to launch the applet (and even depending on the theme which the browser is using). I need a way to get the (vertical) dimension of the titlebar so I can adjust my origin for custom drawing, but I can't seem to find any info whatsoever on how to do this in a platform-independent way. Any help? Thanks in advance.
19 years ago