Java 2D is an API for drawing two-dimensional graphics using the Java programming language.
Questions tagged [java-2d]
1076 questions
-3
votes
1 answer
Moving an Object on a circular path in Java
I want to make a Solar System kind of Simulator an therefor I want to move a Planet around the Sun.
I got the drawing Part done, but I don't know how to do the circular moving Part around the sun.
Thank you.

aFreshCake
- 3
- 2
-3
votes
1 answer
Detecting If Object and Object From ArrayList Collide
I am in the process of writing a program for a java mini-game. I need to determine if two objects collide. One of the object is just of type Player (one single object) with the name of player and the other is part of an arrayList of object type…

javainsanity1414
- 9
- 5
-3
votes
2 answers
How do I get my program to restart properly? (Brick Breaker)
When gameover is true and I call the startGame method from the DOWN button KeyListener, it breaks my game and doesn't allow me to click the exit button on the JFrame and the paddle doesn't work anymore. Please help.
import javax.swing.*;
import…
-3
votes
1 answer
I keep getting a null error but I do not know what to set g equal to, to make it work
I have this code that I was trying to get the graphic to appear after it was clicked and I was trying to find out how to do this but every time I try and run it, it gives an error and I do not know how to fix to get it to work.
Exception in thread…
-3
votes
1 answer
How to initialize Graphics? because it says it was not initialized
I have this part of my code but it will not initialize and I do not know how to do it. It keeps giving me an error such as
Exception in thread "main" java.lang.NullPointerException
at memor.main(memor.java:131)
import java.awt.*;
import…
-4
votes
2 answers
java - Different stroke for different shapes? Graphics2d
I am making a paint application for a project and running into an issue.
My model stores two ArrayLists of circle and square objects. (Every time one is drawn, it is stored)
I also have a JSlider on my GUI to change the thickness of the stroke…
-4
votes
1 answer
Java 2D Graphics
I want to develop a java graphic application. The concept is that there will be a circle in the middle and several balls will rotate around the circle. Is it possible to make the circle stable forever and only change the position of balls? If it is,…

Talha
- 1
- 2
-5
votes
2 answers
JAVA GAME loop?
I have a problem with my java game. I’m beginner, but i have to write it as a school project.
Game is called „Birthday Cake” there is 7 candles on the cake and randomly one of it is showing for let say 30s and during this time u have to click on it…

Miszel
- 1
- 2
-6
votes
1 answer
Java Package not in Folders
I have a java program where I get the Graphics2D from a BufferedImage via createGraphics() and printed it out and got: sun.java2d.SunGraphics2D[font=java.awt........... you get the idea but when I go to my jdk folder there is no folder in sun called…

Sean Letendre
- 2,623
- 3
- 14
- 32
-6
votes
1 answer
Center Align a rectangle in Java Frame/Panel
Trying to create a bull' eyes program using paintComponent. I want the rectangle to be in the center of the screen. How do i do that?

Gaurav Mishra
- 1
- 1
-7
votes
3 answers
Class doesn't have a main method (Traffic Light)
I found a java code from this link.
and when I tried to run it the error class doesnt have a main method.I know this is a similiar post but I tried searching/trying for different solution but when I tried them they dont work. Below is the…

Vista
- 201
- 2
- 4
- 23