File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes New ground, making progress, but need some guidance with drawing lines. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "New ground, making progress, but need some guidance with drawing lines." Watch "New ground, making progress, but need some guidance with drawing lines." New topic
Author

New ground, making progress, but need some guidance with drawing lines.

David Garratt
Ranch Hand

Joined: Aug 08, 2003
Posts: 198

I am creating a "flowchart" type application, but instead of being just a documentation aid I want to actually execute the logic represented on screen. However my question is more graphics related than specific to the logic of the application.

In the two images attached you will see a number of orange squares. These are customised JPanels. Each panel will know which other panels it should be linked to. The actual black lines shown in the images below I have added using a paint program to illustrate what I want to end up with.

I can already drag these panels around the desktop. They are all sitting on another "white" JPanel.

So given that I can drag these panels around and each panel knows the name of the panel it's connected to, can I override the paint method of the parent (background) panel to draw the lines between them. I guess I would need to pass some form of list to the parent panel which indicates the lines which need removing and re-drawing.

Comments welcome - I've not done any low level graphics work before.

Thanks

Dave


[Thumbnail for example1.gif]

[Thumbnail for example2.gif]

Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
Craig Wood's ComponentLinks might suit you (final post in this thread)

http://www.coderanch.com/t/344279/GUI/java/Drawing-lines-between-JPanels-JInternalFrames#1512509

or Stanislav Lapitsky's JConnector

http://java-sl.com/connector.html


David Garratt
Ranch Hand

Joined: Aug 08, 2003
Posts: 198

Looks like someone doing almost exactly the same thing as me.

Many thanks for that reply.

Dave
David Garratt
Ranch Hand

Joined: Aug 08, 2003
Posts: 198

I wonder if I could ask another question which is directly linked to the above example. In the image above as I mentioned the background is a JPanel and the flowchart symbols are JPanels. As I don't know how big my virtual page needs to be I would like to create the background panel to say 2000 x 2000 pixels and put it on a jscrollpane. Umm, well obviously not that simple. Given the nature of my drag and drop symbols I am having to use an absolute layout manager on my background panel.

I'm confident I can do this, but experimentation has yet to yield results.

Thanks

Dave
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
not sure what problem you're having...

if it's the backgroundPanel/scrollpane, just give the backgroundPanel a preferredeSize

backgroundPanel.setPreferredSize(new Dimension(2000,2000));
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4642
    
    5

This old forum thread may help
http://www.coderanch.com/t/422714/GUI/java/JScrollPane-JPanel-dynamic-changes


luck, db
There are no new questions, but there may be new answers.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: New ground, making progress, but need some guidance with drawing lines.