You already know from your research, I guess, that the dot product of two normalized vectors is the cosine of the angle between them. There are a whole bunch of little pieces here:
1) How you represent a vector -- an array, a class?
2) Routines to add and subtract points and vectors, because to compute the dot product between two line segments, you have to turn them into two vectors (i.e., segments with one end at the origin)
3) A dot product routine
4) A way to get the angle from the cosine (Math.acos() will work for this)
It's nice if all this stuff works together. You can either write your own, or do yourself a favor and use a preexisting one. There are many, but one in common use is the
javax.vecmath package, originally part of Java3D, now being developed by the java.net folks
here. With vecmath, this would look something like
Vector2d horizon = new Vector2f(1, 0);
Vector2d click = new Vector2f(clickx, clicky);
click.normalize();
double angle = horizon.angle(click);
And that's it!