• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
David Garratt
Ranch Hand
Posts: 213
Eclipse IDE Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
example1.gif
[Thumbnail for example1.gif]
example2.gif
[Thumbnail for example2.gif]
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 213
Eclipse IDE Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Looks like someone doing almost exactly the same thing as me.

Many thanks for that reply.

Dave
 
David Garratt
Ranch Hand
Posts: 213
Eclipse IDE Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5128
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This old forum thread may help
http://www.coderanch.com/t/422714/GUI/java/JScrollPane-JPanel-dynamic-changes
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic