Reputation: 749
I want to implement a java awt/swing application but i am new to awt/swing. I need to draw a grid like panel. Than drag and drop some objects on it. Later than objects can be clickable and resizable. My application should look like this:
I am able to draw object with :
public void paint(Graphics g){}
but its too far away from what i want to do.
How can i implement this kind of application? What should i read and know to do this?
Upvotes: 1
Views: 687
Reputation: 344
Do you need to develop everything from scratch?
For painting, clicking mechanics etc you can use PlayN only the java part...
But if you want to use the swing capabilities to... I am not sure if you can mix playN with swing...
But if you only relly on the GraphicsAPI awt.... than you will need to look up couple of things.
small graphics enigne for drawing with the pinpoint capability (simple collision detection) so you can check each object on click. Movement and repainting are easely managed with simple engine...
Upvotes: 2
Reputation: 28687
First, I'd be sure to follow the Swing tutorials:
Then, I'd revisit your approach a little: I would use Swing components.
paintComponent
method there to draw your grid.paintComponent
method for those to draw the appearance of your objects.paintComponent
- calling repaint
if necessary to force a redraw.Upvotes: 2
Reputation: 109815
please don't use public void paint(Graphics g){}
this method is for AWT Components
and BasicXxxUI
, for Swing JComponents
is there method public void paintComponent(Graphics g){}
more in Graphics tutorial
Upvotes: 2