Floating "boxes" applet with drag events need ckick events

I Have an applet cobbled from the net & modified. Is works but needs one major event added. It draws "Graphics.drawline" boxes with a text "String" inside each box ( the text string represents an URL location). These "boxes" are objects which are "draggable to other locations on canvas & therefore can be independently positioned by user. Each box redraws itself periodically to a slightly different screen location & becomes stationary after a 5 or 6 seconds. The point is, all of this "drag & mobility" behavior must remain intact & is not part of the "problem task".
Task: Need to have an "event" behavior added in one of two ways ( or a 3rd way if there is another ) whichever is quickest/ easiest. "Clickable mouse events" must be added to each box. ( boxes are built in a loop so adding to one will add to other locations & create as many "buttons" as there are boxes) . At each box's location, clicking one box should be an event which fires & clicking a different box should be a separate event which fires. Separate , so that URL location can be "hotlinked" to each box. That URL is currently displayed in the boxes (visible when running applet).
1st possible solution: Exchange these "boxes" which appear on canvas into clickable event "Graph panel.buttons" ( for example or some other clickable object) which maintains existing "drag" behavior of boxes. These buttons must each have "clickability" with mouse events to enable placing "getAppletContext. showDocument()" code with these events ( e.g., "hotlinked" to http locations).
or
2nd possible solution:. The drawstring boxes are currently dead string text with no event model other than the "drag" feature associated with each box. Must add an additional mouse event behavior to existing boxes so they are "clickable" ( or text inside is clickable) and can then execute "showDocument()" URL when clicked independently.
Maybe there is a #3. I don't know what that would be. Open to try anything without losing the drag & placement mobility of existing boxes.
These "boxes" could be images, or event buttons - doesnt matter.
Not sure if #2 is possible & have not been able to accomplish #1. Must stay within existing AWT framework so IE browsers can run it natively ( which of course IE cannot run Swing graphics unless a Sun plugin loaded ).
Applet is a single file ( creating 4 classes).
html file (which invokes it) passes a string param which is broken into above noted URL strings in each box.
Running this applet, you see a "button" event ( at base of canvas labeled "NewUrl" ) which pops up an url location when clicked ( using "showdocument"). This button is not attached to locations or text of each box object ( which is the "task" to accomplish) . The button does represent the kind of event behavior which each "box" should have when task is achieved. So the box can be exchanged with buttons or the boxes can be imbued with events to hyperlink like a button.
In spirit of solution #1, here is the bonehead attempt I tried which did not work: copied entire "if" block of logic from the button event (sited in preceding paragraph) into region of code which builds boxes ( "for" loop of "drawstring" method).
"g.drawString(doit, x - (w-10)/2, (y - (h-4)/2) + fm.getAscent());"
I copied all the "if" block of logic for button creation into the area immediately after the above line ( for loop which builds the boxes). Hoping that I could create buttons with events, along with all the boxes (which are getting created using "drawstring" above in a "for" loop). These "buttons" must also have positioning info of each box to appear in different locations on the canvas. Positioning data is not in that "if" block of code but it would have been a start to get the multiple buttons created ( even if all drawn in one spot). The "if" code block I've provieded for an example begins with the line:
" if ("NewUrl".equals(arg)) { "
and ends with with lines:
" return true; "
" } " //< -- end of above if block
This full "if" block can be seen in the listing below:
This "if" block creates the "NewUrl" button. Of course, I got a bunch of errors when I tried to copy this block to the above location:
variable: "arg" "not found in class GraphPanel".
methods: "getcodebase, showstatus, getappletcontext()"
"not found in class GraphPanel".
----------- The applet code in total follows next
Here are both the java & htm complete source.
import java.net.MalformedURLException;
import java.net.URL;
import java.net.*;
import java.util.*;
import java.awt.*;
import java.applet.Applet;
import java.applet.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.event.*;
class Node {
double x;
double y;
double dx;
double dy;
boolean fixed;
String lbl;
class Edge {
int from;
int to;
double len;
} // eEdgeCla
class GraphPanel extends Panel implements Runnable {
Box box;
int nnodes;
Node nodes[] = new Node[100];
int nedges;
Edge edges[] = new Edge[200];
Thread relaxer;
boolean showit;
boolean random;
GraphPanel(Box box) {
this.box = box;
} //ebox
int findNode(String lbl) {
for (int i = 0 ; i < nnodes ; i++) {
if (nodes.lbl.equals(lbl)) {
return i;
return addNode(lbl);
int addNode(String lbl) {
Node n = new Node();
n.x = 10 + 380*Math.random();
n.y = 10 + 380*Math.random();
n.lbl = lbl;
nodes[nnodes] = n;
return nnodes++;
void addEdge(String from, String to, int len) {
Edge e = new Edge();
e.from = findNode(from);
e.to = findNode(to);
e.len = len;
edges[nedges++] = e;
public void run() {
int i3=0;
while (true) {
relax();
if (random && (Math.random() < 0.03)) {
Node n = nodes[(int) (1 * nnodes) ]; // no
if (!n.fixed) {
n.x += (100*0.02) - 50;
n.y += (100*0.02) - 50; //
try {
Thread.sleep(4000);
} catch (InterruptedException e) {
break;
i3++;
} //ew
} // epublrun()
synchronized void relax() {
for (int i = 0 ; i < nedges ; i++) {
Edge e = edges;
double vx = nodes[e.to].x - nodes[e.from].x;
double vy = nodes[e.to].y - nodes[e.from].y;
double len = Math.sqrt(vx * vx + vy * vy);
double f = (edges.len - len) / (len * 3) ;
double dx = f * vx;
double dy = f * vy;
nodes[e.to].dx += dx;
nodes[e.to].dy += dy;
nodes[e.from].dx += -dx;
nodes[e.from].dy += -dy;
} //efo
for (int i = 0 ; i < nnodes ; i++) {
Node n1 = nodes;
double dx = 0;
double dy = 0;
for (int j = 0 ; j < nnodes ; j++) {
if (i == j) {
continue;
Node n2 = nodes[j];
double vx = n1.x - n2.x;
double vy = n1.y - n2.y;
double len = vx * vx + vy * vy;
if (len == 0) {
dx += 0.02;
dy += 0.02;
} else if (len < 100*100) {
dx += vx / len;
dy += vy / len;
} //ef3a
double dlen = dx * dx + dy * dy;
if (dlen > 0) {
dlen = Math.sqrt(dlen) / 2;
n1.dx += dx / dlen;
n1.dy += dy / dlen;
} //ef3
Dimension d = size();
// f4
for (int i = 0 ; i < nnodes ; i++) {
Node n = nodes;
if (!n.fixed) {
n.x += Math.max(-5, Math.min(5, n.dx));
n.y += Math.max(-5, Math.min(5, n.dy));
if (n.x < 0) {
n.x = 0;
} else if (n.x > d.width) {
n.x = d.width;
if (n.y < 0) {
n.y = 0;
} else if (n.y > d.height) {
n.y = d.height;
n.dx /= 2;
n.dy /= 2;
repaint();
Node pick;
boolean pickfixed;
Image offscreen;
Dimension offscreensize;
Graphics offgraphics;
final Color fixedColor = Color.green;
final Color selectColor = Color.gray;
final Color edgeColor = Color.black;
final Color nodeColor = new Color(200, 90, 50);
final Color showitColor = Color.gray;
final Color arcColor1 = Color.black;
final Color arcColor2 = Color.orange;
final Color arcColor3 = Color.blue;
public void paintNode( Graphics g, Node n, FontMetrics fm) {
int x = (int)n.x;
int y = (int)n.y;
g.setColor((n == pick) ? selectColor : (n.fixed ? fixedColor : nodeColor));
int w = fm.stringWidth(n.lbl) + 10;
int h = fm.getHeight() + 4;
g.fillRect(x - w/2, y - h / 2, w, h);
g.setColor(Color.black);
g.drawRect(x - w/2, y - h / 2, w-1, h-1);
String doit = n.lbl.replace('x','/');
g.drawString(doit, x - (w-10)/2, (y - (h-4)/2) + fm.getAscent());
} // epa
public synchronized void update(Graphics g) {
Dimension d = size();
if ((offscreen == null) || (d.width != offscreensize.width) || (d.height != offscreensize.height)) {
offscreen = createImage(d.width, d.height);
offscreensize = d;
offgraphics = offscreen.getGraphics();
offgraphics.setFont(getFont());
offgraphics.setColor(getBackground());
offgraphics.fillRect(0, 0, d.width, d.height);
for (int i = 0 ; i < nedges ; i++) {
Edge e = edges;
int x1 = (int)nodes[e.from].x;
int y1 = (int)nodes[e.from].y;
int x2 = (int)nodes[e.to].x;
int y2 = (int)nodes[e.to].y;
int len = (int)Math.abs(Math.sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2)) - e.len);
offgraphics.setColor((len < 10) ? arcColor1 : (len < 20 ? arcColor2 : arcColor3)) ;
offgraphics.drawLine(x1, y1, x2, y2);
if (showit) {
String lbl = String.valueOf(len);
offgraphics.setColor(showitColor);
offgraphics.drawString("href= http://localhost:"+lbl, x1 + (x2-x1)/2, y1 + (y2-y1)/2);
offgraphics.setColor(edgeColor);
} //ef5
FontMetrics fm = offgraphics.getFontMetrics();
for (int i = 0 ; i < nnodes ; i++) {
paintNode( offgraphics, nodes, fm); //or
g.drawImage(offscreen, 0, 0, null);
public synchronized boolean mouseDown(Event evt, int x, int y) {
double bestdist = Double.MAX_VALUE;
for (int i = 0 ; i < nnodes ; i++) {
Node n = nodes;
double dist = (n.x - x) * (n.x - x) + (n.y - y) * (n.y - y);
if (dist < bestdist) {
pick = n;
bestdist = dist;
pickfixed = pick.fixed;
pick.fixed = true;
pick.x = x;
pick.y = y;
repaint();
return true;
public synchronized boolean mouseDrag(Event evt, int x, int y) {
pick.x = x;
pick.y = y;
repaint();
return true;
} //e-pubsyncmousedrag
public synchronized boolean mouseUp(Event evt, int x, int y) {
pick.x = x;
pick.y = y;
pick.fixed = pickfixed;
pick = null;
repaint();
return true;
public void start() {
relaxer = new Thread(this);
relaxer.start();
public void stop() {
relaxer.stop();
public class Box extends Applet {
GraphPanel panel;
public void init() {
setLayout(new BorderLayout());
panel = new GraphPanel(this);
add("Center", panel);
Panel p = new Panel();
add("South", p);
p.add(new Button("Reposition"));
p.add(new Button("NewUrl"));
p.add(new Checkbox("Showit"));
String edges = getParameter("edges"); // putinli
for (StringTokenizer t = new StringTokenizer(edges, ",") ; t.hasMoreTokens() ; ) {
String str = t.nextToken();
int i = str.indexOf('-');
if (i > 0) { int len = 50;
int j = str.indexOf('/');
if (j > 0) {
len = Integer.valueOf(str.substring(j+1)).intValue();
str = str.substring(0, j);
panel.addEdge(str.substring(0,i), str.substring(i+1), len);
} //ef8
Dimension d = size();
String center = getParameter("center");
if (center != null){
Node n = panel.nodes[panel.findNode(center)];
n.x = d.width / 2;
n.y = d.height / 2;
n.fixed = true;
} // eif
} // ep
public void start() {
panel.start();
public void stop() {
panel.stop();
public boolean action(Event evt, Object arg) {
if (arg instanceof Boolean) {
if (((Checkbox)evt.target).getLabel().equals("Showit")) {
panel.showit = ((Boolean)arg).booleanValue();
}// e-
else {
panel.random = ((Boolean)arg).booleanValue();
return true;
} // e-if instof bool
if ("Reposition".equals(arg)) {
Dimension d = size();
for (int i = 0 ; i < panel.nnodes ; i++) {
Node n = panel.nodes;
if (!n.fixed) {
n.x = 10 + (d.width-20)*Math.random();
n.y = 10 + (d.height-20)*Math.random();
} //ei
} //ef9
return true;
} //eif scram
if ("NewUrl".equals(arg)) {
Dimension d = size();
URL url = getCodeBase();
try {
getAppletContext().showDocument( new URL(url+"main.htm"), "_blank" );
try {
Thread.sleep(1000);
} catch (InterruptedException e) { }
} catch(MalformedURLException e) {
showStatus("814 URL not found");
for (int i = 0 ; i < panel.nnodes ; i++) {
Node n = panel.nodes;
if (!n.fixed) {
n.x += (80*0.02) - 40;
n.y += (80*0.02) - 40;
return true;
} //ei
return false;
-----------------------htm file to launch------------------------------
<html>
<head>
<title>R
</title>
</head>
<body>
<h3>
<center>
R
</center>
</h3>
I
<b>
</b>
<table border = 1>
<td>De<td>Test List<tr>
<td>N <td><tr>
<td>N <td><tr>
</table>
<b>view </b>
<applet code="Box.class" CODEBASE=. width=1000 height=600
ALT="Test ">
<param name=edges value="http:xxabc.htm-http:xxnet.htm,http:xxthis.htm-http:xx.comet.htm,http:xxnewsighting.htm-http:xxstar.htm,http:xxmoon.htm-http:xxNeptune.htm">
<hr>
</applet>
</b>
<p>
<table border = 1>
<tr>
<tr>
</table>
</html>
</body>
instructions to compile :
0 : The discussion becomes easy to follow after 1st compiling
& viewing the applet.
1. : cut out applet code.
2. : the post somehow deleted all references to "" <--- HERE
see, the data has been deleted again as I preview this post.
( that "" should contain an "i" array increment argument:
"open square bracket" "i" "close square bracket" ) array
so "javac Box.java" will get 10 errors. These "[" "i" "]"
array args must be replaced to compile the code.
3. : All array variables inside the 10 "for" loops ( the bare words
"edges" and "nodes" ) without array increment "i" should
read "edges" "[" "i" "]" & "nodes" "[" "i" "]".
The 10 location lines are approx:
line #65, #129, #136, #149, #195, #283, #311, #331, #477, #522
4. : These 10 edits reqresent a missing "i" to all 10 for loop arrays.
for eddges & nodes. fix this & javac Box.java" will get
4 class files.
5. : cut "Box.htm" from post & do "appletviewer Box.htm"
or put in an apache "htdoc" or tomcat "servlet" http delivered
directory & call "http://localhost/Box.htm.
6. : of course, selecting the event button "NewUrl" will not
work in appletviewer but will work in an http web location.
7. : post your questions to problem or fixes to problem as I'm
monitoring closely. TIA.

Thanks for code post tip to fix array index deletion problem.
Here is code reposted using "code" delimiters which will
compile straight out of cut/paste.
import java.net.MalformedURLException;
import java.net.URL;
import java.net.*;
import java.util.*;
import java.awt.*;
import java.applet.Applet;
import java.applet.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.event.*;
class Node {
double x;
double y;
double dx;
double dy;
boolean fixed;
String lbl;
class Edge {
int from;
int to;
double len;
} // eEdgeCla
class GraphPanel extends Panel implements Runnable {
Box box;
int nnodes;
Node nodes[] = new Node[100];
int nedges;
Edge edges[] = new Edge[200];
Thread relaxer;
boolean showit;
boolean random;
GraphPanel(Box box) {
this.box = box;
} //ebox
int findNode(String lbl) {
for (int i = 0 ; i < nnodes ; i++) {
//if (nodes.lbl.equals(lbl)) {
  if (nodes.lbl.equals(lbl)) {
return i;
return addNode(lbl);
int addNode(String lbl) {
Node n = new Node();
n.x = 10 + 380*Math.random();
n.y = 10 + 380*Math.random();
n.lbl = lbl;
nodes[nnodes] = n;
return nnodes++;
void addEdge(String from, String to, int len) {
Edge e = new Edge();
e.from = findNode(from);
e.to = findNode(to);
e.len = len;
edges[nedges++] = e;
public void run() {
int i3=0;
while (true) {
relax();
if (random && (Math.random() < 0.03)) {
Node n = nodes[(int) (1 * nnodes) ]; // no
if (!n.fixed) {
n.x += (100*0.02) - 50;
n.y += (100*0.02) - 50; //
try {
Thread.sleep(4000);
} catch (InterruptedException e) {
break;
i3++;
} //ew
} // epublrun()
synchronized void relax() {
for (int i = 0 ; i < nedges ; i++) {
//Edge e = edges;
Edge e = edges[i];
double vx = nodes[e.to].x - nodes[e.from].x;
double vy = nodes[e.to].y - nodes[e.from].y;
double len = Math.sqrt(vx * vx + vy * vy);
//double f = (edges.len - len) / (len * 3) ;
double f = (edges[i].len - len) / (len * 3) ;
double dx = f * vx;
double dy = f * vy;
nodes[e.to].dx += dx;
nodes[e.to].dy += dy;
nodes[e.from].dx += -dx;
nodes[e.from].dy += -dy;
} //efo
for (int i = 0 ; i < nnodes ; i++) {
//Node n1 = nodes[i];
Node n1 = nodes[i];
double dx = 0;
double dy = 0;
for (int j = 0 ; j < nnodes ; j++) {
if (i == j) {
continue;
Node n2 = nodes[j];
double vx = n1.x - n2.x;
double vy = n1.y - n2.y;
double len = vx * vx + vy * vy;
if (len == 0) {
dx += 0.02;
dy += 0.02;
} else if (len < 100*100) {
dx += vx / len;
dy += vy / len;
} //ef3a
double dlen = dx * dx + dy * dy;
if (dlen > 0) {
dlen = Math.sqrt(dlen) / 2;
n1.dx += dx / dlen;
n1.dy += dy / dlen;
} //ef3
Dimension d = size();
// f4
for (int i = 0 ; i < nnodes ; i++) {
//Node n = nodes;
Node n = nodes[i];
if (!n.fixed) {
n.x += Math.max(-5, Math.min(5, n.dx));
n.y += Math.max(-5, Math.min(5, n.dy));
if (n.x < 0) {
n.x = 0;
} else if (n.x > d.width) {
n.x = d.width;
if (n.y < 0) {
n.y = 0;
} else if (n.y > d.height) {
n.y = d.height;
n.dx /= 2;
n.dy /= 2;
repaint();
Node pick;
boolean pickfixed;
Image offscreen;
Dimension offscreensize;
Graphics offgraphics;
final Color fixedColor = Color.green;
final Color selectColor = Color.gray;
final Color edgeColor = Color.black;
final Color nodeColor = new Color(200, 90, 50);
final Color showitColor = Color.gray;
final Color arcColor1 = Color.black;
final Color arcColor2 = Color.orange;
final Color arcColor3 = Color.blue;
public void paintNode( Graphics g, Node n, FontMetrics fm) {
int x = (int)n.x;
int y = (int)n.y;
g.setColor((n == pick) ? selectColor : (n.fixed ? fixedColor : nodeColor));
int w = fm.stringWidth(n.lbl) + 10;
int h = fm.getHeight() + 4;
g.fillRect(x - w/2, y - h / 2, w, h);
g.setColor(Color.black);
g.drawRect(x - w/2, y - h / 2, w-1, h-1);
String doit = n.lbl.replace('x','/');
g.drawString(doit, x - (w-10)/2, (y - (h-4)/2) + fm.getAscent());
} // epa
public synchronized void update(Graphics g) {
Dimension d = size();
if ((offscreen == null) || (d.width != offscreensize.width) || (d.height != offscreensize.height)) {
offscreen = createImage(d.width, d.height);
offscreensize = d;
offgraphics = offscreen.getGraphics();
offgraphics.setFont(getFont());
offgraphics.setColor(getBackground());
offgraphics.fillRect(0, 0, d.width, d.height);
for (int i = 0 ; i < nedges ; i++) {
//Edge e = edges;
Edge e = edges[i];
int x1 = (int)nodes[e.from].x;
int y1 = (int)nodes[e.from].y;
int x2 = (int)nodes[e.to].x;
int y2 = (int)nodes[e.to].y;
int len = (int)Math.abs(Math.sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2)) - e.len);
offgraphics.setColor((len < 10) ? arcColor1 : (len < 20 ? arcColor2 : arcColor3)) ;
offgraphics.drawLine(x1, y1, x2, y2);
if (showit) {
String lbl = String.valueOf(len);
offgraphics.setColor(showitColor);
offgraphics.drawString("href= http://localhost:"+lbl, x1 + (x2-x1)/2, y1 + (y2-y1)/2);
offgraphics.setColor(edgeColor);
} //ef5
FontMetrics fm = offgraphics.getFontMetrics();
for (int i = 0 ; i < nnodes ; i++) {
//paintNode( offgraphics, nodes, fm); //or
paintNode( offgraphics, nodes[i], fm); //or
g.drawImage(offscreen, 0, 0, null);
public synchronized boolean mouseDown(Event evt, int x, int y) {
double bestdist = Double.MAX_VALUE;
for (int i = 0 ; i < nnodes ; i++) {
//Node n = nodes;
Node n = nodes[i];
double dist = (n.x - x) * (n.x - x) + (n.y - y) * (n.y - y);
if (dist < bestdist) {
pick = n;
bestdist = dist;
pickfixed = pick.fixed;
pick.fixed = true;
pick.x = x;
pick.y = y;
repaint();
return true;
public synchronized boolean mouseDrag(Event evt, int x, int y) {
pick.x = x;
pick.y = y;
repaint();
return true;
} //e-pubsyncmousedrag
public synchronized boolean mouseUp(Event evt, int x, int y) {
pick.x = x;
pick.y = y;
pick.fixed = pickfixed;
pick = null;
repaint();
return true;
public void start() {
relaxer = new Thread(this);
relaxer.start();
public void stop() {
relaxer.stop();
public class Box extends Applet {
GraphPanel panel;
public void init() {
setLayout(new BorderLayout());
panel = new GraphPanel(this);
add("Center", panel);
Panel p = new Panel();
add("South", p);
p.add(new Button("Reposition"));
p.add(new Button("NewUrl"));
p.add(new Checkbox("Showit"));
String edges = getParameter("edges"); // putinli
for (StringTokenizer t = new StringTokenizer(edges, ",") ; t.hasMoreTokens() ; ) {
String str = t.nextToken();
int i = str.indexOf('-');
if (i > 0) { int len = 50;
int j = str.indexOf('/');
if (j > 0) {
len = Integer.valueOf(str.substring(j+1)).intValue();
str = str.substring(0, j);
panel.addEdge(str.substring(0,i), str.substring(i+1), len);
} //ef8
Dimension d = size();
String center = getParameter("center");
if (center != null){
Node n = panel.nodes[panel.findNode(center)];
n.x = d.width / 2;
n.y = d.height / 2;
n.fixed = true;
} // eif
} // ep
public void start() {
panel.start();
public void stop() {
panel.stop();
public boolean action(Event evt, Object arg) {
if (arg instanceof Boolean) {
if (((Checkbox)evt.target).getLabel().equals("Showit")) {
panel.showit = ((Boolean)arg).booleanValue();
}// e-
else {
panel.random = ((Boolean)arg).booleanValue();
return true;
} // e-if instof bool
if ("Reposition".equals(arg)) {
Dimension d = size();
for (int i = 0 ; i < panel.nnodes ; i++) {
//Node n = panel.nodes;
Node n = panel.nodes[i];
if (!n.fixed) {
n.x = 10 + (d.width-20)*Math.random();
n.y = 10 + (d.height-20)*Math.random();
} //ei
} //ef9
return true;
} //eif scram
if ("NewUrl".equals(arg)) {
Dimension d = size();
URL url = getCodeBase();
try {
getAppletContext().showDocument( new URL(url+"main.htm"), "_blank" );
try {
Thread.sleep(1000);
} catch (InterruptedException e) { }
} catch(MalformedURLException e) {
showStatus("814 URL not found");
for (int i = 0 ; i < panel.nnodes ; i++) {
//Node n = panel.nodes;
Node n = panel.nodes[i];
if (!n.fixed) {
n.x += (80*0.02) - 40;
n.y += (80*0.02) - 40;
return true;
} //ei
return false;

Similar Messages

  • Floating boxes applet with drag events need click event

    I Have an applet cobbled from the net & modified. Is works but needs one major event added. It draws "Graphics.drawline" boxes with a text "String" inside each box ( the text string represents an URL location). These "boxes" are objects which are "draggable to other locations on canvas & therefore can be independently positioned by user. Each box redraws itself periodically to a slightly different screen location & becomes stationary after a 5 or 6 seconds. The point is, all of this "drag & mobility" behavior must remain intact & is not part of the "problem task".
    Task: Need to have an "event" behavior added in one of two ways ( or a 3rd way if there is another ) whichever is quickest/ easiest. "Clickable mouse events" must be added to each box. ( boxes are built in a loop so adding to one will add to other locations & create as many "buttons" as there are boxes) . At each box's location, clicking one box should be an event which fires & clicking a different box should be a separate event which fires. Separate , so that URL location can be "hotlinked" to each box. That URL is currently displayed in the boxes (visible when running applet).
    1st possible solution: Exchange these "boxes" which appear on canvas into clickable event "Graph panel.buttons" ( for example or some other clickable object) which maintains existing "drag" behavior of boxes. These buttons must each have "clickability" with mouse events to enable placing "getAppletContext. showDocument()" code with these events ( e.g., "hotlinked" to http locations).
    or
    2nd possible solution:. The drawstring boxes are currently dead string text with no event model other than the "drag" feature associated with each box. Must add an additional mouse event behavior to existing boxes so they are "clickable" ( or text inside is clickable) and can then execute "showDocument()" URL when clicked independently.
    Maybe there is a #3. I don't know what that would be. Open to try anything without losing the drag & placement mobility of existing boxes.
    These "boxes" could be images, or event buttons - doesnt matter.
    Not sure if #2 is possible & have not been able to accomplish #1. Must stay within existing AWT framework so IE browsers can run it natively ( which of course IE cannot run Swing graphics unless a Sun plugin loaded ).
    Applet is a single file ( creating 4 classes).
    html file (which invokes it) passes a string param which is broken into above noted URL strings in each box.
    Running this applet, you see a "button" event ( at base of canvas labeled "NewUrl" ) which pops up an url location when clicked ( using "showdocument"). This button is not attached to locations or text of each box object ( which is the "task" to accomplish) . The button does represent the kind of event behavior which each "box" should have when task is achieved. So the box can be exchanged with buttons or the boxes can be imbued with events to hyperlink like a button.
    In spirit of solution #1, here is the bonehead attempt I tried which did not work: copied entire "if" block of logic from the button event (sited in preceding paragraph) into region of code which builds boxes ( "for" loop of "drawstring" method).
    "g.drawString(doit, x - (w-10)/2, (y - (h-4)/2) + fm.getAscent());"
    I copied all the "if" block of logic for button creation into the area immediately after the above line ( for loop which builds the boxes). Hoping that I could create buttons with events, along with all the boxes (which are getting created using "drawstring" above in a "for" loop). These "buttons" must also have positioning info of each box to appear in different locations on the canvas. Positioning data is not in that "if" block of code but it would have been a start to get the multiple buttons created ( even if all drawn in one spot). The "if" code block I've provieded for an example begins with the line:
    " if ("NewUrl".equals(arg)) { "
    and ends with with lines:
    " return true; "
    " } " //< -- end of above if block
    This full "if" block can be seen in the listing below:
    This "if" block creates the "NewUrl" button. Of course, I got a bunch of errors when I tried to copy this block to the above location:
    variable: "arg" "not found in class GraphPanel".
    methods: "getcodebase, showstatus, getappletcontext()"
    "not found in class GraphPanel".
    ----------- The applet code in total follows next
    Here are both the java & htm complete source.
    import java.net.MalformedURLException;
    import java.net.URL;
    import java.net.*;
    import java.util.*;
    import java.awt.*;
    import java.applet.Applet;
    import java.applet.*;
    import java.awt.event.WindowAdapter;
    import java.awt.event.WindowEvent;
    import java.awt.event.*;
    class Node {
    double x;
    double y;
    double dx;
    double dy;
    boolean fixed;
    String lbl;
    class Edge {
    int from;
    int to;
    double len;
    } // eEdgeCla
    class GraphPanel extends Panel implements Runnable {
    Box box;
    int nnodes;
    Node nodes[] = new Node[100];
    int nedges;
    Edge edges[] = new Edge[200];
    Thread relaxer;
    boolean showit;
    boolean random;
    GraphPanel(Box box) {
    this.box = box;
    } //ebox
    int findNode(String lbl) {
    for (int i = 0 ; i < nnodes ; i++) {
    if (nodes.lbl.equals(lbl)) {
    return i;
    return addNode(lbl);
    int addNode(String lbl) {
    Node n = new Node();
    n.x = 10 + 380*Math.random();
    n.y = 10 + 380*Math.random();
    n.lbl = lbl;
    nodes[nnodes] = n;
    return nnodes++;
    void addEdge(String from, String to, int len) {
    Edge e = new Edge();
    e.from = findNode(from);
    e.to = findNode(to);
    e.len = len;
    edges[nedges++] = e;
    public void run() {
    int i3=0;
    while (true) {
    relax();
    if (random && (Math.random() < 0.03)) {
    Node n = nodes[(int) (1 * nnodes) ]; // no
    if (!n.fixed) {
    n.x += (100*0.02) - 50;
    n.y += (100*0.02) - 50; //
    try {
    Thread.sleep(4000);
    } catch (InterruptedException e) {
    break;
    i3++;
    } //ew
    } // epublrun()
    synchronized void relax() {
    for (int i = 0 ; i < nedges ; i++) {
    Edge e = edges;
    double vx = nodes[e.to].x - nodes[e.from].x;
    double vy = nodes[e.to].y - nodes[e.from].y;
    double len = Math.sqrt(vx * vx + vy * vy);
    double f = (edges.len - len) / (len * 3) ;
    double dx = f * vx;
    double dy = f * vy;
    nodes[e.to].dx += dx;
    nodes[e.to].dy += dy;
    nodes[e.from].dx += -dx;
    nodes[e.from].dy += -dy;
    } //efo
    for (int i = 0 ; i < nnodes ; i++) {
    Node n1 = nodes;
    double dx = 0;
    double dy = 0;
    for (int j = 0 ; j < nnodes ; j++) {
    if (i == j) {
    continue;
    Node n2 = nodes[j];
    double vx = n1.x - n2.x;
    double vy = n1.y - n2.y;
    double len = vx * vx + vy * vy;
    if (len == 0) {
    dx += 0.02;
    dy += 0.02;
    } else if (len < 100*100) {
    dx += vx / len;
    dy += vy / len;
    } //ef3a
    double dlen = dx * dx + dy * dy;
    if (dlen > 0) {
    dlen = Math.sqrt(dlen) / 2;
    n1.dx += dx / dlen;
    n1.dy += dy / dlen;
    } //ef3
    Dimension d = size();
    // f4
    for (int i = 0 ; i < nnodes ; i++) {
    Node n = nodes;
    if (!n.fixed) {
    n.x += Math.max(-5, Math.min(5, n.dx));
    n.y += Math.max(-5, Math.min(5, n.dy));
    if (n.x < 0) {
    n.x = 0;
    } else if (n.x > d.width) {
    n.x = d.width;
    if (n.y < 0) {
    n.y = 0;
    } else if (n.y > d.height) {
    n.y = d.height;
    n.dx /= 2;
    n.dy /= 2;
    repaint();
    Node pick;
    boolean pickfixed;
    Image offscreen;
    Dimension offscreensize;
    Graphics offgraphics;
    final Color fixedColor = Color.green;
    final Color selectColor = Color.gray;
    final Color edgeColor = Color.black;
    final Color nodeColor = new Color(200, 90, 50);
    final Color showitColor = Color.gray;
    final Color arcColor1 = Color.black;
    final Color arcColor2 = Color.orange;
    final Color arcColor3 = Color.blue;
    public void paintNode( Graphics g, Node n, FontMetrics fm) {
    int x = (int)n.x;
    int y = (int)n.y;
    g.setColor((n == pick) ? selectColor : (n.fixed ? fixedColor : nodeColor));
    int w = fm.stringWidth(n.lbl) + 10;
    int h = fm.getHeight() + 4;
    g.fillRect(x - w/2, y - h / 2, w, h);
    g.setColor(Color.black);
    g.drawRect(x - w/2, y - h / 2, w-1, h-1);
    String doit = n.lbl.replace('x','/');
    g.drawString(doit, x - (w-10)/2, (y - (h-4)/2) + fm.getAscent());
    } // epa
    public synchronized void update(Graphics g) {
    Dimension d = size();
    if ((offscreen == null) || (d.width != offscreensize.width) || (d.height != offscreensize.height)) {
    offscreen = createImage(d.width, d.height);
    offscreensize = d;
    offgraphics = offscreen.getGraphics();
    offgraphics.setFont(getFont());
    offgraphics.setColor(getBackground());
    offgraphics.fillRect(0, 0, d.width, d.height);
    for (int i = 0 ; i < nedges ; i++) {
    Edge e = edges;
    int x1 = (int)nodes[e.from].x;
    int y1 = (int)nodes[e.from].y;
    int x2 = (int)nodes[e.to].x;
    int y2 = (int)nodes[e.to].y;
    int len = (int)Math.abs(Math.sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2)) - e.len);
    offgraphics.setColor((len < 10) ? arcColor1 : (len < 20 ? arcColor2 : arcColor3)) ;
    offgraphics.drawLine(x1, y1, x2, y2);
    if (showit) {
    String lbl = String.valueOf(len);
    offgraphics.setColor(showitColor);
    offgraphics.drawString("href= http://localhost:"+lbl, x1 + (x2-x1)/2, y1 + (y2-y1)/2);
    offgraphics.setColor(edgeColor);
    } //ef5
    FontMetrics fm = offgraphics.getFontMetrics();
    for (int i = 0 ; i < nnodes ; i++) {
    paintNode( offgraphics, nodes, fm); //or
    g.drawImage(offscreen, 0, 0, null);
    public synchronized boolean mouseDown(Event evt, int x, int y) {
    double bestdist = Double.MAX_VALUE;
    for (int i = 0 ; i < nnodes ; i++) {
    Node n = nodes;
    double dist = (n.x - x) * (n.x - x) + (n.y - y) * (n.y - y);
    if (dist < bestdist) {
    pick = n;
    bestdist = dist;
    pickfixed = pick.fixed;
    pick.fixed = true;
    pick.x = x;
    pick.y = y;
    repaint();
    return true;
    public synchronized boolean mouseDrag(Event evt, int x, int y) {
    pick.x = x;
    pick.y = y;
    repaint();
    return true;
    } //e-pubsyncmousedrag
    public synchronized boolean mouseUp(Event evt, int x, int y) {
    pick.x = x;
    pick.y = y;
    pick.fixed = pickfixed;
    pick = null;
    repaint();
    return true;
    public void start() {
    relaxer = new Thread(this);
    relaxer.start();
    public void stop() {
    relaxer.stop();
    public class Box extends Applet {
    GraphPanel panel;
    public void init() {
    setLayout(new BorderLayout());
    panel = new GraphPanel(this);
    add("Center", panel);
    Panel p = new Panel();
    add("South", p);
    p.add(new Button("Reposition"));
    p.add(new Button("NewUrl"));
    p.add(new Checkbox("Showit"));
    String edges = getParameter("edges"); // putinli
    for (StringTokenizer t = new StringTokenizer(edges, ",") ; t.hasMoreTokens() ; ) {
    String str = t.nextToken();
    int i = str.indexOf('-');
    if (i > 0) { int len = 50;
    int j = str.indexOf('/');
    if (j > 0) {
    len = Integer.valueOf(str.substring(j+1)).intValue();
    str = str.substring(0, j);
    panel.addEdge(str.substring(0,i), str.substring(i+1), len);
    } //ef8
    Dimension d = size();
    String center = getParameter("center");
    if (center != null){
    Node n = panel.nodes[panel.findNode(center)];
    n.x = d.width / 2;
    n.y = d.height / 2;
    n.fixed = true;
    } // eif
    } // ep
    public void start() {
    panel.start();
    public void stop() {
    panel.stop();
    public boolean action(Event evt, Object arg) {
    if (arg instanceof Boolean) {
    if (((Checkbox)evt.target).getLabel().equals("Showit")) {
    panel.showit = ((Boolean)arg).booleanValue();
    }// e-
    else {
    panel.random = ((Boolean)arg).booleanValue();
    return true;
    } // e-if instof bool
    if ("Reposition".equals(arg)) {
    Dimension d = size();
    for (int i = 0 ; i < panel.nnodes ; i++) {
    Node n = panel.nodes;
    if (!n.fixed) {
    n.x = 10 + (d.width-20)*Math.random();
    n.y = 10 + (d.height-20)*Math.random();
    } //ei
    } //ef9
    return true;
    } //eif scram
    if ("NewUrl".equals(arg)) {
    Dimension d = size();
    URL url = getCodeBase();
    try {
    getAppletContext().showDocument( new URL(url+"main.htm"), "_blank" );
    try {
    Thread.sleep(1000);
    } catch (InterruptedException e) { }
    } catch(MalformedURLException e) {
    showStatus("814 URL not found");
    for (int i = 0 ; i < panel.nnodes ; i++) {
    Node n = panel.nodes;
    if (!n.fixed) {
    n.x += (80*0.02) - 40;
    n.y += (80*0.02) - 40;
    return true;
    } //ei
    return false;
    -----------------------htm file to launch------------------------------
    <html>
    <head>
    <title>R
    </title>
    </head>
    <body>
    <h3>
    <center>
    R
    </center>
    </h3>
    I
    <b>
    </b>
    <table border = 1>
    <td>De<td>Test List<tr>
    <td>N <td><tr>
    <td>N <td><tr>
    </table>
    <b>view </b>
    <applet code="Box.class" CODEBASE=. width=1000 height=600
    ALT="Test ">
    <param name=edges value="http:xxabc.htm-http:xxnet.htm,http:xxthis.htm-http:xx.comet.htm,http:xxnewsighting.htm-http:xxstar.htm,http:xxmoon.htm-http:xxNeptune.htm">
    <hr>
    </applet>
    </b>
    <p>
    <table border = 1>
    <tr>
    <tr>
    </table>
    </html>
    </body>
    instructions to compile :
    0 : The discussion becomes easy to follow after 1st compiling
    & viewing the applet.
    1. : cut out applet code.
    2. : the post somehow deleted all references to "" <--- HERE
    see, the data has been deleted again as I preview this post.
    ( that "" should contain an "i" array increment argument:
    "open square bracket" "i" "close square bracket" ) array
    so "javac Box.java" will get 10 errors. These "[" "i" "]"
    array args must be replaced to compile the code.
    3. : All array variables inside the 10 "for" loops ( the bare words
    "edges" and "nodes" ) without array increment "i" should
    read "edges" "[" "i" "]" & "nodes" "[" "i" "]".
    The 10 location lines are approx:
    line #65, #129, #136, #149, #195, #283, #311, #331, #477, #522
    4. : These 10 edits reqresent a missing "i" to all 10 for loop arrays.
    for eddges & nodes. fix this & javac Box.java" will get
    4 class files.
    5. : cut "Box.htm" from post & do "appletviewer Box.htm"
    or put in an apache "htdoc" or tomcat "servlet" http delivered
    directory & call "http://localhost/Box.htm.
    6. : of course, selecting the event button "NewUrl" will not
    work in appletviewer but will work in an http web location.
    7. : post your questions to problem or fixes to problem as I'm
    monitoring closely. TIA.

    Thanks for code post tip to fix array deletion problem.
    Here is code reposted using delimiters with will
    compile straight out of cut/paste.import java.net.MalformedURLException;
    import java.net.URL;
    import java.net.*;
    import java.util.*;
    import java.awt.*;
    import java.applet.Applet;
    import java.applet.*;
    import java.awt.event.WindowAdapter;
    import java.awt.event.WindowEvent;
    import java.awt.event.*;
    class Node {
    double x;
    double y;
    double dx;
    double dy;
    boolean fixed;
    String lbl;
    class Edge {
    int from;
    int to;
    double len;
    } // eEdgeCla
    class GraphPanel extends Panel implements Runnable {
    Box box;
    int nnodes;
    Node nodes[] = new Node[100];
    int nedges;
    Edge edges[] = new Edge[200];
    Thread relaxer;
    boolean showit;
    boolean random;
    GraphPanel(Box box) {
    this.box = box;
    } //ebox
    int findNode(String lbl) {
    for (int i = 0 ; i < nnodes ; i++) {
    //if (nodes.lbl.equals(lbl)) {
    if (nodes.lbl.equals(lbl)) {
    return i;
    return addNode(lbl);
    int addNode(String lbl) {
    Node n = new Node();
    n.x = 10 + 380*Math.random();
    n.y = 10 + 380*Math.random();
    n.lbl = lbl;
    nodes[nnodes] = n;
    return nnodes++;
    void addEdge(String from, String to, int len) {
    Edge e = new Edge();
    e.from = findNode(from);
    e.to = findNode(to);
    e.len = len;
    edges[nedges++] = e;
    public void run() {
    int i3=0;
    while (true) {
    relax();
    if (random && (Math.random() < 0.03)) {
    Node n = nodes[(int) (1 * nnodes) ]; // no
    if (!n.fixed) {
    n.x += (100*0.02) - 50;
    n.y += (100*0.02) - 50; //
    try {
    Thread.sleep(4000);
    } catch (InterruptedException e) {
    break;
    i3++;
    } //ew
    } // epublrun()
    synchronized void relax() {
    for (int i = 0 ; i < nedges ; i++) {
    //Edge e = edges;
    Edge e = edges[i];
    double vx = nodes[e.to].x - nodes[e.from].x;
    double vy = nodes[e.to].y - nodes[e.from].y;
    double len = Math.sqrt(vx * vx + vy * vy);
    //double f = (edges.len - len) / (len * 3) ;
    double f = (edges[i].len - len) / (len * 3) ;
    double dx = f * vx;
    double dy = f * vy;
    nodes[e.to].dx += dx;
    nodes[e.to].dy += dy;
    nodes[e.from].dx += -dx;
    nodes[e.from].dy += -dy;
    } //efo
    for (int i = 0 ; i < nnodes ; i++) {
    //Node n1 = nodes[i];
    Node n1 = nodes[i];
    double dx = 0;
    double dy = 0;
    for (int j = 0 ; j < nnodes ; j++) {
    if (i == j) {
    continue;
    Node n2 = nodes[j];
    double vx = n1.x - n2.x;
    double vy = n1.y - n2.y;
    double len = vx * vx + vy * vy;
    if (len == 0) {
    dx += 0.02;
    dy += 0.02;
    } else if (len < 100*100) {
    dx += vx / len;
    dy += vy / len;
    } //ef3a
    double dlen = dx * dx + dy * dy;
    if (dlen > 0) {
    dlen = Math.sqrt(dlen) / 2;
    n1.dx += dx / dlen;
    n1.dy += dy / dlen;
    } //ef3
    Dimension d = size();
    // f4
    for (int i = 0 ; i < nnodes ; i++) {
    //Node n = nodes;
    Node n = nodes[i];
    if (!n.fixed) {
    n.x += Math.max(-5, Math.min(5, n.dx));
    n.y += Math.max(-5, Math.min(5, n.dy));
    if (n.x < 0) {
    n.x = 0;
    } else if (n.x > d.width) {
    n.x = d.width;
    if (n.y < 0) {
    n.y = 0;
    } else if (n.y > d.height) {
    n.y = d.height;
    n.dx /= 2;
    n.dy /= 2;
    repaint();
    Node pick;
    boolean pickfixed;
    Image offscreen;
    Dimension offscreensize;
    Graphics offgraphics;
    final Color fixedColor = Color.green;
    final Color selectColor = Color.gray;
    final Color edgeColor = Color.black;
    final Color nodeColor = new Color(200, 90, 50);
    final Color showitColor = Color.gray;
    final Color arcColor1 = Color.black;
    final Color arcColor2 = Color.orange;
    final Color arcColor3 = Color.blue;
    public void paintNode( Graphics g, Node n, FontMetrics fm) {
    int x = (int)n.x;
    int y = (int)n.y;
    g.setColor((n == pick) ? selectColor : (n.fixed ? fixedColor : nodeColor));
    int w = fm.stringWidth(n.lbl) + 10;
    int h = fm.getHeight() + 4;
    g.fillRect(x - w/2, y - h / 2, w, h);
    g.setColor(Color.black);
    g.drawRect(x - w/2, y - h / 2, w-1, h-1);
    String doit = n.lbl.replace('x','/');
    g.drawString(doit, x - (w-10)/2, (y - (h-4)/2) + fm.getAscent());
    } // epa
    public synchronized void update(Graphics g) {
    Dimension d = size();
    if ((offscreen == null) || (d.width != offscreensize.width) || (d.height != offscreensize.height)) {
    offscreen = createImage(d.width, d.height);
    offscreensize = d;
    offgraphics = offscreen.getGraphics();
    offgraphics.setFont(getFont());
    offgraphics.setColor(getBackground());
    offgraphics.fillRect(0, 0, d.width, d.height);
    for (int i = 0 ; i < nedges ; i++) {
    //Edge e = edges;
    Edge e = edges[i];
    int x1 = (int)nodes[e.from].x;
    int y1 = (int)nodes[e.from].y;
    int x2 = (int)nodes[e.to].x;
    int y2 = (int)nodes[e.to].y;
    int len = (int)Math.abs(Math.sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2)) - e.len);
    offgraphics.setColor((len < 10) ? arcColor1 : (len < 20 ? arcColor2 : arcColor3)) ;
    offgraphics.drawLine(x1, y1, x2, y2);
    if (showit) {
    String lbl = String.valueOf(len);
    offgraphics.setColor(showitColor);
    offgraphics.drawString("href= http://localhost:"+lbl, x1 + (x2-x1)/2, y1 + (y2-y1)/2);
    offgraphics.setColor(edgeColor);
    } //ef5
    FontMetrics fm = offgraphics.getFontMetrics();
    for (int i = 0 ; i < nnodes ; i++) {
    //paintNode( offgraphics, nodes, fm); //or
    paintNode( offgraphics, nodes[i], fm); //or
    g.drawImage(offscreen, 0, 0, null);
    public synchronized boolean mouseDown(Event evt, int x, int y) {
    double bestdist = Double.MAX_VALUE;
    for (int i = 0 ; i < nnodes ; i++) {
    //Node n = nodes;
    Node n = nodes[i];
    double dist = (n.x - x) * (n.x - x) + (n.y - y) * (n.y - y);
    if (dist < bestdist) {
    pick = n;
    bestdist = dist;
    pickfixed = pick.fixed;
    pick.fixed = true;
    pick.x = x;
    pick.y = y;
    repaint();
    return true;
    public synchronized boolean mouseDrag(Event evt, int x, int y) {
    pick.x = x;
    pick.y = y;
    repaint();
    return true;
    } //e-pubsyncmousedrag
    public synchronized boolean mouseUp(Event evt, int x, int y) {
    pick.x = x;
    pick.y = y;
    pick.fixed = pickfixed;
    pick = null;
    repaint();
    return true;
    public void start() {
    relaxer = new Thread(this);
    relaxer.start();
    public void stop() {
    relaxer.stop();
    public class Box extends Applet {
    GraphPanel panel;
    public void init() {
    setLayout(new BorderLayout());
    panel = new GraphPanel(this);
    add("Center", panel);
    Panel p = new Panel();
    add("South", p);
    p.add(new Button("Reposition"));
    p.add(new Button("NewUrl"));
    p.add(new Checkbox("Showit"));
    String edges = getParameter("edges"); // putinli
    for (StringTokenizer t = new StringTokenizer(edges, ",") ; t.hasMoreTokens() ; ) {
    String str = t.nextToken();
    int i = str.indexOf('-');
    if (i > 0) { int len = 50;
    int j = str.indexOf('/');
    if (j > 0) {
    len = Integer.valueOf(str.substring(j+1)).intValue();
    str = str.substring(0, j);
    panel.addEdge(str.substring(0,i), str.substring(i+1), len);
    } //ef8
    Dimension d = size();
    String center = getParameter("center");
    if (center != null){
    Node n = panel.nodes[panel.findNode(center)];
    n.x = d.width / 2;
    n.y = d.height / 2;
    n.fixed = true;
    } // eif
    } // ep
    public void start() {
    panel.start();
    public void stop() {
    panel.stop();
    public boolean action(Event evt, Object arg) {
    if (arg instanceof Boolean) {
    if (((Checkbox)evt.target).getLabel().equals("Showit")) {
    panel.showit = ((Boolean)arg).booleanValue();
    }// e-
    else {
    panel.random = ((Boolean)arg).booleanValue();
    return true;
    } // e-if instof bool
    if ("Reposition".equals(arg)) {
    Dimension d = size();
    for (int i = 0 ; i < panel.nnodes ; i++) {
    //Node n = panel.nodes;
    Node n = panel.nodes[i];
    if (!n.fixed) {
    n.x = 10 + (d.width-20)*Math.random();
    n.y = 10 + (d.height-20)*Math.random();
    } //ei
    } //ef9
    return true;
    } //eif scram
    if ("NewUrl".equals(arg)) {
    Dimension d = size();
    URL url = getCodeBase();
    try {
    getAppletContext().showDocument( new URL(url+"main.htm"), "_blank" );
    try {
    Thread.sleep(1000);
    } catch (InterruptedException e) { }
    } catch(MalformedURLException e) {
    showStatus("814 URL not found");
    for (int i = 0 ; i < panel.nnodes ; i++) {
    //Node n = panel.nodes;
    Node n = panel.nodes[i];
    if (!n.fixed) {
    n.x += (80*0.02) - 40;
    n.y += (80*0.02) - 40;
    return true;
    } //ei
    return false;

  • GL floating boxes with rollovers

    I'm working on a project that is similar to a target--bullseye in center with rings around it. I have created the text/phrases that go in each ring in Illustrator and put the whole thing together in a layered PS file. No problems yet, but when I separate all of the text/phrase into images with 2 states for the rollover and put them into GL floating boxes, the boxes overlap in some area so the mouseover rollover doesn't always work. For example, mouseover one text image and another one will show the color change rollover because the mouse is really over an area of the image that is transparent. Is the only way around this to re-arrange the box z-index to try to avoid the overlap or is there some way that I am missing? Frustrating!

    Like I said, you can use the Set Image URL action for the rollover. You can set multiple actions to change more than 1 pic on mouse enter if you need to. You won't need any more layers than you currently have, and only the area where you place the image map will be active (rollover won't trigger in transparent areas).
    As for overlib, (I'm not familiar with that) if it's a javascript that's added to your links/rollovers, you can move it to the image maps in the source, it should work fine.

  • Itunes app no longer showing genres or the top charts/genius bar in the top bar ... it only displays a faint music in the centre with just the search box..why? i need them back:-(

    itunes app no longer showing genres or the top charts/genius bar in the top bar ... it only displays a faint music in the centre with just the search box..why? i need them back:-(

    The iTunes Store listing of your podcast is simply reflecting the contents of your podcast feed. Make sure all of the content you want displayed in the iTunes Store is still contained within your feed.
    Are you able to supply your feed for reference?

  • TS4040 I assumed this would help my problem with not being able to open apps like Preview or TextEdit since I installed Mountain Lion. Instead, first I'm prompted to enter a password, then once I do that, I get an error box telling me the Library needs re

    I assumed this would help my problem with not being able to open apps like Preview or TextEdit since I installed Mountain Lion. Instead, first I'm prompted to enter a password, then once I do that, I get an error box telling me the Library needs repairing. So I click on Repair, and once again I'm prompted for a password, which I enter, then the same error box opens, and so it goes. Can anyone help me with this problem? I'd greatly appreciate it.
    Thor

    Back up all data. Don't continue unless you're sure you can restore from a backup, even if you're unable to log in.
    This procedure will unlock all your user files (not system files) and reset their ownership and access-control lists to the default. If you've set special values for those attributes on any of your files, they will be reverted. In that case, either stop here, or be prepared to recreate the settings if necessary. Do so only after verifying that those settings didn't cause the problem. If none of this is meaningful to you, you don't need to worry about it.
    Step 1
    If you have more than one user account, and the one in question is not an administrator account, then temporarily promote it to administrator status in the Users & Groups preference pane. To do that, unlock the preference pane using the credentials of an administrator, check the box marked Allow user to administer this computer, then reboot. You can demote the problem account back to standard status when this step has been completed.
    Triple-click the following line to select it. Copy the selected text to the Clipboard (command-C):
    { sudo chflags -R nouchg,nouappnd ~ $TMPDIR.. ; sudo chown -Rh $UID:staff ~ $_ ; sudo chmod -R u+rwX ~ $_ ; chmod -R -N ~ $_ ; } 2> /dev/null
    Paste into the Terminal window (command-V). You'll be prompted for your login password, which won't be displayed when you type it. You may get a one-time warning to be careful. If you don’t have a login password, you’ll need to set one before you can run the command. If you see a message that your username "is not in the sudoers file," then you're not logged in as an administrator.
    The command will take a noticeable amount of time to run. Wait for a new line ending in a dollar sign (“$”) to appear, then quit Terminal.
    Step 2 (optional)
    Step 1 should give you usable permissions in your home folder. This step will restore special attributes set by OS X on some user folders to protect them from unintended deletion or renaming. You can skip this step if you don't consider that protection to be necessary, and if everything is working as expected after step 1.
    Boot into Recovery by holding down the key combination command-R at startup. Release the keys when you see a gray screen with a spinning dial.
    When the OS X Utilities screen appears, select
    Utilities ▹ Terminal
    from the menu bar. A Terminal window will open.
    In the Terminal window, type this:
    res
    Press the tab key. The partial command you typed will automatically be completed to this:
    resetpassword
    Press return. A Reset Password window will open. You’re not  going to reset a password.
    Select your boot volume ("Macintosh HD," unless you gave it a different name) if not already selected.
    Select your username from the menu labeled Select the user account if not already selected.
    Under Reset Home Directory Permissions and ACLs, click the Reset button.
    Select
     ▹ Restart
    from the menu bar.

  • What's with this weird floating box on my screen spelling out everything I'm doing? How can I make it go away?

    A floating box has suddenly appeared on the lower left of my screen with white text on a black background telling me about whatever my cursor is hovering over at any given moment.  It's driving me nuts.  I'm sure it must be part of Help or Info, and it probably just takes a simple keystroke to get rid of it, but I can't seem to find that blasted keystroke!!  Please help.  [OS X 10.8.4; Mac Pro]

    welcome

  • I'm running OS 10.4 and purchased Mac Box Set with Snow Leopard.  When I run the Snow Leo install it errors saying I need OS 10.5 to run the install.  How do I get around this?  I've read that it's possible to go direcectly from 10.4 to 10.6.

    I'm running OS 10.4 and purchased Mac Box Set with Snow Leopard.  When I run the Snow Leo install it errors saying I need OS 10.5 to run the install.  How do I get around this?  I've read that it's possible to go direcectly from 10.4 to 10.6.

    To buy a hard drive try Newegg.com http://www.newegg.com/Store/SubCategory.aspx?SubCategory=380&name=Laptop-Hard-Dr ives or OWC http://eshop.macsales.com/shop/hard-drives/2.5-Notebook/
    Here's a cheap SATA external hard drive case on eBay http://cgi.ebay.com/USB-2-5-SATA-HDD-HARD-DRIVE-EXTERNAL-ENCLOSURE-CASE-BOX-/120 636286623?pt=PCC_Drives_Storage_Internal&hash=item1c167ba69f
    Here's instructions on replacing the hard drive http://creativemac.digitalmedianet.com/articles/viewarticle.jsp?id=45088

  • Newby to Flash -- need help with Drag and Drop

    I have been trying to create a drag and drop in Flash where I have five different places for an instance of a mc to be dropped. I want to be able to drop only three instances to each place and these three instances are specific to one of the five "drop places".  I also want the mc instance to go back to its original position if it is not dropped on the right place.  I've got the actionscript working to drag and drop the mc instances on the "drop places"  but I cannot figure out how to do the if statements so that if it doesn't match the correct drop place it will go back to its original position.
    Here's some of my code:
    Analyze1_mc.objName = "Analyze1";
    Analyze1_mc.val = 1;
    Design1_mc.objName = "Design1";
    Design1_mc.val = 4;
    Analyze1_mc.buttonMode = true; // sets mouse pointer to hand
    Design1_mc.buttonMode = true;
    Analyze1_mc.addEventListener(MouseEvent.MOUSE_DOWN, fl_ClickToDrag);
    Analyze1_mc.addEventListener(MouseEvent.MOUSE_UP, fl_ReleaseToDrop);
    Design1_mc.addEventListener(MouseEvent.MOUSE_DOWN, fl_ClickToDrag);
    Design1_mc.addEventListener(MouseEvent.MOUSE_UP, fl_ReleaseToDrop);
    var originalPosition:Point;
    function returnToOriginalPosition(): void
              originalPosition = new Point(x,y)
              x = originalPosition.x;
              y = originalPosition.y;
    // function to drag item clicked
    function fl_ClickToDrag(event:MouseEvent):void
              event.currentTarget.startDrag();
              event.target.parent.addChild(event.target);
    function fl_ReleaseToDrop(event:MouseEvent):void
              var target:MovieClip = event.currentTarget as MovieClip;
              var item:MovieClip = MovieClip(event.target);
              item.stopDrag();
    if (event.target.hitTestObject(AnalyzeTarget_mc)  && (event.target.val == 1)) {
                                            trace ("Analyze1");
                                            event.target.x = AnalyzeTarget_mc.x + 42;
                                            event.target.y = AnalyzeTarget_mc.y + 5;
                                            updateItem(Analyze1_mc);
                                  } else {
                                            returnToOriginalPosition();
    if (event.target.hitTestObject(DesignTarget_mc) && (event.target.val == 4)) {
                                            trace ("Design1");
                                            event.target.x = DesignTarget_mc.x + 42;
                                            event.target.y = DesignTarget_mc.y + 5;
                                            updateItem(Design1_mc);
                                  } else {
                                            returnToOriginalPosition();
    function updateItem(item:MovieClip):void {
              buttonMode = false;
              removeEventListener(MouseEvent.MOUSE_DOWN, fl_ClickToDrag);
    I put the trace in to check the function -- and I do get the output when the mc instance is dropped on the right place -- but there is no return to original position if the instance is dropped in the wrong spot and there is no update to the mc instance. 
    Any help would be greatly appreciated. Thanks!

    That line you speak of is merely declaring a variable, nothing is being assigned to it.
    One way of assigning the original position data to each object is to just assign it like follows:
    Analyze1_mc.originalX = Analyze1_mc.x;
    Analyze1_mc.originalY = Analyze1_mc.y;
    etc...
    Another way to do it with less code is to assign it generically just before you start dragging each of them...
    function fl_ClickToDrag(event:MouseEvent):void
              event.currentTarget.originalX = event.currentTarget.x;
              event.currentTarget.originalY = event.currentTarget.y;
              event.currentTarget.startDrag();
              event.target.parent.addChild(event.target);
    One thing I noticed in your code earlier is that you switch between using event.currentTarget and event.target.  If you want to be sure that the object your code is targetiing is the object that has the listener assigned to it (your movieclips) stick with using currentTarget.   target can end up pointing to something inside that object instead of the object itself.  In the following lines...
              var target:MovieClip = event.currentTarget as MovieClip;
              var item:MovieClip = MovieClip(event.target);
    You could very well be assigning target and item as being the same object.  I don't think that is what you want.  You might wanting to have one of them be the object you drop it on, which would be the dropTarget, not the target

  • I am having same problem with apple tv need 4.4 version and can not find solution this a brand new product out of box yesterday why would it not already have updated version. I am getting frustrated that I can not get this mirroring icon to work. I

    I am having same problem with apple tv need 4.4 version and can not find solution this a brand new product out of box yesterday why would it not already have updated version. I am getting frustrated that I can not get this mirroring icon to work. I have tried all suggestions in this thread and nothing works. I also hooked up to laptop through iTunes with micro USB nothing!!!

    The new appletv software came out 2 or 3 days ago, how would Apple get it on the device in the box in a store?
    Why don't ou update the appletv software?

  • Do I need to make an applet with swing point to the JRE 1.4 plug-in?

    Do I need to make an applet with swing point to the JRE 1.4 plug-in? I mean, in 1.3.1 plug-in, if you did not run your code through the HTML converter, the applet would still use the browsers JRE (JVM). However, with 1.4.0, it seems that you don't need to. Is this correct?

    When you ran an applet that has been compiled under 1.4 and needs classes or methods from 1.4 with an old HTML file (presumedly with the <object> tag that still refers to JRE 1.3+), the browser is going to look at the <object> tag and see that at least JRE1.3.1 is needed to correctly run the applet and since 1.4, which is higher than 1.3+, is on the system, it ignorantly proceeds to load and run the applet. The problem that you're going to run into is when you deploy the applet on the web and your viewer only have JRE1.3+, your applet which really needs 1.4, will crap out....
    ;o)
    V.V.

  • Possible Bug with Drag-and-Drop Being Published via HTML5 - Getting "Undefined" Error When Dragging Object

    Hello,
    I came up with a way to use drag-and-drop interactions that will take advantage of file input so that I may create a drag-and-drop interaction that uses one draggable object over and over allowing multiple scoring/tracking possibilities.  Example use...is having the draggable object be dynamic in that it randomly changes its text so that a learner can drag a term it's possible classification.........thus allowing the possibility of having many terms easily loaded without having to redo a drag-and-drop interaction for each needed terms/classifications updates/changes.
    My Issue: When using a variable to represent the text for a draggable Smart Shape object, I'm getting the error message "undefined" when, clicking/pressing on the object, as well as during the drag of the object. This issue occurs when publishing the project in an HTML5 format.  Flash interestingly enough seems to work perfect...but we are not interested in publishing via Flash any longer.
    To better help you explore this error message, I've set up a test project so that you can see when and how the "undefined" message shows up during a drag-and-drop interaction.  I've also included the Captivate 8 project file used to make the exploration project I'm sharing in this post.
    Link to Captivate project I created for you all to explore "undefined" error message": http://iti.cscc.edu/drag_and_drop_bug/
    Link to this Captivate 8 Project file: http://iti.cscc.edu/drag_and_drop_bug.cptx
    It's pretty interesting how things react in this demo, please try the following actions to see some interesting happenings:
    Drag the Yellow (or variable drag box) to the drag target.
    Drag Black Hello square to Drag target and click undo or reset - watch the undefined message come up on the Yellow (or variable drag box).
    Drag the Yellow (or variable drag box) to the drag target and then use the undo or reset.
    Move both draggable boxes to the drag target and use the undo and reset buttons...
    Anyhow, I know you all are sharp and will run the demo through its paces.
    I'd really be very honored if anyone help me figure out how I could (when publishing out to HTML5) no longer have the "undefined" error message show up when using drag-and-drop with a variable for shape text. This technique has been well received at the college I work at...and I have many future project requests for using such an idea on a variety of similar interactions. I'd love see a solution or see if this might be a bug Adobe may be able to fix!
    I tried to find a solution to the issue documented here for quite some time, but I was not able to find anyone with this problem much less attempting the idea I'm sharing in the help request -  save the darn "undefined" message that comes up!
    Many thanks in advance for any help and/or direction that you all may be able to provide,
    Paul

    Hello,
    I just wanted to supply a minor update related to my drag-and-drop question/issue stated above:
    I did another test using Captivate 7, and found that the undefined error (publishing as HTML5) does not appear and the variable data remains visible - except the variable data turns very small and does not honor any font size related settings.
    I did go ahead and submit this to Adobe as a possible bug today.
    Thanks again for any help related to this issue.  If the issued documented above is solved, it will allow many amazing things to be done using Captivate's drag-and-drop for both regular type projects as well as interaction development for iBooks! 
    Matter of fact if this issue gets fixed, I'll publish a Blog entry (or video) on way's I've used Captivate's drag-and-drop to create dynamic learning activities for Higher Ed. and for use in iBooks.
    ~ Paul

  • Why No Floating Boxes on IE8?

    I am using Adobe GL ver. 6.0 and I just spent hours formatting an image map to show/hide 7 images in floating boxes. I even placed the images carefully so there was no interference with the mouse over on the map. When I preview the page in IE it works fine but with a warning about Active X controls. But when I upload the page to the hosted website it does not even show the hotspots on the image or any type of action. Did I just waste my time? Do I have to go out and buy Flash?   Website is at the homepage for www.junglemistorchids.com and the image map is at the bottom of the page. Each orchid should display a larger image with a title. Please help!

    To use and understand the .site file is very importent for using golive ... it is the heart and soule
    when you begin a new website you have to start by making site/folder/projekt frome in GoLive
    Start by taking a backup/copy of you websitefolder now .....
    to start a website:
    when you open GL you will be askd if you want to  "new document" or "new folder" Chose "new document"
    (If you already hase GL open, go to file>new document in the menu)
    youll get this window:
    Chose the site at the left menu and create site in the middel to start/create a new site.
    Follow the instuctions in the wizzard (you dont have to specifi anny FPT yet but you can - leav blank if you want to do that later)
    Golive now creat a folder on you computer (wher you chose to place it) and GL open you new site...
    This is you site window ... ALWAYS work inside this / form this:
    Its split in left and  right... to the left is filewindow with your files for you webpages and to the right you see the server window wher if conected you can se the files on the server. The new site contains a index.html file and a css folder with a basic.css file (index.html and basic.css are blank) and GL is now ready to work in...
    If you find the folder GL made for the site youll see  it contains 3 folders and 3 files:
    The importent ones are:
    web-content folder contains all you pages, images, script and so for you site and are shown in the sitewindows leftside
    And the New Site.site file (or what you chosen to name your site in the wizzard)
    The .site file is the is the one that contains the site window in golive... it keeps track of all link/content/actions and so on you site... and when you want to work on the site you simple click this one.
    When you work in the site window GL will know what you do and where the difrent things are, and if you move eg. a picture/file frome one place inside the window to another GL will know this and rewrite the corosponding URL's (les work for you)
    When you ad adctions (funktions) to a page golive use its scriptLibery to make the scripts neede ... and place a "script" folder in the site:
    That folder/file  contains the scripts neede for the actions to work.. If you dont work in the sitewindow/file GL dont know where to place this and therfor the URL will point to GL's own folder and the script will only work local...
    (You can in the prefrence chosae to write scripts in the document, but i wont recomend that)
    When you ar done and want to upload you site to a server... right click in window and chose puplish server .. if you have not specifide a server youll be askd to.. else it will connect ...
    Now you can right click in window and chose puplish server and chose how to upload you site and Gl will upload all the files with correct url's including the script folder (Before upload its a good ideer to rightclick and chose update>flatten scriptlibery to make the scriptLib smaller)
    Hope this helps you understand the site file and importens of using this..
    Now for getting you website to work corectly....

  • Problem-less Floating Boxes?

    I saw the recent thread about problems with relative positioning. All of a sudden I'm insecure again. I have a page with 34 floating boxes (none nested, but many overlap) and their positions remain stable when my browser window is resized. No sleight of hand, just dragged boxes into position and filled with content (default settings in F.B. inspector). So I was feeling confident. Safari, Explorer, Aol all show the page as locked down, reacting to window re-sizing and scrolling just like any other conventional page design. Should I be worried? Is such a layout going to corrupt itself, or glitch-out, or crawl out from under my bed at night and bite my hand? I'm worried that I'm naive and missing something because of the complexity of that previous thread.

    >I saw the recent thread about problems with relative positioning
    There are no problems with relative positioning other than not understanding
    how it works. There are many *more* problems with absolute positioning,
    especially when text is placed in absolutely positioned elements.
    > just like any other conventional page design. Should I be worried?
    Yes. Resize your text in the browser and see what happens. Or better, post
    a link to your page so we can see its code and anticipate problems for you.
    Murray

  • Help creating a login applet with JDBC

    Hi, I'm trying to create a login applet using a table from a database (created with Microsoft Access). The bottom line is that I have very little knowledge of ActionListeners. I do know some things about JDBC, but most of it is through notes and lots of reading. I was wondering how to go about looking through a table (with two columns, user and password), to see if it matches what is typed into a JTextField and a JPasswordField. Just a sample piece of code would be helpful. Thank you very much in advanced. Also, I have the GUI done for what I need, just no ActionListeners or JDBC functionality implemented. Here it is:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.sql.*;
    public class login extends JFrame /*implements ActionListener*/ {
         private Container container;
         private GridBagLayout layout;
         private GridBagConstraints gbc;
         public login()
              super("Login");
              setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
            setSize(300,130);
            setLocationRelativeTo(null);
              container = getContentPane();
              layout = new GridBagLayout();
              container.setLayout(layout);
              gbc = new GridBagConstraints();
              labelUser = new JLabel("Username:");
              gbc.insets = new Insets(2,2,2,2);
              container.add(labelUser, gbc);
              textUser = new JTextField(15);
              gbc.gridx = 1;
              gbc.gridwidth = 3;
              container.add(textUser, gbc);
              labelPassword = new JLabel("Password:");
              gbc.gridy = 1;
              gbc.gridx = 0;
              gbc.gridwidth = 1;
              container.add(labelPassword, gbc);
              textPassword = new JPasswordField(15);
              gbc.gridx = 1;
              gbc.gridwidth = 3;
              container.add(textPassword, gbc);
              button1 = new JButton("Login");
              gbc.gridy = 2;
              gbc.gridx = 1;
              gbc.gridwidth = 1;
              container.add(button1, gbc);
              button2 = new JButton("Cancel");
              gbc.gridx = 2;
              container.add(button2, gbc);
         public static void main(String args[]) {
            new login().setVisible(true);
        private JButton button1, button2;
        private JLabel labelUser, labelPassword;
        private JTextField textUser;
        private JPasswordField textPassword;
    }Thank you again in advanced.

    Sir,
    Much of your question makes middling sense to me. You say applet but you have JFrame for example. I would caution you right now an applet with access for a DB is asking for trouble. Never minding the various security issues Access is not really intended for this sort of operation.
    Now none of that actually seems to be your question but I just thought I'd address that before you go too far down a road fraught with peril.
    As far as what I think you are asking assuming our table looks like this.
    tblUser
    username VARCHAR (access text field) primary key
    password VARCHAR (again known in access as text)then the code would look something like this...
    Connection c; //create your connection
    PreparedStatement ps = c.prepareStatement("SELECT username FROM tblUser WHERE username=? AND password=?");
    ps.setString(1,usernameVariable);
    ps.setString(2,passwordVariable);
    ResultSet rs = ps.executeQuery();
    if(rs.next()){
      // login successful
    }else{
      // login failed!
    rs.close();
    ps.close();
    c.close();Also duffymo will be unhappy if I don't mention that you will really want to give second thought to mixing your database code with your GUI code. Please take a gander through http://java.sun.com/blueprints/patterns/MVC.html
    Sincerely,
    Slappy

  • IPhoto 9.6 (910.29) hangs when dragging a photo from events into a slideshow. I am running OS X Yosemite 10.10.2

    iPhoto 9.6 (910.29) hangs when dragging a photo from events into a slideshow. I am running OS X Yosemite 10.10.2 on a Mac from 2011. I am trying to edit a slideshow that was already created. I can delete a photo but I cannot add drag any more photos into it. Please help, time is of the essence! I need to finish for my daughter's first birthday!
    Thanks,

    Option 1
    Back Up and try rebuild the library: hold down the command and option (or alt) keys while launching iPhoto. Use the resulting dialogue to rebuild. Choose to Repair Database. If that doesn't help, then try again, this time using Rebuild Database.
    If that fails:
    Option 2
    Download iPhoto Library Manager and use its rebuild function. (In early versions of Library Manager it's the File -> Rebuild command. In later versions it's under the Library menu.)
    This will create an entirely new library. It will then copy (or try to) your photos and all the associated metadata and versions to this new Library, and arrange it as close as it can to what you had in the damaged Library. It does this based on information it finds in the iPhoto sharing mechanism - but that means that things not shared won't be there, so no slideshows, books or calendars, for instance - but it should get all your events, albums and keywords, faces and places back.
    Because this process creates an entirely new library and leaves your old one untouched, it is non-destructive, and if you're not happy with the results you can simply return to your old one.  
    Regards
    TD

Maybe you are looking for

  • Regarding the text in the smartforms.

    HI EXPERTS, i m working on the smartforms ,i have to display the text as a column heading in the forms i.e "Amount of one increment granted from 01.07.95" as this text is very lengthy due to which my rows are getting heighted as i m using table for p

  • How to uninstall J2RE 1.4.2 without the msi?

    Hi, I am unable to uninstall the default installation of Java Plug-in as installed with WinXP Pro. I am upgrading to J2RE 1.42-07 for security reasons and would like to uninstall the older version. However, the uninstaller keeps looking for a J2RE1.4

  • When to use @Resource and when to use @EJB for dependency injection

    Hi, When do you use @Resource and when do you use @EJB for dependency injection? Thanks

  • J2ee security and page flow problem

    To give more details about the problem I have, user likes to put a URL in the browser, then press enter. User likes to see the running results. However, user is not able to see the results because j2ee security requires user log in. After sucessful l

  • BlackBerry playbook operating system.

    Good afternoon,  I have recently purchased a blackberry playbook 32gb with operating system 2.0.1.358. My wife also owns a playbook 16gb with operating system 2.0.1.668. When I check for system updates I am advised both via the playbook and when conn