X

Geertjan's Blog

  • October 8, 2011

Small NetBeans Visual Library ConnectionWidget Sample

Geertjan Wielenga
Product Manager

Small ConnectionWidget sample, within the constructor of a TopComponent:

setLayout(new BorderLayout());
Scene scene = new Scene();
LayerWidget baseLayer = new LayerWidget(scene);
LayerWidget connectionLayer = new LayerWidget(scene);
LabelWidget helloLabel1 = new LabelWidget(scene, "hello1");
helloLabel1.setPreferredLocation(new Point(10, 50));
baseLayer.addChild(helloLabel1);
LabelWidget helloLabel2 = new LabelWidget(scene, "hello2");
helloLabel2.setPreferredLocation(new Point(100, 50));
baseLayer.addChild(helloLabel2);
ConnectionWidget connectionWidget = new ConnectionWidget (scene);
connectionWidget.setTargetAnchorShape(AnchorShape.TRIANGLE_HOLLOW);
connectionWidget.setSourceAnchor (AnchorFactory.createRectangularAnchor(helloLabel1));
connectionWidget.setTargetAnchor (AnchorFactory.createRectangularAnchor(helloLabel2));
connectionLayer.addChild (connectionWidget);
scene.addChild(baseLayer);
scene.addChild(connectionLayer);
add(scene.createView(), BorderLayout.CENTER);

Join the discussion

Comments ( 2 )
  • faroq Tuesday, March 27, 2012

    Thank you, I am just asking, how can we use a graph ended with cicles and connected by lines. The widgets have to be movable, editable and renderable in case of zooming.

    Any help is appreaciated.


  • Filipe Macedo Friday, November 9, 2012

    Hi, Geertjan! Can you please help me ? I have to make a ConnectionWidget's endpoint to move around the connected LabelWidget.

    Thank you!


Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.