Actually that was the problem haha. I messed with the timer a little bit and got it to work. Thanks anyway though :)
Type: Posts; User: jm24
Actually that was the problem haha. I messed with the timer a little bit and got it to work. Thanks anyway though :)
I'm honestly not completely sure. I think it has something to do with the timing of the laser moving upwards and which collision it happens to be checking at that moment. It does register some...
Ok so I'm not getting any errors with this code or anything, but there is a small problem. Basically I'm making an invaders game and to hold the different invaders I have an 2D array called invaders...
Awesome! Thanks it worked perfectly :cool:
So I'm making a pong game that's almost done, but the one problem I have is that the JLabel that should display the score is in the main class on the JFrame and I need to change the value of it in...
Yea I figured that was my problem. I just wanted to make the whole thing in one class, but yea I guess that's not possible. Thanks for the help! :cool:
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
@SuppressWarnings("serial")
public class PongDrawer extends JPanel implements ActionListener, KeyListener {
JFrame table;...
Ok I just added panel to the JFrame before I made it the content pane but it's still not drawing anything. I also did table.getContentPane().add(panel); instead of table.setContentPane(panel);
Yea but I'm saying how would I specify so that it will draw on panel. I think I remember something about using the getGraphics() method, but I don't remember where to put it. Lol sorry for my...
Well what I'm really asking is how I would add the paintComponent to the JPanel panel. Would I have to make the JFrame and JPanel and such in the main class to do that?
This is my main class
public class PongMain {
public static void main(String[] args) {
PongDrawer game = new PongDrawer();
game.display();
}
No as in I had that before you told me lol. I still have the problem, which is that it's not drawing on the JPanel panel for some reason.
Lol sorry I should have said that I already have all that stuff (I thought it would be implied lol)
I'm trying to draw on the JPanel panel, but for some reason nothing shows up when I run the code. Is it because I have to set the panel on which to draw? If so, can someone please tell me how to do...
Ok, so basically I want to use a swing timer and an actionListener and use thread.sleep in the middle of the actionPerformed method to make it wait 2 seconds before doing the next action. The...
Alright well thanks for the help anyway. I'll try to figure this out lol.
No the name of my main class is MoleMain but yea I get that last line every time I export it into a runnable jar file and try to run it
I would but I'm not really sure how to do that lol. And yea I was almost sure it was ok to use == as long as I wasn't messing around with aliases or anything like that but idk.
EDIT: Oh ok I get...
So wait, I can have two different actionListeners within the same class? (sorry I'm a bit of a noob lol) Also if you could show me an example of the way you're saying to use casting with the try...
Ok so basically I want this program to change the text of a random JButton out of the 9 on the panel every 5 seconds (I have a timer firing with intervals of 5 seconds) to "mole" and then wait 5...
Haha wow it's funny because I knew that too. I guess I just didn't catch the error in the code. Thanks for the help :cool:
Hello, I'm having a problem with the following code where I keep getting the following error:
Exception in thread "main" java.lang.IndexOutOfBoundsException: Index: 9, Size: 9
at...