How can I make a 2D star move in my JFrame using Java?

  • Java
  • Thread starter Nec
  • Start date
  • Tags
    Java Star
In summary, Java is a high-level, object-oriented programming language commonly used for developing web and mobile applications. It is used for creating a moving star because of its efficient and flexible coding capabilities. To create a moving star using Java, you would need to define its properties and use animation techniques. You can control the movement of the star by manipulating its properties or using user input. While Java is a popular choice for creating moving stars, there are other programming languages that can also achieve the same result. There are many resources available online to help you learn how to create a moving star using Java.
  • #1
Nec
50
0
In my JFrame, I already draw a 2d star, i would like to make it move around in my frame, but i don't know how to erase the old star when it appears in a new position, can anyone here help me with this ?
Thanks
 
Technology news on Phys.org
  • #2
Although I haven't done much Java programming recently, I think one of the following suggestions could be used.

1. Before updating the position of the star, you could first paint it the background color.

2. Alternatively, you could implement "double buffering".
 
  • #3
Ah.., I see it now, thanks for your suggestions ..lol..
(!ThumbsUp!)
 

Related to How can I make a 2D star move in my JFrame using Java?

1. What is Java and why is it used for my moving star?

Java is a high-level, object-oriented programming language that is commonly used for developing web and mobile applications. It is used for your moving star because it allows for efficient and flexible coding, making it easier to create interactive and dynamic elements like a moving star on a webpage.

2. How do I create a moving star using Java?

Creating a moving star using Java involves using the programming language to define the star's properties, such as its size, position, and speed, and then using animation techniques to make it move across the screen. This can be achieved by using Java libraries and frameworks like JavaFX.

3. Can I control the movement of the star using Java?

Yes, you can control the movement of the star by manipulating its properties, such as its speed and direction, in your Java code. You can also use user input, such as keyboard or mouse events, to control the star's movement.

4. Is Java the only programming language that can create a moving star?

No, there are other programming languages that can also be used to create a moving star, such as JavaScript and HTML5. However, Java is a popular choice for developing interactive and animated elements on webpages due to its versatility and robustness.

5. Are there any resources available to help me learn how to create a moving star using Java?

Yes, there are many online tutorials and resources available that can guide you through the process of creating a moving star using Java. You can also refer to Java documentation and join online communities to seek help and advice from other programmers.

Similar threads

  • Programming and Computer Science
Replies
14
Views
3K
  • Programming and Computer Science
Replies
3
Views
3K
  • Programming and Computer Science
Replies
15
Views
2K
  • Programming and Computer Science
Replies
5
Views
1K
  • Programming and Computer Science
Replies
1
Views
1K
  • Programming and Computer Science
Replies
4
Views
4K
  • Programming and Computer Science
Replies
5
Views
2K
  • Programming and Computer Science
Replies
6
Views
2K
  • Programming and Computer Science
Replies
1
Views
1K
Back
Top