Hyperlink in an Applet

Hi,
is it possible to create a hyperlink in an Applet?

Give your button an actionlistener then once it's clicked run this bit of code where target is a String such as "_blank" which will determine where the link should be shown
getAppletContext().showDocument(new URL("http://www.example.com"), target);

Similar Messages

  • Hyperlinks from an Applet

    Hi,
    I was wondering if we can have hyperlinks in the applet. I have a Table which has 6 columns and some thousands of rows of data. I want to provide hyperlinks for each row in the first column. Is there any way that i can do it. I tried searching in the forum theards but could not get a clue on how i should be doing it.
    I'm new to java..! Please help..
    Thanks

    here is the basic of it compile the code an try it
    import java.awt.*;
    import java.net.*;
    import java.applet.*;
    import java.awt.event.*;
    public class testing1 extends Applet implements MouseListener {
    public void init() {
    addMouseListener(this);
    setBackground(Color.black);
    public void mouseClicked (MouseEvent me) {
    try { URL url = new           URL("http://javaboutique.internet.com/tutorials/"); 
    getAppletContext().showDocument(url,"_self");
    }catch(Exception tr) {}
    public void mouseEntered (MouseEvent me) {}
    public void mousePressed (MouseEvent me) {}
    public void mouseReleased (MouseEvent me) {}
    public void mouseExited (MouseEvent me) {}
    click anywhere in the applet it will link to the url

  • Including hyperlink in the applet

    how do can i include a hyperlink in the applet

    hi there EXPERT
    sorry for the question format.
    Here is what i want to do!! Firstly i'm writing a converter
    from some another lang. to Java. I'm implementing it using
    the applets. That lang can include the "labels" as hyperlinks.
    so if there are lots of labels, i need to find out whether it
    is associated with a url or not and make that label a hyperlink
    accordingly. so what this means i need to add the hyperlinks
    to the applet as and when there are "url labels" in the other
    lang window.
    following is a simple applet,plz explain me how to add hlinks
    to it.
    import java.awt.*;
    import java.awt.event.*;
    import java.applet.*;
    import java.lang.*;
    import javax.swing.*;
    /*<applet code= "try1" width = 200 height = 300>
    </applet>*/
    public class try1 extends Applet implements FocusListener
    TextField tx2;
    public     void init()
         setLayout(new FlowLayout(FlowLayout.LEFT));
              Label l1 = new Label ("Name");
              Label l2 = new Label ("Address");
              TextField tx1 = new TextField(20);
              tx2 = new TextField(20);
    //i need to add the hyperlink here
              Button ok = new Button("Ok");
              Button cancel = new Button("Cancel");
    //and here also
              add(l1);
              add(l2);
              add(tx1);
              add(tx2);
              add(ok);
              add(cancel);
    public     void start()
    public     void paint()
    Ashish

  • How can I use HyperLink In Java Applet..

    I am new In Java Programming And i Want to create a Hyperlink OR URL in java Applet, How can be It possible?

    well u can use a hyperlink as a url by using url from java.net.url class
    define ur url .... u can check the API fo r that
    and by using wht u mean .. u want to browse in applet with that url or wht
    if u want to do browing in applet than u will also have to do parsing of all HTML tags
    hope it will help u

  • Monitoring hyperlink activity through applet

    Is it posible for an applet to monitor which hyperlinks are being click on by the user in a different frame? I could not find a documentatioon on this, maybe i am blind...
    Thanks for your help,
    Mink

    Thanks for the reply, thats what i did.

  • Loading swing applet over another swing applet, how?

    hi
    My problem is that i have to load an applet in a browser. Then i have to load another applet over it. But that does not happen. The applet is loaded on its side, and the earlier applet is not unloaded and is still visible. And i am calling both the applets from a JSP page. So What can i do to unload the earlier applet.
    Thanks

    Hi
    Actually, i got two partitions in my browser(with help of <table> tag). In one i have all the hyperlinks, and by clicking on these hyperlinks the corresponding applets are to be displayed in the second part. So what is the way by which i can do that. Note that for this i m not loading a new jsp page.

  • Viravan....I NEED YOUR HELP!...Please?

    Just trying to get your attention as I saw you just posted. Can you help me? In this link, you posted this:
    http://forum.java.sun.com/thread.jsp?forum=57&thread=267060&tstart=0&trange=15
    If you don't want to have to fool around with the HyperlinkListener, >just add the normal <BASE> tag to your HTML file. The <BASE> tag has >the following syntax:
    <BASE HREF="baseURL" TARGET="WindowName" >
    The TARGET portion is optional!
    Theoretically, the JEditorPane should be smart enough to look for the >link from the same place where the original HTML file is loaded from >but apparently there is a bug somewhere that prevents it from doing >that.What baseURL do you speak of?

    Thanks again for your help. Here runnable example that consists of three classes:
    1) Applet
    2) Dialog
    3) JEditorPane
    ...and at the bottom the HTML file. Should be easy to run it and check it out. I tried adding the BASE tag within the html, but it did not work.
    Thanks!
    public class TestApplet extends javax.swing.JApplet {
      public void start() {
        TestDialog testDialog = new TestDialog();
    public class TestDialog extends javax.swing.JDialog {
      public TestDialog() {
        this.setSize(250,250);
        TestEditor testEditor = new TestEditor();
        javax.swing.JScrollPane testScroll = new javax.swing.JScrollPane(testEditor);
        getContentPane().add(testScroll);
        show();
    public class TestEditor extends javax.swing.JEditorPane {
      public TestEditor() {
        this.setEditable(false);
        this.setContentType("text/html");
        HTMLListener htmlListener = new HTMLListener();
        this.addHyperlinkListener(htmlListener);
        this.setText("<HTML>"
            + "<TITLE>This is a test</TITLE>"
            + "<H2>Paragraph 1</H2>"
            + "<A HREF='#Para2'>Click here to go to Paragraph 2</A>"
            + "<P>Here is text for paragraph 1</P>"
            + "<P>Here is text for paragraph 1</P>"
            + "<P>Here is text for paragraph 1</P>"
            + "<P>Here is text for paragraph 1</P>"
            + "<P>Here is text for paragraph 1</P>"
            + "<A NAME='Para2'>"
            + "<H2>Paragraph 2</H2>"
            + "<P>Here is text for paragraph 2</P>"
            + "</HTML>");
      private class HTMLListener implements javax.swing.event.HyperlinkListener {
        public void hyperlinkUpdate(javax.swing.event.HyperlinkEvent hyper) {
          if(hyper.getEventType() == javax.swing.event.HyperlinkEvent.EventType.ACTIVATED)
            System.out.println("Clicked on a hyperlink");
    <HTML>
      <BODY>
        <APPLET codebase = .
        code = TestApplet.class
        width=250, height=250>
        </APPLET>
      </BODY>
    </HTML>

  • Hyperlink in a TextField on an Applet

    How do i insert a hyperlink in a TextField object which is in an applet and make that hyperlink reference a new window
    thanks for the help

    try the methode in the Interface java.applet Interface AppletContext
    showDocument(URL,"_blank)

  • How do I put a hyperlink button on the Canvas in Applet

    I am tried to put a hyperlink button on the Canvas in Applet.
    But Canvas is a componet that can't contain any component.
    I hope best way that is like hyperlink of HTML , I just clicked this hyperlink in Canvas,it's automation link to directed homepage.
    Can I have any way to do that?

    You can setup Restrictions...
    Tap Settings > General > Restrictions
    AFAIK, it's not possible to attach a password for access to the Settings.

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

  • How can I change  oval shape applet to (plot)

    Hi this is not my code so, the orignal code is freeware to www.neuralsemantics.com and is Copyright 1989 by Rich Gopstein and Harris Corporation.
    The site allows permission to play with the code or ammend it.
    how could I modify the applet to display (plot) several cycles of the audio signal instead of the elliptical shape. The amplitude and period of the waveform should change in accordance with the moving sliders
    Here is the code from www.neuralsemantics.com /applets/jazz.html
    import java.applet.*;
    import java.awt.*;
    import java.awt.event.*;
    public class JazzMachine extends Applet
                 implements Runnable, AdjustmentListener, MouseListener {
      // program name
      final static String TITLE = "The jazz machine";
      // Line separator char
      final static String LSEP = System.getProperty("line.separator");
      // Value range
      final static int MIN_FREQ = 1;   // min value for barFreq
      final static int MAX_FREQ = 200; // max value for barFreq
      final static int MIN_AMPL = 0;   // min value for barVolume
      final static int MAX_AMPL = 100; // max value for barVolume
      // Sun's mu-law audio rate = 8KHz
      private double rate = 8000d;      
      private boolean audioOn = false;     // state of audio switch (on/off)
      private boolean changed = true;      // change flag
      private int freqValue = 1;           // def value of frequency scrollbar
      private int amplValue = 70;          // def value of volume scrollbar
      private int amplMultiplier = 100;    // volume multiplier coeff
      private int frequency, amplitude;    // the requested values
      private int soundFrequency;          // the actual output frequency
      // the mu-law encoded sound samples
      private byte[] mu;
      // the audio stream
      private java.io.InputStream soundStream;
      // graphic components
      private Scrollbar barVolume, barFreq;
      private Label labelValueFreq;
      private Canvas canvas;   
      // flag for frequency value display
      private boolean showFreq = true;
      // width and height of canvas area
      private int cw, ch;
      // offscreen Image and Graphics objects
      private Image img;
      private Graphics graph;
      // dimensions of the graphic ball
      private int ovalX, ovalY, ovalW, ovalH;
      // color of the graphic ball
      private Color ovalColor;
      // default font size
      private int fontSize = 12;
      // hyperlink objects
      private Panel linkPanel;
      private Label labelNS;
      private Color inactiveLinkColor = Color.yellow;
      private Color activeLinkColor = Color.white;
      private Font inactiveLinkFont = new Font("Dialog", Font.PLAIN, fontSize);
      private Font activeLinkFont = new Font("Dialog", Font.ITALIC, fontSize);
      // standard font for the labels
      private Font ctrlFont;
      // standard foreground color for the labels
      private Color fgColor = Color.white;
      // standard background color for the control area
      private Color ctrlColor = Color.darkGray;
      // standard background color for the graphic ball area
      private Color bgColor = Color.black;
      // start value for the time counter
      private long startTime;
      // maximum life time for an unchanged sound (10 seconds)
      private long fixedTime = 10000;
      // animation thread
      Thread runner;
    //                             Constructors
      public JazzMachine() {
    //                                Methods
      public void init() {
        // read applet <PARAM> tags
        setAppletParams();
        // font for the labels
        ctrlFont = new Font("Dialog", Font.PLAIN, fontSize);
        // convert scrollbar values to real values (see below for details)
        amplitude = (MAX_AMPL - amplValue) * amplMultiplier;
        frequency = (int)Math.pow(1.2d, (double)(freqValue + 250) / 10.0);
        setLayout(new BorderLayout());
        setBackground(ctrlColor);
        setForeground(fgColor);
        Label labelVolume = new Label(" Volume ");
        labelVolume.setForeground(fgColor);
        labelVolume.setAlignment(Label.CENTER);
        labelVolume.setFont(ctrlFont);
        barVolume = new Scrollbar(Scrollbar.VERTICAL, amplValue, 1,
                         MIN_AMPL, MAX_AMPL + 1);
        barVolume.addAdjustmentListener(this);
        // assign fixed size to the scrollbar
        Panel pVolume = new Panel();
        pVolume.setLayout(null);
        pVolume.add(barVolume);
        barVolume.setSize(16, 90);
        pVolume.setSize(16, 90);
        Label labelFreq = new Label("Frequency");
        labelFreq.setForeground(fgColor);
        labelFreq.setAlignment(Label.RIGHT);
        labelFreq.setFont(ctrlFont);
        barFreq = new Scrollbar(Scrollbar.HORIZONTAL, freqValue, 1,
                      MIN_FREQ, MAX_FREQ);
        barFreq.addAdjustmentListener(this);
        // assign fixed size to the scrollbar
        Panel pFreq = new Panel();
        pFreq.setLayout(null);
        pFreq.add(barFreq);
        barFreq.setSize(140, 18);
        pFreq.setSize(140, 18);
        // show initial frequency value
        labelValueFreq = new Label();
        if (showFreq) {
          labelValueFreq.setText("0000000 Hz");
          labelValueFreq.setForeground(fgColor);
          labelValueFreq.setAlignment(Label.LEFT);
          labelValueFreq.setFont(ctrlFont);
        Panel east = new Panel();
        east.setLayout(new BorderLayout(10, 10));
        east.add("North", labelVolume);
        Panel pEast = new Panel();
        pEast.add(pVolume);
        east.add("Center", pEast);
        Panel south = new Panel();
        Panel pSouth = new Panel();
        pSouth.setLayout(new FlowLayout(FlowLayout.CENTER));
        pSouth.add(labelFreq);
        pSouth.add(pFreq);
        pSouth.add(labelValueFreq);
        south.add("South", pSouth);
        linkPanel = new Panel();
        this.composeLink();
        Panel west = new Panel();
        // dummy label to enlarge the panel
        west.add(new Label("      "));
        add("North", linkPanel);
        add("South", south);
        add("East", east);
        add("West", west);
        add("Center", canvas = new Canvas());
      private void composeLink() {
        linkPanel.setLayout(new FlowLayout(FlowLayout.CENTER, 0, 5));
        linkPanel.setFont(inactiveLinkFont);
        linkPanel.setForeground(Color.yellow);
        Label labelName = new Label(TITLE + " \u00a9");
          labelName.setForeground(inactiveLinkColor);
          labelName.setAlignment(Label.RIGHT);
        labelNS = new Label(" Neural Semantics   ");
          labelNS.setForeground(inactiveLinkColor);
          labelNS.setFont(inactiveLinkFont);
          labelNS.setAlignment(Label.LEFT);
        linkPanel.add(labelName);
        linkPanel.add(labelNS);
        // link to Neural Semantics website
        String h = getDocumentBase().getHost();
        if ((h.length() > 4) && (h.substring(0, 4).equals("www.")))
          h = h.substring(4);
        if ((h != null) && (! h.startsWith("neuralsemantics.com"))) {
          // create a hand cursor for the hyperlink area
          Cursor linkCursor = new Cursor(Cursor.HAND_CURSOR);
          linkPanel.setCursor(linkCursor);
          labelName.addMouseListener(this);
          labelNS.addMouseListener(this);
      private void switchAudio(boolean b) {
        // switch audio to ON if b=true and audio is OFF
        if ((b) && (! audioOn)) {
          try {
            sun.audio.AudioPlayer.player.start(soundStream);
          catch(Exception e) { }
          audioOn = true;
        // switch audio to OFF if b=false and audio is ON
        if ((! b) && (audioOn)) {
          try {
            sun.audio.AudioPlayer.player.stop(soundStream);
          catch(Exception e) { }
          audioOn = false;
      private void getChanges() {
        // create new sound wave
        mu = getWave(frequency, amplitude);
        // show new frequency value
        if (showFreq)
          labelValueFreq.setText((new Integer(soundFrequency)).toString() + " Hz");
        // shut up !
        switchAudio(false);
        // switch audio stream to new sound sample
        try {
          soundStream = new sun.audio.ContinuousAudioDataStream(new
                            sun.audio.AudioData(mu));
        catch(Exception e) { }
        // listen
        switchAudio(true);
        // Adapt animation settings
        double prop = (double)freqValue / (double)MAX_FREQ;
        ovalW = (int)(prop * cw);
        ovalH = (int)(prop * ch);
        ovalX = (int)((cw - ovalW) / 2);
        ovalY = (int)((ch - ovalH) / 2);
        int r = (int)(255 * prop);
        int b = (int)(255 * (1.0 - prop));
        int g = (int)(511 * (.5d - Math.abs(.5d - prop)));
        ovalColor = new Color(r, g, b);
        // start the timer
        startTime = System.currentTimeMillis();
        // things are fixed
        changed = false;
    //                               Thread
      public void start() {
        // create thread
        if (runner == null) {
          runner = new Thread(this);
          runner.start();
      public void run() {
        // infinite loop
        while (true) {
          // Volume or Frequency has changed ?
          if (changed)
            this.getChanges();
          // a touch of hallucination
          repaint();
          // let the children sleep. Shut up if inactive during more
          // than the fixed time.
          if (System.currentTimeMillis() - startTime > fixedTime)
            switchAudio(false);
          // let the computer breath
          try { Thread.sleep(100); }
          catch (InterruptedException e) { }
      public void stop() {
        this.cleanup();
      public void destroy() {
        this.cleanup();
      private synchronized void cleanup() {
        // shut up !
        switchAudio(false);
        // kill the runner thread
        if (runner != null) {
          try {
            runner.stop();
            runner.join();
            runner = null;
          catch(Exception e) { }
    //                     AdjustmentListener Interface
      public void adjustmentValueChanged(AdjustmentEvent e) {
        Object source = e.getSource();
        // Volume range : 0 - 10000
        // ! Scrollbar value range is inverted.
        // ! 100 = multiplier coefficient.
        if (source == barVolume) {
          amplitude = (MAX_AMPL - barVolume.getValue()) * amplMultiplier;
          changed = true;
        // Frequency range : 97 - 3591 Hz
        // ! Scrollbar value range represents a logarithmic function.
        //   The purpose is to assign more room for low frequency values.
        else if (source == barFreq) {
          freqValue = barFreq.getValue();
          frequency = (int)Math.pow(1.2d, (double)(freqValue + 250) / 10.0);
          changed = true;
    //                     MouseListener Interface
      public void mouseClicked(MouseEvent e) {
      public void mouseEntered(MouseEvent e) {
        // text color rollover
        labelNS.setForeground(activeLinkColor);
        labelNS.setFont(activeLinkFont);
        showStatus("Visit Neural Semantics");
      public void mouseExited(MouseEvent e) {
        // text color rollover
        labelNS.setForeground(inactiveLinkColor);
        labelNS.setFont(inactiveLinkFont);
        showStatus("");
      public void mousePressed(MouseEvent e) {
        try {
          java.net.URL url = new java.net.URL("http://www.neuralsemantics.com/");
          AppletContext ac = getAppletContext();
          if (ac != null)
            ac.showDocument(url);
        catch(Exception ex){ }
      public void mouseReleased(MouseEvent e) {
    //                              Painting
      public void update(Graphics g) {
        Graphics canvasGraph = canvas.getGraphics();
        if (img == null) {
          // get canvas dimensions
          cw = canvas.getSize().width;
          ch = canvas.getSize().height;
          // initialize offscreen image
          img = createImage(cw, ch);
          graph = img.getGraphics();
        // offscreen painting
        graph.setColor(bgColor);
        graph.fillRect(0, 0, cw, ch);
        graph.setColor(ovalColor);
        graph.fillOval(ovalX, ovalY, ovalW, ovalH);
        // canvas painting
        if (canvasGraph != null) {
          canvasGraph.drawImage(img, 0, 0, canvas);
          canvasGraph.dispose();
    //                          Sound processing
      // Creates a sound wave from scratch, using predefined frequency
      // and amplitude.
      private byte[] getWave(int freq, int ampl) {
        int lin;
        // calculate the number of samples in one sinewave period
        // !! change this to multiple periods if you need more precision !!
        int nSample = (int)(rate / freq);
        // calculate output wave frequency
        soundFrequency = (int)(rate / nSample);
        // create array of samples
        byte[] wave = new byte[nSample];
        // pre-calculate time interval & constant stuff
        double timebase = 2.0 * Math.PI * freq / rate;
        // Calculate samples for a single period of the sinewave.
        // Using a single period is no big precision, but enough
        // for this applet anyway !
        for (int i=0; i<nSample; i++) {
          // calculate PCM sample value
          lin = (int)(Math.sin(timebase * i) * ampl);
          // convert it to mu-law
          wave[i] = linToMu(lin);
        return wave;
      private static byte linToMu(int lin) {
        int mask;
        if (lin < 0) {
          lin = -lin;
          mask = 0x7F;
        else  {
          mask = 0xFF;
        if (lin < 32)
          lin = 0xF0 | 15 - (lin / 2);
        else if (lin < 96)
          lin = 0xE0 | 15 - (lin-32) / 4;
        else if (lin < 224)
          lin = 0xD0 | 15 - (lin-96) / 8;
        else if (lin < 480)
          lin = 0xC0 | 15 - (lin-224) / 16;
        else if (lin < 992)
          lin = 0xB0 | 15 - (lin-480) / 32;
        else if (lin < 2016)
          lin = 0xA0 | 15 - (lin-992) / 64;
        else if (lin < 4064)
          lin = 0x90 | 15 - (lin-2016) / 128;
        else if (lin < 8160)
          lin = 0x80 | 15 - (lin-4064) / 256;
        else
          lin = 0x80;
        return (byte)(mask & lin);
    //                             Applet info
      public String getAppletInfo() {
        String s = "The jazz machine" + LSEP + LSEP +
                   "A music synthetizer applet" + LSEP +
                   "Copyright (c) Neural Semantics, 2000-2002" + LSEP + LSEP +
                   "Home page : http://www.neuralsemantics.com/";
        return s;
      private void setAppletParams() {
        // read the HTML showfreq parameter
        String param = getParameter("showfreq");
        if (param != null)
          if (param.toUpperCase().equals("OFF"))
            showFreq = false;
        // read the HTML backcolor parameter
        bgColor = changeColor(bgColor, getParameter("backcolor"));
        // read the HTML controlcolor parameter
        ctrlColor = changeColor(ctrlColor, getParameter("controlcolor"));
        // read the HTML textcolor parameter
        fgColor = changeColor(fgColor, getParameter("textcolor"));
        // read the HTML fontsize parameter
        param = getParameter("fontsize");
        if (param != null) {
          try {
            fontSize = Integer.valueOf(param).intValue();
          catch (NumberFormatException e) { }
      private Color changeColor(Color c, String s) {
        if (s != null) {
          try {
            if (s.charAt(0) == '#')
              c = new Color(Integer.valueOf(s.substring(1), 16).intValue());
            else
              c = new Color(Integer.valueOf(s).intValue());
          catch (NumberFormatException e) { e.printStackTrace(); }
        return c;
    }thanks LIZ
    PS If you can help how do I Give the Duke dollers to you

    http://www.google.ca/search?q=java+oval+shape+to+plot&hl=en&lr=&ie=UTF-8&oe=UTF-8&start=10&sa=N
    Ask the guy who made it for more help

  • Hyperlink in iGrid Cell?

    Hi,
    Is it possible to have a hyperlink in a iGrid cell?
    Thanks,
    Sara

    Sara:
    My technique is to use a string property (a string transaction output), then I wrote a library of small transactions that create the correct HTML content for various types of HTML tags (tables, rows, columns, divs, etc).  I invoke these as needed, and the resultant HTML snippet is appended to the string transaction output property.
    To generate the HTML content, I invoke the runner servlet, pass the name of the appropriate output parameter in OutputParameter=XXX, and add to the URL:
    &Content-Type=text/html
    I've used this technique to create specialized tables, gantt charts, and entire pages dynamically as well.
    AJAX is also a viable approach.  The only real disadvantage is that you can't edit/manage the application logic as easily in a single place, but it is definitely a good approach to use AJAX if you'll be leveraging some of the very cool AJAX UI libraries out there.
    Again, I am a big fan of Adobe Flex also.  It can easily integrate with/share events with the MII applets and other HTML content on the page, or you can build entire apps with Flex using just MII as the back end.
    Hope this helps,
    Rick

  • Hyperlink in java

    Is it possible to create hyperlink in java. If so please give me some suggestions

    use
    getAppletContext().showDocument
    (new URL("URL_TO_YOUR_IMAGE"));
    getAppletContext().showDocument
    (new URL("http://www.whatever.com"),"HTML FRAME
    ID");
    If "HTML frame ID" do not exists then a new browser
    window will be opened. The following "HTML frame ID"
    have special meanings :
    "_self" current frame
    "_parent" parent frame
    "_top" base frame
    "_blank" new window
    a complete example of a button :
    import java.applet.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.net.*;
    ublic class GotoURLButton extends Applet implements
    ActionListener {
    tton b;
    TextField t;
    public void init() {
    t = new TextField(20);
    t.setText("URL_TO_YOUR_IMAGE");
    add(t);
    b = new Button("Go to this URL");
    add(b);
    b.addActionListener(this);
    public void actionPerformed(ActionEvent ae) {
    if (ae.getSource() == b) {
    try {
    getAppletContext().showDocument(new
    URL(t.getText()));
    catch (Exception e) {
    e.printStackTrace();
    is this your stock response to every "hyperlink in java" question?? what if the question isn't related to applets? what if it's not even related to web-based code at all?
    @OP: you need to be a bit more specific about what you mean by "hyperlink". don't just give me a description of what a hyperlink does ("I want something where you click and it goes to the web page" isn't good enough). where do you want this link to be present? in a swing application? a JSP? an applet? where?

  • Applets on linked page won't open

    This is probably a really basic question, but I'm stumped.
    I have two domains and both have applets. When I use a text hyperlink to go to the other site, the .class files don't seem to be made available. Is that what
    getAppletContext() .showDocument(new URL("http://www.***.com"),
    is for? And what do you do? put quotations around the line and use it as the URL of the text hyperlink?
    I'm using Netscape 4.5 and IntExplorer6.
    The two domains (which are under construction) are:
    http://www.showsnap.com
    http://www.computerpuzzle.com

    So what exactly do you want - to have your applet open another window with the specified URL? If so, the yes, that's what showDocument() is for.
    AppletContext appletContext = getAppletContext();
    URL url = null;
    String URLString;
    //read the string specifying the URL from a parameter supplied  to the applet
    URLString = getParameter("PAGENAME");
    //alternatively, you could just specify it by your self, but then you'd have to recompile each time you wanted to change the URL
    //URLString = "http://www.somesite.com";
    //try to form an URL from the string and check whether it's correct or not
    try
    url = new URL(URLString);
    catch (MalformedURLException malf)
    System.out.println("Bad URL:" + URLString);     
    //if the url was created succesfully, display it in the specified frame ("_blank")
    if (url != null)
    appletContext.showDocument(url, "_blank");

Maybe you are looking for

  • How do i play podcast in order

    can anyone help me out.. im new to the whole podcasting thing but im loving it ok its just one problem ... being a noob to this try not to laugh ok but i cant seem to listen to my podcast in order from old to new i have a 5 gen ipod (black). is there

  • Create dynamic view link

    my problem is I build the first view link by using createViewObjectFromQueryStmt method on my application module instance ,then I build the second view link by using createViewObjectFromQueryStmt method on my application module instance,now when I us

  • Biochemist in desperate need of Java expertise!

    Hello People I'm a Biochemist, with no programming experience at all! I have an assignment where I have to create a programme whereby I store an array of different values for an amino acid (single char); I then paste in an amino acid sequence (a stri

  • ActiveX Crystal Report Control

    Post Author: JLTerMarsch CA Forum: General I am using Crystal Reports 8.5 Developer. I know it is old, but I am using the original Crystal Reports Control ActiveX. Where can I get a list of the available commands available to me? e.g. printreport, ex

  • Intel Core Duo MacBook 802.11n

    I have a MacBook with Core duo. It can not recieve 802.11n, but I have seen a few different options for upgrading. One of those includes buying a Mac Pro Wireless Kit from apple and installing the card into the MacBook. I found this on the HardMac si