15 Posted Topics
This is for anyone who might find it helpful. This template... * uses double-buffering, which can help game-makers fix that glitchy screen problem * can be exported as a runnable jar file. If you're like me and had trouble making your Applet executable, this is a possible fix. * Additionally … | |
Re: That's strange. The setup works for me... Where's your MyObject class? ![]() | |
The setSize() method of a Frame only resizes the frame itself, not the canvas inside. Is there a way to resize a frame based on what size you want the interior to be? I made this image to explain what I'm talking about: I used setSize(500,500); http://oi44.tinypic.com/4uymur.jpg I suppose I … | |
If I am given the exact coordinates of three vertices in image-space (as in, the numbers are not integers, but can be rounded to find their location on the screen), how can I determine which pixels are inside the triangle and should be colored? If you look at the diagram … | |
So I have a PrintWriter as a class variable which is created upon initialization. I want to make sure it gets closed when the Applet closes, but overriding the destroy() method doesn't seem to work (a System.out.println inside the method does not appear). 1. should I be doing this in … | |
Right now I know that Applets can add any listener with the addMouseListener() method. But what I want to know is if I can make my custom class a mouse listener without having an Applet add it itself. | |
Re: As a newbie myself, I'm unsure whether this could be helpful, but I'll post it anyway: Instead of placing the ships one-by-one, you could try loop { randomlyArrangeShips(); //this ignores previously placed ships if(count_occupied_tiles == number_of_tiles_there_should_be) { //there is no intersection of ships, so keep the layout break from loop; … | |
**Does the code** int value = 5; if(value==5) System.out.println("value is 5"); if(value==6) System.out.println("value is 6"); **actually compute faster than** int value = 5; if(value==5) System.out.println("value is 5"); else if(value==6) System.out.println("value is 6"); **?** I would assume that it *is* faster, based on its name and all, but is that actually … | |
An **applet** I am creating **uses Timers for its animation**. Even though the Timer is set to repeat at a constant 30ms, **the applet's framerate on my computer** versus on my brother's laptop **is significantly better**. Is there a chance that **on slower computers**, the **Timer "ticks" slower**, so to … | |
My applet creates a new sound every time an impact occurs, which is very frequently. How come, when the sounds become too numerous, the game ceases to run smoothly? Here is the code that gets called many, many times: class soundThread extends Thread { String sound; soundThread(String i_sound) { sound … | |
Re: I have little experience but I'm sure someone will correct me if I'm wrong. The **init()** method just *initializes* the applet -- it starts it up. Try making your applet like this: import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.util.Random; public class applet extends JApplet implements Runnable, ActionListener { //Foundation … | |
I'm probably doing this wrong, because there has to be a way to do this. Here is my current code: import javax.sound.sampled.*; public class soundHandler{ soundHandler() { } public void newSound(String sound) { new soundThread(sound).start(); } } class soundThread extends Thread { String soundName; Clip clip = null; soundThread(String i_soundName) … | |
**Background**: I have some experience in programming, but it's not a lot and not very good. I'm taking my first Java class this year, but because the pace is so slow I decided to just learn with the aid of the internet. This is how I have learned most of … | |
I have two classes: (1) **Class A**, which extends JApplet, implements Runnable + some Listener stuff (2) **Class B**, which has a main method and is not an applet My question is, how do I create **class A** with **class B**'s main method? Is this even possible? What I'm doing … |
The End.