Invoking Component With OnClick Event

I need help! I am trying to invoke a component asychronously
with an onclick event of my form. Unfortunately, I have not been
able to get it to work. I am currently using a framework by JSMX,
but it is not functioning properly for me.
I know that my cfc is okay, for when I manually invoke it
through the URL, it behaves as expected. Can anyone familiar with
JSMX help me out? Thanks!
My code is as follows:

Why don't you do it the easy way and submit the form to a cf
template that calls the method? If necessary, put that template
into an iframe so it is not visible to the user.
Take into account that once you get your code to actually do
something, you have to contend with users clicking the button
repeatedly wondering why nothing appears to be happening.

Similar Messages

  • How to create a navigation bar entry with onclick event

    I have requirement of creating navigation bar entry with a an "on click" event. When a user clicking time a location list should open. I didn't understand how to do it on NAVIGATIONBAR_ENTRY.
    Also Navigation Bar Entry IMage is not displaying.
    Regards
    Edited by: satheeshkumars on Oct 25, 2010 7:52 PM

    Do you specifically need to use the onclick event, or do you jts want to run Javascript from the navbar entry? If the latter then you can use the URL method and set the URL to:
    javascript:myfunction()
    If it must be an onclick event then I think you would need to attach it dynamically in Javascript (using jQuery if available) to locate the link somehow (it's not easy to give it a unique ID unfortunately).
    Edited by: Tony Andrews on Oct 26, 2010 10:35 AM

  • GridView - How to use OnClick event in a hyperlink in?

    Hi there,
    In my SharePoint Application I have an aspx page with a GridView. One of the columns should show a hyperlink with OnClick event. If you can please provide code for aspx page and/or C# code behind that will be appreciated.
    Thank you.

    Hi,
    Here is the sample code to add the HyperLink field in the Gridview.
    using System;
    using System.ComponentModel;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using Microsoft.SharePoint;
    using Microsoft.SharePoint.WebControls;
    using System.Data;
    namespace VisualWebPartProject5.VisualWebPart1
    [ToolboxItemAttribute(false)]
    public class VisualWebPart1 : WebPart
    protected override void CreateChildControls()
    GridView gview = new GridView();
    SPList list = SPContext.Current.Web.Lists["Projects"];
    SPQuery query = new SPQuery();
    query.Query = “<OrderBy><FieldRef Name=\”Project\” Ascending=\”True\”/></OrderBy>”;
    query.ViewFields = “<FieldRef Name=\”Project\” Nullable=\”TRUE\” /><FieldRef Name=\”Client\” Nullable=\”TRUE\” /><FieldRef Name=\”URL\”
    Nullable=\”TRUE\” />”;
    query.ViewFieldsOnly = true;
    SPListItemCollection lic = list.GetItems(query);
    DataTable dt = lic.GetDataTable();
    dt.Columns.Add(“Temp”, typeof(string));
    foreach (DataRow r in dt.Rows)
    r["Temp"] = r["URL"];
    gview.DataSource = dt;
    HyperLinkField linkField = new HyperLinkField();
    linkField.HeaderText = “Text”;
    linkField.DataTextField = “Project”;
    linkField.DataNavigateUrlFields =new string[] { “Temp”};
    linkField.Target = “_blank”;
    gview.Columns.Add(linkField);
    gview.DataBind();
    this.Controls.Add(gview);
    Please mark it answered, if your problem resolved or useful.

  • How to invoke a Servlet on onClick event of CheckBox ?

    Hi,
    Can anybody provide me with the code - how to invoke a Servlet & then pass all form variables to the Servlet on onClick Event of CheckBox in a JSP Page.
    I guess it is possible with Javascript but i need the code...
    Pls Help !
    Thanx.

    <html>
    <head>
    <script language="JavaScript">
    <!--
    function submitMyForm(){      
    document.myform.submit();
    //-->
    </script>
    </head>
    <body>
    <form name="myform" method="POST" action="http://mywebserver/servlet/myServlet" target=_top>
    <input type="checkbox" name="mycheckbox" OnClick = "javascript:submitMyForm()">
    </form>
    </body>
    </html>
    Hope this helps...

  • Can't set a hidden field value from onClick event with a runtime expression

    Hi,
    I need to set a hidden field in an onClick event of button but it's not working.
    <html:submit styleClass="btnLink" onclick="document.empForm.hidden.value='<%= empID%>'">
    <%= empID%>
    </html:submit>
    Althought the second expression is evaluated and written successfully "the button value"
    I heard that this is because you can't mix the value of an attribute of a custom tag with both string literal and run time expressions.
    Is there any work around to solve that?
    I can't use EL as I'm using old JSP version

    I guess, it should work; instead of html:submit, try with button.

  • Does onClick event work with Group in Adobe CC?

    Hi everyone
    I need to know if onClick event can be used on a Group in Adobe CC as it does in CS versions.
    Thanks!

    The removal of this option may also be due to the ScriptUI update in CC.
    http://blogs.adobe.com/aftereffects/2013/04/whats-new-changed-after-effects-next.html
    scripting changes
    ScriptUI is now based on the same controls as the main application, so appearance and functionality of panels created with scripts should be more consistent.
    Other scripting changes will be listed in a separate post on this blog soon.

  • EP 6.0 SP2: Update a HTMLB TableView after onClick Event

    Hello,
    i generate a TableView from a JDBC database selection.
    Outside this TableView there are 3 Buttons.
    Now the problem:
    If one of the buttons will click, the TableView has to be updated with a new database result. Have somebody an idea, how to update the TableView?
    Stephan

    Could you be more precise?
    Default behaviour/coding is that an onClick event effects a request to the server - as your component/dynpage handles this request, you should be able to present anything that you like on this occasion. Maybe you code does not react to the HTMLB event properly?
    Regards,
    Armin

  • 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;

  • 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;

  • Using javascript to detect the onclick event over a datatable row

    Hi all,
    I'm working with JSF 1.2 R.I. and I would like to add some javascript to my datatable to be able to control the onclick event on a row.
    At the moment I have just added a checkbox to be able to know which row the user wants to select but I'm not satisfied with this solution.
    <h:dataTable
    value="#{person_iupopulations_Observation.customer}" var="customer"
    rowClasses="evenRow,oddRow"
    cellspacing="0">
    <h:column>
    <f:facet name="header">
    <h:outputText value="Select" />
    </f:facet>
    <h:selectBooleanCheckbox value="" onclick="getRow(this)">
    </h:selectBooleanCheckbox>
    </h:column>
    <h:column>
    <f:facet name="header">
    <h:outputText value="Name" />
    </f:facet>
    <h:outputText value="#{customer.Name}"></h:outputText>
    </h:column>
    </h:dataTable>
    What I would like to achieve is:
    When the user clicks the row (wherever, not only the checkbox) the checkbox changes to the new value depending, off course, on the user's selection.
    For this purpose I would need to add the onclick event to every row and associate it to a javascript function to update the checkbox.
    Can anybody help me please.
    I appreciate any suggestion.
    Thanks in advance!

    I am looking for answers on how to use javascript to detect the onclick event over a datatable row . I have a selectBooleanCheckBox in one of the columns in the every row in the table. On click of the checkbox in any row of the table, I want to get some values from the selected row and also verify that the rest of the checkboxes in all the other columns are unchecked. I want to do this using javascript. If any of you have answers, please repsond. Thanks.

  • OnClick event in swf file stops a WMP movie that is being play

    Hi
    When placed in the same page - onclick event in a swf file
    stops a WMP movie that is being play.
    I've tryied to add another div with ontop positioning. but it
    didn't work.
    I've added a dlear image and it worked but the SWF mouseover
    and mouseclick events disappeared.
    Can someone help me?
    PS - it happens only on IE.
    Thanks.

    Hi Alden,
    I fear your problem might be the file size (system resources,
    actually) of your project. And if that is the case, it will
    adversely affect your end users as well, so best find our
    definitively right away. But let's assume for a minute that the
    file size is
    not causing the problem ...
    Are there any interactive object(s) on the 33rd slide (or
    thereabouts) that might be causing the project to stop - like a
    button, click-box, or text-entry box???
    A 48 slide movie is not (in and of itself) overly large, so
    hopefully you can find some overlooked object that is causing the
    problem...
    .

  • Input Field in table - I need a OnClick Event

    Hello everybody,
    I have the following problem:
    I have created a table in my view which is filled at runtime. The table has 3 different rows and every row has TableSingleMarkableCells, these cells further have a input field as their celleditor.
    I now want to know which cell the user is editing. I have a AttributePointer through which I know that at the time the user presses the enter key. But I need to know whether the focus has changed. Because there is the possibility that the user switches between the differnt cells with the arrow key or the tab key. But the AttributePointer only gives me the first selected cell.
    Have anybody a suggestion to solve this problem -  it seemed to be something like definingb a OnClick event for a input field (additionaly to the default OnEnter event...)
    Best regards,
    Sebastian

    Hi,
    You can find out at which row the editing goes, by using
    onLeadSelect action of TableUIElement.
    in onLeadSelect action you can find row number using this statement
    int rownumber= wdContext.node<TableNode>().getLeadSelection();
    Regards
    LakshmiNarayana

  • How to setup PCG Flow Rule Process flow with Business Event subscription

    Hi,
    How to setup PCG Flow Rule Process flow with Business Event subscription type?
    When should Business Events be used?
    The latest user guide does not provide ay information on this functionality of Flow rules.
    Thanks

    You should find it's usage noted in the new PCG user guide on page 3-26 under the heading "Configuring Workflow/Event Rules". This way you can have a Flow Rule call a business event component or a workflow. This would be kicked off within a process flow as one of the steps.
    I hope that helps.

  • Tree Component with incremental auto-refresh?

    Is there a free (preferably) or commercial JSF tree component with a general AJAX-based incremental auto-refresh?
    Essentially when dealing with a tree of data which can lose or add nodes at any time, it would be nice to have an optional polling mechanism built into the tree that would check the server for tree insertion and removal events and handle any such events whenever they're found via incremental AJAX-based modifications to the tree -- not a full refresh. The same is true for tree node change events.
    To be clear this is not a substitute for handling client events -- the tree data is indicative of shared state and changes independently from user actions.

    I was following instructions from [http://niallcblogs.blogspot.nl/2009/06/auto-refreshing-adf-chart-objects-in.html]
    But I got it to work the way you say.
    But setting refresh="always" generates exceptions in even simple cases. Is it because I am using MySQL which does not have event notification support?

  • Trouble Passing Values Using onClick Event

    I have a page with a div, <div id= PF_Text_Panel></>,  containing text describing an image, the image is in a separate div.  Using CSS the text panel is on top of the image and covers about 1/3 of the image’s left side.  A slide effect, handled by the function Slide, targets the PF_Text_Panel div. The function Slide is triggered by an onClick event allowing the user to slide the description to the left and reveal the entire image.
    The function Slide contains an if statement. The if statement is used to determine if PF_Text_Panel is open or closed using the variable SldPnlState  as a flag like this; if the variable SldPnlState ==1, then run Slide.  The other part of this function, which actually slides the div is an instance of the Slide Effect, inserted using Dreamweaver CS4.
    The variable SldPnlState  is set using the function setSldPnlState
    The function setSldPnlState, initiated by an onClick, passes a value to the variable SldPnlState, in this case it can be set to either 0 or 1 by separate onClick events
    To test if the variable SldPnlState is being passed from the onClick event to the variable I included the function printVar which writes the value of the variable SldPnlState to the screen.
    I believe that the Spry effect Slide portion of the function works because if I go into the code and manually set the variable SldPnlState to 1 the function Slide works and if I set it to 0 the function Slide does not work.
    This the bug:
    printVar indicates that the value is being passed the variable SldPnlState, it displays either a 1 or 0 as expected. 
    The function Slide does not work however, when the variable SldPnlState should be set by the onClick event passing the value using the function setSldPnlState.  It does not seem like the value is being passed from the onClick event triggering the function or that somehow the script stops running.
    You can demo the page at: http://dg-ad.com/Slide_Effect_Logic_Parameter.html
      Attached is the code, if anyone has some suggestions I would really appreciate hearing from you
    <!--begin setup Spry Effects-->
    <script src="SpryAssets/SpryEffects.js" type="text/javascript"></script>
    <!--Begin pass variable from flagToggle parameter to SldPnlState variable includes printVar function to sent results to screen-->
    <script language="javascript" type="text/javascript">
    <!--begin set flag using onclick event-->
    var SldPnlState = (1);
    function setSldPnlState(flagToggle)
    SldPnlState = flagToggle;
    </script>
    <!--end set flag using onclick event-->
    <!--begin slider onclick event-->
    <script type="text/javascript">
    if(SldPnlState==1)
    function MM_effectSlide(targetElement, duration, from, to, toggle, transition, fps, horizontal)
    Spry.Effect.DoSlide(targetElement, {duration: 500, from: 0, to: 200, toggle: true, transition: 2, fps: 750, horizontal: true});
    //-->
    </script>
    <!--end slider onclick event-->
    <!--begin write variable onclick event-->
    <script type="text/javascript">
    function printVar()
    document.getElementById('test_display').innerHTML = SldPnlState
    </script>
    <!--end write variable onclick event-->
    </head>
    <body id="wrapper">
            <div style="padding-top:50px;">
            <a href="#" onclick="setSldPnlState(1);">Set var SldPnlState to Flag Status Set Open (1)</a><br><br><br>
            <a href="#" onclick="setSldPnlState(0);">Set var SldPnlState to Flag Status Set Closed (0)</a><br><br><br>
            <a href="#" onclick="printVar();">Print Flag Status to Screen</a><br><br><br>
            <div id="test_display" style="border:#9CC thick groove; width:50px; height:50px; margin:15px; text-align:center; font-size:36px;"></div>
            <a href="#" onclick="MM_effectSlide('PF_Text_Panel');">Slide Panel</a><br><br>
            </div>
    <div id="PF_Text_Panel" style="border:#9C9 thick solid; height:250px; margin-top:25px;">
      <div id="PF_Text" class="PF_Text">
      </div>
      <script type="text/javascript">
        var panelWidget_1=new Spry.Widget.HTMLPanel('PF_Text');
        </script>
    </div>

    Thanks so much for taking a look at this.  The whole reason I am doing this is that I couldn't find a state indicator flag in the Spry.Effect.DoSlide effect.
    I see that the htmlPanel does not have a bearing on the problem as you mentioned but not having the javascript doesn't matter either.  I am using the Spry.Effect.DoSlide effect, it is in the head,  in the function with the if statement, and it is making the div"PF_Text_Panel slide which works fine including the if statement.  If I set the var SldPnlState = (1) it works set it to 0 and the slide effect is disabled.  I need to be able to change the variable using an onclick event.
    The problem as you mention is with the function SldPnlState = flagToggle;  This is what I need to do.  I need to pass a value to  the variable SldPnlState from an onclick event.  As the function Slide is set up, with an if statement, the div will slide if SldPnlState=1 and the slide function will turn off if SldPnlState=0.  However when I do the onclick="setSldPnlState(1);"event there is no effect on the Slide function.  The value seems to pass to the variable tSldPnlState since I can get the value of this same variable to display using the function printVar() which will display 1 or 0 depending on which onclick event I run.  It seems like the I can pass the variable from the onclick event it's just that if statement in the function MM_effectSlide never sees it.  I don't know enough to trouble shoot this.  But I will take a closer look at the SldPnlState = flagToggle; part as you suggest.

Maybe you are looking for

  • Central PI Monitoring and Alerting in Solution manager

    According to SAP AG documentation [White Paper|http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/104677d9-fc8c-2e10-dc92-c4e660b0dd8c?quicklink=index&overridelayout=true] - the Solution Manager 7.1 onward provides a central PI monito

  • Strange Application Issues after Mountain Lion Upgrade!

    I'm having, what I believe to be, strange issues with a clean install of Mountain Lion from 10.6.8 It's for my boss' computer at work so I can't afford to have it down for very long at a time. It's hard to pinpoint the issue(s). Computer: Mac Pro - E

  • Is Oracle Form can read bar code scanner ?

    Hi everybody, I would like to develop an application for a video club with oracle form. Can anyone tell me how can do or just say if it is possible or not Thanks a lot. Shafique Mahmood

  • Banging my head against a brick wall

    Some background information: I currently have two phone lines, let’s call them line A and line B. At the beginning of September I decided to move by broadband to BT and signed up online for a Total Broadband package to be activated on line A (the lin

  • Delete Photoshop CS6 beta

    hi, I just subscribed to Creative Cloud. The Adobe Application Manager (for Mac) refuses to download Photoshop CS6 because it finds a beta version of that application on the machine. This was originally so. But I have uninsalled and deleted that. How