gui to make a flow chart.
I need to build a java application which supports drag and drop feature to build flow charts. The application is supposed to work like this :- there should be shapes which need to be dragged and dropped on to a separate area where all these shapes are put to form flow chart.
I just need to know how should I begin and what libraries I should use. I am new to java and I have searched the net for related stuff but could not succeed.
Thanks and regards
Re: gui to make a flow chart.
First, you will need to decide what kind of objects you are going to be dragging and dropping. Next, you will want to see if there's an existing Swing (or AWT) component that can be used to represent that object. Some common ones are:
JLabel, JTextField, JTree, JList, etc. etc.
All JComponents by standard have the framework to support drag and drop, but some don't have the TransferHandler implemented to actually perform the action once the object has been dragged/dropped, and even if they do have a default TransferHandler, if you want to be able to transfer your own type of data (or transfer a type of data to a JComponent that doesn't support that type by default) you will need to implement your own TransferHandler.
The default objects Java can transfer to some components are: files, images, and strings. If you want your own data types, you will need to create an object that is transferable, as well as Serializable. Please note that the Serializable needs to be applied to all fields of that object, as well as any fields it's fields have, etc. etc. (primitives are default serializable). You will also need a DataFlavor so java knows how to retrieve data back/send data out.
Drag and drop is quite an intensive piece of code that involves a lot of java standard API components. I don't think there are any libraries created for this purpose specifically other than the one provided with the standard API.
If you want to see an example of an implementation of Drag and Drop I did using JTrees (note: the code I posted is currently being revised, but it does work until you try to transfer data into/out of the application), see this post.