Reputation: 43
so today I'm was making a program and as i'm still a beginner I'm still learning but i'd like to know how to add another circle, for instance I have two units, Red and Blue, I have added the randomize which randomly selects the x and y position, but when I click start it only shows one circle which is red, the blue one is not even there, I know i have not done some coding, but here's my program, please help thanks :)
so yh :) thanks in advance.
Upvotes: 1
Views: 229
Reputation: 47608
A few things to change here:
JPanel
, JTextField
...). This will avoid rendering issues and bring double buffering (without any code to perform).c.getGraphics()
.paintComponent(Graphics g)
and use the Graphics g
parameter provided there (see also this link for some example)javax.swing.Timer
. All updates to the UI must be done on the EDT (Event Dispatching Thread). Read also about concurrency in SwingJOptionPane.showMessageDialog
(or any other dialog), provide a valid parent
component and not null
. This will allow proper parenting of windows (avoiding dialogs to be hidden by other frames).Upvotes: 5