In this example we are going to create three connected circles as per the image below:
and we will be able to drag these circles around the screen using the mouse:
The Code
Create the class examples001.ConnectedShapes.java as follows:
ConnectedShapes
[code language=”java”]
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package examples001;
// bring the clicked circle to the front
Circle c = (Circle) (t.getSource());
c.toFront();
};
[/code]
and similarly for mouseDraggedEventHandler.
Creating the Lines
We use the connect method to connect two circles with a dashed line.
We first create a line and set the stroke width, line cap and dash array.
Then we bind the x and y properties of one end of the line to the centre of one of the circles, and bind the x and y properties of the other end of the line to the other circle.
I do not want to go into a lot of detail here, because the JMS Documentation is very good. This post is more an abridged description, with working code. Install ActiveMQ First install ActiveMQ as per my previous post. Start ActiveMQ …
/usr/libexec/java_home -V this will list all the Java Versions on the machine select the specific version using: export JAVA_HOME=`/usr/libexec/java_home -v 1.8.0_125` or just specify the major number export JAVA_HOME=`/usr/libexec/java_home -v 1.8` Now run java -version Facebook0Tweet0Pin0