Jame
Jame

Reputation: 22180

Java : How to draw graphic object?

I am developing a small desktop application in Netbeans. The application is complete and working fine. A small description of application is as follow:

The application is basically an object manager, where user add new object, remove old objects and connect object with each other. What i did is that i simply add 3 panel and change its type to titled border. One for Add object one for remove and one for connect.

Status:

Every thing is working fine as expected.

What Left:

In order to make UI more appealing i added a new panel at the end and called it "Object Viewer". I am planing to visualize the steps which user performs e.g

  1. If user add an object then i that pannel i will daraw a little circle and fill it with green color

  2. Similarly if user remove some object then again i will draw another cricle and fill that with red

  3. And when user connects two object then i will draw two circle and connect them with a dotted line

This is my first java application, i only want to know how do i acheive this task. Some links or experience are highly appreciated

Upvotes: 1

Views: 2771

Answers (3)

Manuel Selva
Manuel Selva

Reputation: 19050

As Nico Huysamen said you can do that with Java 2D. But because it's your first Java application I strongly recommend to do it manually with this lybrary in order to understand how higer level lybraries work.

Upvotes: 1

Thomas
Thomas

Reputation: 88707

As for custom painting in swing, have a look here: http://download.oracle.com/javase/tutorial/uiswing/painting/

However, I'd suggest using a graph visualization library like JUNG etc. Using this you'd basically only have to define your object graph.

Upvotes: 2

Nico Huysamen
Nico Huysamen

Reputation: 10417

You can either do that manually with Java 2D, which I don't recommend, or, since you are using Netbeans (and I assume the Netbeans Platform, but this is not required), I would strongly suggest looking at the Netbeans Visual Library. It can do exactly what you want.

Upvotes: 1

Related Questions