Added: 1 year ago
From: macheads101
Views: 11,276
Sort by time | Sort by thread (beta)

Link to this comment:

Share to:

All Comments (46)

Sign In or Sign Up now to post a comment!
  • How can i stop the graphic from moving after i press a key??? pls help tnx

  • How do I make a black background?

  • 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 Did you import it from javax.swing?

  • Mine moves but it leaves footprints. How to fix?!?

  • @RockerNamedJoe You need to repaint();

  • @RockerNamedJoe same here

  • 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!

  • Comment removed

  • Hi there, may i know how to add second.java into another panel instead of the main?

  • 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!

  • that means, you can do this:

    vely = MOVEMENT_SPEED * -1;

    velx = 0;

    By doing the left keystroke

  • 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.

  • 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 Just have an integer variable that you increment (add one to) every time the key event is fired.

  • @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?

  • 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 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.

  • 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 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 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

  • 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 Same here

  • Comment removed

  • 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.

  • How would you make it so it only moves 1.5 then stops?

  • @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.

  • thank you very much for these tutorials!!!

    helped me a lot.

  • 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

  • Comment removed

  • Comment removed

  • Comment removed

  • Comment removed

  • god thankyou! could never get this right

  • @hobolikespie11 You can do it with most languages. It's easier for object-oriented ones though.

  • what the fuck is that Timer good for?

  • @FecOoOoOo

    Maybe not this but it can be used for a loading screen

  • @FecOoOoOo It makes the process repeat when initiated and it also allows the action to be shown.

  • Comment removed

  • thankyou, you are a savior

  • 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?

  • 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

  • @hobolikespie11 probably c++. Lots of other languages.

  • the method to keep it from going off screen would be the window size?

  • @malakov5 no i go over keeping it from going off screen in the previous tutorial

Loading...
Alert icon
0 / 00Unsaved Playlist Return to active list
    1. Your queue is empty. Add videos to your queue using this button:
      or sign in to load a different list.
    Loading...Loading...Saving...
    • Clear all videos from this list
    • Learn more