Eclipse doesn't like the start() method for t. I don't know why, but I personally don't see a start() method it can refer to. It says "The method start() is undefined for the type Timer".
Why It not clear the screen so that leave look like a line in the screen, and it auto fire without invoke the button, although i can control it by arrow button. Please correct me if i wrong! By the way can you upload the code, thank you very much!
@macheads101 For my program i have made a keyboard/keypad. And everytime the user pressed the up or down arrow keys I have to higlight the letters. So if the starting point is at A and if the user pressed right I have to highlight B anyway i can do that?
@scottyy888 If by application you mean class, you do not have to. Your main class could be a subclass of JFrame, but in general this is not good practice. Therefore, it's best to split your code up between multiple classes.
@QuickfleX1990 hey I finally got the circle to appear by fooling around with the paintComponent in JFrame but now the circle will not respond to my key movment :( I checked that all the methods like the up() and down() method and it fine. I also check that it was repainting after the keyevent
it works, but my problem with this is, when i run the java, it redraws the oval, and the one of itself if stil on the screen, so i looks like a long snake or whatever, maybe i'd call it a pipe.
@MinecraftingDaddio In your keyReleased(KeyEvent e) method set vely and velx to 0. That way whenever you stop holding a key down your velocities will be 0.
my comments were dumb questions easily answered so i deleted them im tired and i hav 4 projects and a math review pachet for the finals due mon and tues so im tired and not thinking but i klove ur videos they preety dam helpful more than my teacher
This is good, but I'm trying to make a square instead of a circle so what do I have to change? Oh, and is it possible to change the color of the shape as well?
How can i stop the graphic from moving after i press a key??? pls help tnx
hyperacidic009 2 days ago
How do I make a black background?
8o8inSquares 6 days ago
Eclipse doesn't like the start() method for t. I don't know why, but I personally don't see a start() method it can refer to. It says "The method start() is undefined for the type Timer".
Hoobes1 3 weeks ago
@Hoobes1 Did you import it from javax.swing?
JavaHax0r 1 week ago
Mine moves but it leaves footprints. How to fix?!?
RockerNamedJoe 3 weeks ago
@RockerNamedJoe You need to repaint();
Vaysm 3 days ago
@RockerNamedJoe same here
JoeVirella 3 days ago
Oval doesn't move on my side. Can somebody please share a link to full source code so i can compare. Thank you very much!
JosephRobertCox 4 weeks ago
Comment removed
8o8inSquares 1 month ago
Hi there, may i know how to add second.java into another panel instead of the main?
undead01 2 months ago
Why It not clear the screen so that leave look like a line in the screen, and it auto fire without invoke the button, although i can control it by arrow button. Please correct me if i wrong! By the way can you upload the code, thank you very much!
MyGrimTube 2 months ago
that means, you can do this:
vely = MOVEMENT_SPEED * -1;
velx = 0;
By doing the left keystroke
YoujimboL337 3 months ago
Basic tip: Making the movement speed should be given by something like...
public final double MOVEMENT_SPEED = 1.5;
Not really that important, but it makes the program much more readable and understandfull for the viewers.
YoujimboL337 3 months ago
Hey how can you count the number of times the arrow keys have been pressed can you help me with this please i really need it, Please and thank you
ComputerKing240 3 months ago
@ComputerKing240 Just have an integer variable that you increment (add one to) every time the key event is fired.
macheads101 3 months ago
@macheads101 For my program i have made a keyboard/keypad. And everytime the user pressed the up or down arrow keys I have to higlight the letters. So if the starting point is at A and if the user pressed right I have to highlight B anyway i can do that?
ComputerKing240 3 months ago
I have a question, why did you need to have another application out for the JFrame and main method? you cant combine it all into one application?
scottyy888 4 months ago
@scottyy888 If by application you mean class, you do not have to. Your main class could be a subclass of JFrame, but in general this is not good practice. Therefore, it's best to split your code up between multiple classes.
macheads101 4 months ago
Please help I followed your lesson but the circle doesn't show up :( here the code I have please tell me what im missing
public void paintcomponent(Graphics g)
{ super.paintComponent(g); Graphics2D g2 =(Graphics2D) g; g2.fill(new Ellipse2D.Double(x, y, 40, 40)); }
starbrand1 4 months ago
@starbrand1 Hey I'm aware this is a little late but are you sure you didn't possibly write paintComponent wrong?
Because when I started learning this stuff 3 months ago I did that a million times. It should be paintComponent not paintComponents.
QuickfleX1990 4 months ago
@QuickfleX1990 hey I finally got the circle to appear by fooling around with the paintComponent in JFrame but now the circle will not respond to my key movment :( I checked that all the methods like the up() and down() method and it fine. I also check that it was repainting after the keyevent
starbrand1 4 months ago
PLease help guys. My circle wont move...
could someone please gice me their working code so i can compare , or just try and help? thanks
Lt0Th3M 5 months ago
@Lt0Th3M Same here
JosephRobertCox 4 weeks ago
Comment removed
Lt0Th3M 5 months ago
it works, but my problem with this is, when i run the java, it redraws the oval, and the one of itself if stil on the screen, so i looks like a long snake or whatever, maybe i'd call it a pipe.
codecrax 5 months ago
How would you make it so it only moves 1.5 then stops?
MinecraftingDaddio 6 months ago
@MinecraftingDaddio In your keyReleased(KeyEvent e) method set vely and velx to 0. That way whenever you stop holding a key down your velocities will be 0.
0wner517 1 month ago
thank you very much for these tutorials!!!
helped me a lot.
checangel 8 months ago
my comments were dumb questions easily answered so i deleted them im tired and i hav 4 projects and a math review pachet for the finals due mon and tues so im tired and not thinking but i klove ur videos they preety dam helpful more than my teacher
Dragonboy664 9 months ago
Comment removed
Dragonboy664 9 months ago
Comment removed
Dragonboy664 9 months ago
Comment removed
Dragonboy664 9 months ago
Comment removed
Dragonboy664 9 months ago
god thankyou! could never get this right
TheWillOfTheKing 9 months ago
@hobolikespie11 You can do it with most languages. It's easier for object-oriented ones though.
turf7227 1 year ago
what the fuck is that Timer good for?
FecOoOoOo 1 year ago
@FecOoOoOo
Maybe not this but it can be used for a loading screen
MacApple10256 1 year ago
@FecOoOoOo It makes the process repeat when initiated and it also allows the action to be shown.
MinecraftingDaddio 6 months ago
Comment removed
StormFaction1 1 year ago
thankyou, you are a savior
Quinton238 1 year ago
This is good, but I'm trying to make a square instead of a circle so what do I have to change? Oh, and is it possible to change the color of the shape as well?
TehPiemaygor 1 year ago
thank you... that's so easy with java.. in c++ you need a lot of shits to add and the code is very annoying.. that's clean and simple
cosminx2003 1 year ago
@hobolikespie11 probably c++. Lots of other languages.
Kainaffets 1 year ago
the method to keep it from going off screen would be the window size?
malakov5 1 year ago
@malakov5 no i go over keeping it from going off screen in the previous tutorial
macheads101 1 year ago