Checkbox applet

I need some help on an applet I am writing. I need the applet to monitor 6 checkboxes. If any number of boxes are checked I need a message to appear in a text box. If none of the boxes are checked I need the text box to clear.
I need this to happen "on-the-fly", if one box is ticked I need the message, if the user unticks the box, I need the message to go.
I have the boxes, and text box working but cannot get the message to appear at the right times.
It will only work for two of the boxes, when I try to get the third box to be monitored, the whole thing falls apart and doesn't work at all as it should.
Can what I want be done? Or am I trying to do the impossible?
Please help
nrestell

is it now possible to add 5 more checkboxes that have
a different message? Can that be done simply by
repeating what is already there but changing the name
of "j" and "checkedCount"?My previous post was supposed just to be a "proof of concept" for the counter idea. In order to add more sets of check boxes, it seems like the design needs to be changed a little in order not to get too tied up with keeping track of which check box is being changed and which count needs to be updated. So I made the ItemListener into its own full-fledged class so there could be multiple instances of it, each with its own counter, label, and message. That way the listener keeps track of what it needs to be updating.
import java.awt.*;
import java.awt.event.*;
import java.applet.Applet;
public class CheckMe extends Applet {
  public void init()
    setLayout(new GridLayout(1,2));
    Panel group1 = new Panel(new GridLayout(7,1));
    Panel group2 = new Panel(new GridLayout(6,1));
    Checkbox[] cb1 = new Checkbox[6];
    Label lbl1 = new Label();           // create empty label
    CheckboxListener cbl1 = new CheckboxListener(lbl1, "First Message");
    for(int j=0; j<6; j++) {
      cb1[j] = new Checkbox(cbLabels[j], false);
      cb1[j].addItemListener(cbl1);
      group1.add(cb1[j]);
    group1.add(lbl1);
    Checkbox[] cb2 = new Checkbox[5];
    Label lbl2 = new Label();           // create empty label
    CheckboxListener cbl2 =
                    new CheckboxListener(lbl2, "Second  Message");
    for(int j=0; j<5; j++) {
      cb2[j] = new Checkbox(cbLabels[j], false);
      cb2[j].addItemListener(cbl2);
      group2.add(cb2[j]);
    group2.add(lbl2);
    add(group1);
    add(group2);
  private static final String[] cbLabels =
              {"one", "two", "three", "four", "five", "six"};
class CheckboxListener implements ItemListener {
  public CheckboxListener(Label lbl, String msg)
    label = lbl;
    message = msg;
  public void itemStateChanged(ItemEvent e)
    if(e.getStateChange() == ItemEvent.SELECTED)
      checkedCount++;
    if(e.getStateChange() == ItemEvent.DESELECTED)
      checkedCount--;
    if(checkedCount > 0)
      label.setText(message);
    else
      label.setText("");
  private int checkedCount = 0;     // count of how many boxes are checked
  private Label label;
  private String message;

Similar Messages

  • After Java patch 1.7.0_07 ENable applet plug-in and Web start checkbox is gone!

    Hello all,
    Using ML 10.8.1 and Safair 6.0
    After Java patch 1.7.0_07 ENable applet plug-in and Web start checkbox is gone! The check box to enable Safari to load Java pages is 100% gone, missing, just not there anymore.
    When I go to the Java test page it shows that I have Java 7 loaded. Has anyone else run into this problem or have a solution to enable true load loading in Safari and bring back the Enable applet plug-in and Web Start application check box in ML...
    Thanks

    I found out something very interesting. I noticed that another page would show up for less than have a second before the ML Java Preference would show up. I did a video recording of this and moved frame by frame. I show that the page / pane showing up had the following option:
                    Run applets:  in their own process
                                         within their browser process
    Both boxes for the two are unchecked.
    Then this page would disappear and nother would show up without the option / check box
    Enable applet plugin and Web Start applications
    Strange

  • Re: Java Applet w/ Checkbox Group and Alignment Probs

    Bad idea:if( e.getActionCommand() == "Calculate")
    if( e.getActionCommand() == "Clear")
    ...Good idea:if( "Calculate".equals(e.getActionCommand()) )
    if( "Clear".equals(e.getActionCommand()) )
    ...Search the forum/web/API docs for an explanation ...

    But why won't the checkbuttons reset to false when I tell them to??
    Thanks

  • Check boxes are not being displayed in any list applets

    Issue: The check boxes are not being displayed in any list applets in the system. A check box can be marked in the system, but as soon as the user clicks anywhere outside of the box the check box 'visibly' disappears. If you hover the mouse over the check box it displays a 'Y'. However, check boxes are working fine for the form applet, the issue is only with the list applet.
    I verified the checkboxes work fine in the thick client and in production. However, it is the testing environment, which belongs to client, that is showing the above behavior. I think there is some setting that is missing for them. But I am unable to figure it. I would really appreciate if someone could help !!
    Thanks in advance

    One way that you could make it work (just tried it out again) is to use the windings font
    and use the checkboxes from there. However, you need to register the font with xml publisher. In the template builder for Word, you can put a configuration file under:
    C:\Program Files\Oracle\XML Publisher Desktop\Template Builder for Word\config
    (depnding on your installation). The file should have the name xdo.cfg or xdoconfig.xml.
    There is an example file: xdo example.cfg that you rename and change accoringly.
    The font is there setup for windows 2000 as an example. Select the correct font
    path - for my XP it is:
    <font family="Wingdings" style="normal" weight="normal">
    <truetype path="C:\WINDOWS\fonts\wingding.ttf" />
    </font>
    Then you can put the symbols into your RTF template and it will be rendered.
    At least it worked for me - with 5.6.2. (Availbable on Wednesday or Thursday), but
    I am pretty sure I tried it before with 5.5.
    Didn't have the 5.5 manual with me - so I have to check what that says again..
    Hope it helps,
    Klaus

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

  • Getting applets to work in Firefox or IE7!!

    Hi folks.
    I've been reading Jason Hunters excellet book on Java Servlet Programming and become rather stuck on being able to get applets to work in a browser.
    1) I managed to briefly get an Applet to work in IE7. Then things went astray (I say work, because applet initially displayed correctly graphically)
    2) I introduced a bug and tried to redisplay. And haven't been able to recover.
    3) When 2) occurred I swapped over to Firefox, since IE7 doesn't have a Java Console. (& theres no setting to enable it in security settings either)
    4) Then Firefox prompted to download JRE... This was an odd one to me.... Since I already had a Java runtime...
    I got this through downloading file java_app_platform_sdk-5_04-windows.exe
    java -version yeilds:
    Microsoft Windows XP [Version 5.1.2600]
    (C) Copyright 1985-2001 Microsoft Corp.
    C:\Documents and Settings\Jeremy>java -version
    java version "1.6.0_04"
    Java(TM) SE Runtime Environment (build 1.6.0_04-b12)
    Java HotSpot(TM) Client VM (build 10.0-b19, mixed mode)
    C:\Documents and Settings\Jeremy>
    Browser Versions
    IE : is at version 7.0.5730.13
    Firefox started out at 2.0.0.12... Now Firefox didn't seem to detect the JRE
    5) It said additional plugins are required to display the media on this page...
    6) I clicked the button to "Install missing plugins"
    It then presents Plugin Finder Service with "Available Plugin Downloads" of Java Runtime Environment with checkbox ticked.
    7) I clicked "next", at which point it completes saying
    No plugins were installed
    Java Runtime Environment failed with "Manual Install" button...
    Clicking said button gave me executeable xpiinstall.exe from http://sdlc-esd.sun.com
    8) When I ran this it
    a) proceeded to cause Firefox to crash and a report was sent to Mozilla...
    b) created a restore point called "Installed Java (TM) 6 update 5..
    9)So now I went back to IE 7 having given up on Firefox...
    Now it complained about missing classes which I felt sure were in a jar I'd deployed in Tomcat...
    10) I tried to validate my assumptions by looking inside the Jar with Winzip...
    Then I got a pop up with "Java Virtual Machine Launcher" in its title saying..
    "Failed to load Main-Class manifest attribute from cos.jar"
    At this point I realised 8) was the culprit after posting here and looking at possible causes for said pop-up.
    [http://www.artima.com/forums/flat.jsp?forum=1&thread=61427&start=75&msRange=15]
    None of solutions posted there seemed to apply to me
    11) So now I restored to a restore point prior to 8) and though my problems were over
    12) I've since upgraded to Firefox 2.0.0.14. Firefox pushed update to me. Also tried manually uninstalling and downloading file. Still saying missing plugin!!!
    13) I've tried changing my tags in my html from
    APPLET to OBJECT for IE7 or EMBED for Firefox..
    I've validated my APPLET with APPLETVIEWER following advice posted here:
    [http://java.sun.com/docs/books/tutorial/deployment/applet/index.html]
    No tell tale signs appear in Tomcat Console or logs..
    *The only thing that seems weird is codebase tag*
    14) Book I've been reading mentioned putting both html code and applet class in root folder of tomcat
    I've hosted both files here:
    C:\Apps\apache-tomcat-6.0.16\webapps\ROOT
    15) When I test with appletviewer from this folder and codebase set to / appletviewer doesn't find class.
    I think I need to set this so when web browser runs it finds class. Maybe this is the route of my problems.
    What's haunting me here though is placeholder for applet graphic worked at one point!
    I don't recall fussing with codebase attribute of applet tag, yet suddenly things stopped working.
    16) When I tried to verify with appletviewer I had to remove codebase attribute completely to get things to work.
    Here are three versions of html file. Firefox version doesn't seem to be recognized by Appletviewer
    Applet tag version: (BTW have tried with CODEBASE=/ too. This was how it appeared in book, Remember I'm hosting in Tomcat 6.0.16)
    {code}
    <HTML>
    <HEAD><TITLE>Daytime Applet</TITLE></HEAD>
    <BODY>
    <CENTER><H1>Daytime Applet</H1></CENTER>
    <CENTER><APPLET CODE="DaytimeApplet.class" WIDTH=300 HEIGHT=180></APPLET></CENTER>
    </BODY></HTML>
    {code}
    IE Version only
    {code}
    <HTML>
    <HEAD><TITLE>Daytime Applet</TITLE></HEAD>
    <BODY>
    <CENTER><H1>Daytime Applet</H1></CENTER>
    <CENTER><object classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
    width="300" height="180">
    <param name="code" value="DaytimeApplet.class"></object></CENTER>
    </BODY></HTML>
    {code}
    Firefox version with JRE matching what java -version says precisely and using "jpi-version" so need for download instructions url 'should' be redundant..
    {code}
    <HTML>
    <HEAD><TITLE>Daytime Applet</TITLE></HEAD>
    <BODY>
    <CENTER><H1>Daytime Applet</H1></CENTER>
    <CENTER>
    <embed code="DaytimeApplet.class"
    width="300" height="180"
    type="application/x-java-applet;jpi-version=1.6.0_04"/>
    </CENTER>
    </BODY></HTML>
    {code}
    I don't want to be staring at a placeholder in a Web Browser.
    I want to GUI as it appears in AppletViewer and how it once had it working in IE7!
    You wouldn' t think that was to much to ask for would you! Sorry for length of this post.
    Any clues as to where to go next would be greatly appreciated as I'm pulling hairs out with frustration at the moment...
    A few of footnotes:
    1) I've relaxed my security zone settings for intranet, added localhost to local intranet sites..
    2) I've tried deleting all temporay files in IE7 even to point of resetting to install setup thinking there may be some sort of caching issue with bad applet... No luck
    3) I can still get Glassfish server to login to Admin Console.
    So the integrity of my pc should me intact based on the shenanigans of point 11. Restoring to get rid of second JRE

    paulcw wrote:
    I'm not sure what to tell you. I've never had any trouble installing the JRE and getting applets to work. Maybe it's an IE7 thing. Firefox is usually easier to configure.
    Anyway, it sounds like something that you need to be sitting at your computer to fix, so I don't know how useful a forum will be. It might be best just to ask a coworker with a lot of arcane knowledge to take a look at it.1) Unfortunately I'm learning from home and don't have the luxury of asking a co-worker. Have fired off email to one of folks at Sun..
    In my efforts to try and track down the problem yesterday, Google uncovered some interesting findings regarding Caching of Applets. Thought I'd share this:
    2) [http://www.velocityreviews.com/forums/t603400-ltobjectgt-tag-and-applet-caching.html]
    There is an interesting post some way down posted by james.a.cleland
    Quote:
    "My solution is to x-c in the Java console to clear
    this cache. This works without unloading the JVM and while the applet
    is running. It looks like the browser isn't caching any applets. At
    least my browser cache doesn't contain any, although I do regularly
    use half a dozen, so it must be the JRE. Anyway, clearing through the
    console solves my problem".
    I can't access Java Console in IE7 as you know...
    3) There is always another way to skin a cat regarding clearing cache.
    Found this here:
    [http://www.aurigma.com/Support/DocViewer/28/UpdatingImageUploaderonClientSide.htm.aspx]
    Search for Java section
    Quote:
    "Java applets are stored in the cache that is accessible through the Java control panel. Follow these steps to do it:
    Open Java Plug-in Control Panel. Depending on the platform, it can be found in different locations:
    Windows: Control Panel -> Java Plug-in
    Click the Cache tab.
    Click Clear to clear all cached applets."
    *Problem is that there is no Java Plug-In within Control panel. Mentioned this with Coffee Cup reference above..*
    4) Also saw this article on *"How to troubleshoot Java applet and component download problems"* at:
    [http://support.microsoft.com/kb/241111]
    Java console or output log section:
    Javalog.txt in the windows\java or winnt\java directory
    windows\java contains
    - classes
    - trustdb
    No such file: classes & trustdb are empty folders.
    5) I have same problem mentioned here:
    [http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=915520&SiteID=1]
    Quote:
    "I cannot get java applets to display on any web pages - instead this message appears:
    alt="Your browser understands the <APPLET> tag but isn't running the applet, for some reason." Your browser is completely ignoring the <APPLET> tag! "
    Yep. That's my predicament.
    BTW: Get this by doing test here:
    [http://java.sun.com/products/plugin/1.5.0/demos/applets/Clock/example1.html]
    6) Sun's Verify Installation fails on me too:
    [http://www.java.com/en/download/installed.jsp]
    7) I'm interested in knowing how IE7 caches the applets too. Does it store some sort of class-id in the registry? (I'm on XP SP2)
    8) Is there an installation integrity verifier for Sun? Something that verifies the integrity against a baseline install and reports anomalies.Like I mentioned earlier I've got java_app_platform_sdk-5_04-windows.exe file installed. Not the latest incarnation, but the one immediately before. With SE 1.6.0_04-b12 built built into it

  • Mouse clicks in IE with applet not responding

    We have an applet containing a JTree inside a JScrollPane loaded in a frame in Internet Explorer. The JTree has a thread for each node under the root that polls and updates the tree on a set interval (say 30 seconds). For some reason, when the applet is visible form elements in regular HTML pages in other frames no longer repaint properly when clicked. If you click on a checkbox for example, it won't repaint with the check showing until you move the mouse. Also, if you go to load the page in the browser and don't move your mouse, the page doesn't do any loading until the mouse is moved. It seems like there is some weird interaction going on here with the browser, applet, and mouse events.
    Any ideas on what could be causing such a thing to happen?
    Thanks!

    Are you sending your JSP page to your applet first then from the applet opening a separate IE frame with the generated page?
    I came across the following. Hope it helps.
    <% request.setAttribute("_cache_refresh", "true"); %>
    QUOTE:
    "If you want all caches to be refreshed, set the cache to the application scope. If you want all the caches for a user to be refreshed, set it in the session scope. If you want all the caches in the current request to be refreshed, set the _cache_refresh object either as a parameter or in the request.
    The <wl:cache> tag specifies content that must be updated each time it is displayed. The statements between the <wl:cache> and </wl:cache> tags are only executed if the cache has expired or if any of the values of the key attributes have changed."
    Regards,
    Devyn

  • Can't run JRE 1.2.2 applets once 1.4.1 installed

    I have an applet developed with JDK 1.2.2 (uses 3rd-party jars) which was working perfectly with the 1.2.2 plug-in
    that comes with the JDK.
    The OBJECT tag specifies the dynamic versioning clsid clsid:8AD9C840-044E-11D1-B3E9-00805F499D93 (which is the
    only possibility for 1.2.2?).
    However, when users who have downloaded the 1.4.1 plug-in run the applet (quite apart from the fact that I have had
    to solve a problem where plug-in 1.2.2 accepts PARAMs with initail _ but plug-in 1.4.1 does not!) they are
    getting an ExceptionInInitializerError inside one of the 3rd-party libraries. I have reproduced this
    error on my Windows XP PC (IE 6). The stack trace is as follows :
    (this has been reproduced outside of the browser using JRE 1.4.1 because the 1.4.1 plug-in console won't display,
    even after manually running the Console and setting the Show Console checkbox,
    and the icon doesn't appear on the System menu, presumably all because I have JDK 1.2.2 + plug-in installed)
    java.lang.ExceptionInInitializerError
    at javax.crypto.Mac.getInstance(DashoA6275)
    at com.baltimore.jpkiplus.pkcs12.PFX.fromASN1Object([DashoPro-V1.3-01300
    0])
    at com.baltimore.jpkiplus.pkcs12.PFX.fromBER([DashoPro-V1.3-013000])
    at com.baltimore.jpkiplus.pkcs12.PFX.<init>([DashoPro-V1.3-013000])
    at com.baltimore.jpkiplus.pkidevice.PKCS12Provider.openFile([DashoPro-V1
    .3-013000])
    at com.baltimore.jpkiplus.pkidevice.PKCS12Provider.openFile([DashoPro-V1
    .3-013000])
    at com.baltimore.jpkiplus.pkidevice.PKCS12Device.initInstance([DashoPro-
    V1.3-013000])
    at com.baltimore.jpkiplus.pkidevice.PKIDeviceManager.getPKIDevice([Dasho
    Pro-V1.3-013000])
    at com.baltimore.jpkiplus.vaults.Vault.a([DashoPro-V1.3-013000])
    at com.baltimore.jpkiplus.vaults.Vault.openVault([DashoPro-V1.3-013000])
    at mailsign.signer.signAndSend(signer.java:262)
    at mailsign.AppletSigner.signAndSend(AppletSigner.java:329)
    at mailsign.AppletSigner.action(AppletSigner.java:521)
    at java.awt.Component.handleEvent(Unknown Source)
    at java.awt.Component.postEvent(Unknown Source)
    at java.awt.Component.postEvent(Unknown Source)
    at java.awt.Component.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)
    Caused by: java.lang.SecurityException: Cannot set up certs for trusted CAs
    at javax.crypto.SunJCE_b.<clinit>(DashoA6275)
    ... 24 more
    Caused by: java.lang.UnsupportedOperationException
    at java.security.cert.CertificateFactorySpi.engineGenerateCertPath(Unkno
    wn Source)
    at java.security.cert.CertificateFactory.generateCertPath(Unknown Source
    at javax.crypto.SunJCE_d.a(DashoA6275)
    at javax.crypto.SunJCE_d.a(DashoA6275)
    at javax.crypto.SunJCE_b.i(DashoA6275)
    at javax.crypto.SunJCE_b.h(DashoA6275)
    at javax.crypto.SunJCE_v.run(DashoA6275)
    at java.security.AccessController.doPrivileged(Native Method)
    ... 25 more
    In my opinion, this has something to do with the way service providers are handled. The 3rd party jar requires
    a Security.insertProviderAt () call. My suspicion is that there is some kind of conflict with the JCE stuff
    that comes bundled with JRE 1.4.1 to handle RSA signed applets. I found a similar conflict with the 1.2.2 JRE
    when I tried to jarsign the 3rd-party libraries - I was getting, at runtime, either some kind of infinite loop hanging or
    a stack overflow due to recursive function calls.
    The fact that I can run the applet as a main and that I get the exact same error running the app from the DOS
    prompt would indicate that this is a JRE 1.4.1 problem (surely the JREs are supposed to be downwardly-
    compatible??!!! - i.e. the JRE 1.4 should run apps compiled with JDK 1.2.2 without any problem). Yes, I have
    run the app as a main with JRE 1.2.2 and all works fine.
    However, I could get around this if I could force the 1.2.2 plug-in to run instead of the 1.4.1 plug-in (quite
    how the users are going to be able to get the 1.2.2 plug-in if they have plug-in 1.4.1 installed
    without being Java experts is a problem I will leave
    till later when I try to figure out how to make my applet an RSA signed applet (which if the documentation is
    correct are only available from 1.3 onwards, hence solving this 1.4.1 problem would be VERY nice)).
    But the problem is that once the 1.4.1 plug-in is installed, it always takes precedence over lower versions.
    It's not obvious from the documentation whether older plug-in versions get executed when static versioning
    is used for the clsid in the OBJECT tag. I can't be bothered to download a 1.3 plug-in and try.
    However, unless I am mistaken, there is not a static versioning clsid for plug-in 1.2.2 ?????
    In summary, once users download a plug-in version greater than 1.2.2 (presumably by running another applet from some
    other site that requires eg 1.4.1 - I guess Sun's aim is to make the Plug-In as prevalent as possible, hence
    this is not a far-fetched scenario), it is no longer possible for my applet to be run by a 1.2.2 JRE !!!!!!!
    Because the 1.4.1 JRE is not downwardly-compatible, it can't run my 1.2.2-developed applet and my deployed
    application is broke.
    Unless I am missing something somewhere (which is possible because I am getting fed up of solving problem after
    problem with the Plug-In - eg the mess of setting the right codebase to get different plug-ins to be downloaded
    automatically - the HTML converter doesn't always set up the codebase correctly), this seems like a nightmare
    for applet developers - from one day to the next your applications will break because of Sun's plug-in upgrading.
    Please tell me there is a way to force the 1.2.2 JRE/plug-in to execute instead of 1.4.1 and that there is a
    way for the 1.2.2 plug-in to be downloaded automatically by users even when they have 1.4.1 already installed.

    Are you using signtool? I had a problem where applets stopped working when I went from JRE 1.3.1_01a to 1.3.1_07. I updated the signtool from 1.1 to 1.3 and now my applets run.
    Mark

  • Applet doesn´t load in java 7 with next-generation plug-in marked

    I have developed an applet with netbeans 7.1.2 which worked fine until I updated from jvm6 to jvm7. The applet does not load properly unless I uncheck from the configuration of the jvm the checbox plug-in next-generation.
    Anyone know why in java 6 working properly with the plug-in next generation and in java 7 do not?
    I can do something to work properly in Java 7 without having to uncheck the checkbox?
    Thanks.

    1 - Java installed -> 1.7.0_05-b06. In Firefox works fine. The problem is in IE8.
    2 - I can run other applets.
    3-
    security: property package.access value sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.,com.sun.org.apache.xerces.internal.utils.,com.sun.org.apache.xalan.internal.utils.
    security: property package.access new value sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.,com.sun.org.apache.xerces.internal.utils.,com.sun.org.apache.xalan.internal.utils.,com.sun.javaws
    security: property package.access value sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.,com.sun.org.apache.xerces.internal.utils.,com.sun.org.apache.xalan.internal.utils.,com.sun.javaws
    security: property package.access new value sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.,com.sun.org.apache.xerces.internal.utils.,com.sun.org.apache.xalan.internal.utils.,com.sun.javaws,com.sun.deploy
    security: property package.access value sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.,com.sun.org.apache.xerces.internal.utils.,com.sun.org.apache.xalan.internal.utils.,com.sun.javaws,com.sun.deploy
    security: property package.access new value sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.,com.sun.org.apache.xerces.internal.utils.,com.sun.org.apache.xalan.internal.utils.,com.sun.javaws,com.sun.deploy,com.sun.jnlp
    security: property package.definition value null
    security: property package.definition new value com.sun.javaws
    security: property package.definition value com.sun.javaws
    security: property package.definition new value com.sun.javaws,com.sun.deploy
    security: property package.definition value com.sun.javaws,com.sun.deploy
    security: property package.definition new value com.sun.javaws,com.sun.deploy,com.sun.jnlp
    security: property package.access value sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.,com.sun.org.apache.xerces.internal.utils.,com.sun.org.apache.xalan.internal.utils.,com.sun.javaws,com.sun.deploy,com.sun.jnlp
    security: property package.access new value sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.,com.sun.org.apache.xerces.internal.utils.,com.sun.org.apache.xalan.internal.utils.,com.sun.javaws,com.sun.deploy,com.sun.jnlp,org.mozilla.jss
    security: property package.definition value com.sun.javaws,com.sun.deploy,com.sun.jnlp
    security: property package.definition new value com.sun.javaws,com.sun.deploy,com.sun.jnlp,org.mozilla.jss
    basic: Listener de progreso agregado: sun.plugin.util.ProgressMonitorAdapter@bbe282
    basic: Plugin2ClassLoader.addURL parent called for .../appletFirma/lib/bcmail-jdk13-145.zip
    basic: Plugin2ClassLoader.addURL parent called for.../appletFirma/lib/jce-ext-jdk13-145.zip
    basic: Plugin2ClassLoader.addURL parent called for .../appletFirma/lib/AbsoluteLayout.jar
    basic: Plugin2ClassLoader.addURL parent called for .../appletFirma/lib/plugin.jar
    basic: Plugin2ClassLoader.addURL parent called for .../appletFirma/AppletAplication.jar
    security: Se ha activado la comprobación de revocación de la lista negra
    security: Está activada la comprobación de lista de bibliotecas de confianza
    network: Se ha encontrado la entrada de caché [URL: .../appletFirma/lib/bcmail-jdk13-145.zip, versión: null] prevalidated=false/0
    cache: Resource .../appletFirma/lib/bcmail-jdk13-145.zip has expired.
    network: Conectando.../appletFirma/lib/bcmail-jdk13-145.zip con proxy=DIRECT
    network: Conectando.../ con proxy=DIRECT
    network: Conectando .../appletFirma/lib/bcmail-jdk13-145.zip con cookie "__utma=153011745.179473224.1324411077.1324563223.1326992570.4; DomAuthSessId=07A8675D20F4CBAA6E2D638B5330E7A0"
    network: ResponseCode de.../appletFirma/lib/bcmail-jdk13-145.zip: 304
    network: Codificación de .../appletFirma/lib/bcmail-jdk13-145.zip: null
    network: Desconectar conexión con .../appletFirma/lib/bcmail-jdk13-145.zip
    cache: Reading Signers from 2157 .../appletFirma/lib/bcmail-jdk13-145.zip | C:\Documents and Settings\Francisco Alvarez\Configuración local\Datos de programa\Sun\Java\Deployment\cache\6.0\1\282adb01-384a1e15.idx
    cache: Done readSigners(.../appletFirma/lib/bcmail-jdk13-145.zip)
    cache: Read manifest for .../appletFirma/lib/bcmail-jdk13-145.zip: read=201 full=5808
    security: Cargando certificados de despliegue desde C:\Documents and Settings\Francisco Alvarez\Datos de programa\Sun\Java\Deployment\security\trusted.certs
    security: Se han cargado certificados de despliegue desde C:\Documents and Settings\Francisco Alvarez\Datos de programa\Sun\Java\Deployment\security\trusted.certs
    security: Cargando certificados del almacén de certificados de la sesión de despliegue
    security: Certificados cargados del almacén de certificados de la sesión de despliegue
    security: Cargando certificados del almacén de certificados TrustedPublisher de Internet Explorer
    security: Certificados cargados desde el almacén de certificados TrustedPublisher de Internet Explorer
    security: Validar la cadena de certificados utilizando la API CertPath
    security: Cargando certificados del almacén de certificados ROOT de Internet Explorer
    security: Certificados cargados desde el almacén de certificados ROOT de Internet Explorer
    security: Cargando certificados de CA raíz desde C:\Documents and Settings\Francisco Alvarez\Datos de programa\Sun\Java\Deployment\security\trusted.cacerts
    security: Certificados de CA raíz cargados desde C:\Documents and Settings\Francisco Alvarez\Datos de programa\Sun\Java\Deployment\security\trusted.cacerts
    security: Cargando certificados de CA raíz desde C:\Archivos de programa\Java\jre7\lib\security\cacerts
    security: Certificados de CA raíz cargados desde C:\Archivos de programa\Java\jre7\lib\security\cacerts
    security: Obtener recopilación de certificados del almacén de certificados de CA raíz
    security: Obtener recopilación de certificados del almacén de certificados de CA raíz
    security: Obtener recopilación de certificados del almacén de certificados de CA raíz
    security: Obtener recopilación de certificados del almacén de certificados de CA raíz
    security: El certificado no ha caducado. No es preciso comprobar la información sobre el registro de hora
    security: Se ha encontrado el archivo de lista de jurisdicciones
    security: No se necesita comprobar la extensión de confianza de este certificado
    security: El soporte de CRL está desactivado
    security: El soporte de OCSP está desactivado
    security: Esta validación de entidad final de OCSP está desactivada
    security: Comprobando si el certificado está en el almacén de certificados denegados de despliegue
    security: Comprobando si el certificado está en el almacén permanente de certificados de despliegue
    security: Comprobando si el certificado está en el almacén de certificados de la sesión de despliegue
    security: Comprobando si el certificado está en el almacén de certificados TrustedPublisher de Internet Explorer
    basic: Dialog type is not candidate for embedding
    security: El usuario ha otorgado privilegios de código sólo para esta sesión
    security: Agregando certificado en el almacén de certificados de la sesión de despliegue
    security: Certificados agregados en el almacén de certificados de la sesión de despliegue
    security: Guardando certificados en el almacén de certificados de la sesión de despliegue
    security: Certificados guardados en el almacén de certificados de la sesión de despliegue
    network: Se ha encontrado la entrada de caché [URL:.../appletFirma/lib/jce-ext-jdk13-145.zip, versión: null] prevalidated=false/0
    cache: Resource http://desarrollo.isaltda.com.uy/appletFirma/lib/jce-ext-jdk13-145.zip has expired.
    network: Conectando .../appletFirma/lib/jce-ext-jdk13-145.zip con proxy=DIRECT
    network: Conectando .../appletFirma/lib/jce-ext-jdk13-145.zip con cookie "__utma=153011745.179473224.1324411077.1324563223.1326992570.4; DomAuthSessId=07A8675D20F4CBAA6E2D638B5330E7A0"
    network: ResponseCode de .../appletFirma/lib/jce-ext-jdk13-145.zip: 304
    network: Codificación de .../appletFirma/lib/jce-ext-jdk13-145.zip: null
    network: Desconectar conexión con .../appletFirma/lib/jce-ext-jdk13-145.zip
    cache: Reading Signers from 2157 .../appletFirma/lib/jce-ext-jdk13-145.zip | C:\Documents and Settings\Francisco Alvarez\Configuración local\Datos de programa\Sun\Java\Deployment\cache\6.0\37\590df8a5-7d87e233.idx
    cache: Done readSigners(.../appletFirma/lib/jce-ext-jdk13-145.zip)
    cache: Read manifest for .../appletFirma/lib/jce-ext-jdk13-145.zip: read=202 full=47488
    security: Validar la cadena de certificados utilizando la API CertPath
    security: El certificado no ha caducado. No es preciso comprobar la información sobre el registro de hora
    security: Se ha encontrado el archivo de lista de jurisdicciones
    security: No se necesita comprobar la extensión de confianza de este certificado
    security: El soporte de CRL está desactivado
    security: El soporte de OCSP está desactivado
    security: Esta validación de entidad final de OCSP está desactivada
    security: Comprobando si el certificado está en el almacén de certificados denegados de despliegue
    security: Comprobando si el certificado está en el almacén permanente de certificados de despliegue
    security: Comprobando si el certificado está en el almacén de certificados de la sesión de despliegue
    network: Se ha encontrado la entrada de caché [URL: .../appletFirma/lib/AbsoluteLayout.jar, versión: null] prevalidated=false/0
    cache: Resource .../appletFirma/lib/AbsoluteLayout.jar has expired.
    network: Conectando.../appletFirma/lib/AbsoluteLayout.jar con proxy=DIRECT
    network: Conectando .../appletFirma/lib/AbsoluteLayout.jar con cookie "__utma=153011745.179473224.1324411077.1324563223.1326992570.4; DomAuthSessId=07A8675D20F4CBAA6E2D638B5330E7A0"
    network: ResponseCode de.../appletFirma/lib/AbsoluteLayout.jar: 304
    network: Codificación de.../appletFirma/lib/AbsoluteLayout.jar: null
    network: Desconectar conexión con .../appletFirma/lib/AbsoluteLayout.jar
    cache: Reading Signers from 1055 .../appletFirma/lib/AbsoluteLayout.jar | C:\Documents and Settings\Francisco Alvarez\Configuración local\Datos de programa\Sun\Java\Deployment\cache\6.0\17\56fa4991-262eae08.idx
    cache: Done readSigners(.../appletFirma/lib/AbsoluteLayout.jar)
    cache: Read manifest for.../appletFirma/lib/AbsoluteLayout.jar: read=283 full=283
    security: Validar la cadena de certificados utilizando la API CertPath
    security: El certificado no ha caducado. No es preciso comprobar la información sobre el registro de hora
    security: Se ha encontrado el archivo de lista de jurisdicciones
    security: No se necesita comprobar la extensión de confianza de este certificado
    security: El soporte de CRL está desactivado
    security: El soporte de OCSP está desactivado
    security: Esta validación de entidad final de OCSP está desactivada
    security: Comprobando si el certificado está en el almacén de certificados denegados de despliegue
    security: Comprobando si el certificado está en el almacén permanente de certificados de despliegue
    security: Comprobando si el certificado está en el almacén de certificados de la sesión de despliegue
    security: Comprobando si el certificado está en el almacén de certificados TrustedPublisher de Internet Explorer
    basic: Dialog type is not candidate for embedding
    security: El usuario ha otorgado privilegios de código sólo para esta sesión
    security: Agregando certificado en el almacén de certificados de la sesión de despliegue
    security: Certificados agregados en el almacén de certificados de la sesión de despliegue
    security: Guardando certificados en el almacén de certificados de la sesión de despliegue
    security: Certificados guardados en el almacén de certificados de la sesión de despliegue
    network: Se ha encontrado la entrada de caché [URL:.../appletFirma/lib/plugin.jar, versión: null] prevalidated=false/0
    cache: Resource .../appletFirma/lib/plugin.jar has expired.
    network: Conectando .../appletFirma/lib/plugin.jar con proxy=DIRECT
    network: Conectando.../appletFirma/lib/plugin.jar con cookie "__utma=153011745.179473224.1324411077.1324563223.1326992570.4; DomAuthSessId=07A8675D20F4CBAA6E2D638B5330E7A0"
    network: ResponseCode de.../appletFirma/lib/plugin.jar: 304
    network: Codificación de .../appletFirma/lib/plugin.jar: null
    network: Desconectar conexión con .../appletFirma/lib/plugin.jar
    cache: Reading Signers from 5 .../appletFirma/lib/plugin.jar | C:\Documents and Settings\Francisco Alvarez\Configuración local\Datos de programa\Sun\Java\Deployment\cache\6.0\15\c16d34f-2740f800.idx
    network: No hay información de certificado para el archivo JAR sin firma: .../appletFirma/lib/plugin.jar
    cache: Done readSigners(.../appletFirma/lib/plugin.jar)
    cache: Read manifest for .../appletFirma/lib/plugin.jar: read=89 full=89
    network: Se ha encontrado la entrada de caché [URL: .../appletFirma/AppletAplication.jar, versión: null] prevalidated=false/0
    cache: Resource .../appletFirma/AppletAplication.jar has expired.
    network: Conectando .../appletFirma/AppletAplication.jar con proxy=DIRECT
    network: Conectando .../appletFirma/AppletAplication.jar con cookie "__utma=153011745.179473224.1324411077.1324563223.1326992570.4; DomAuthSessId=07A8675D20F4CBAA6E2D638B5330E7A0"
    network: ResponseCode de .../appletFirma/AppletAplication.jar: 304
    network: Codificación de .../appletFirma/AppletAplication.jar: null
    network: Desconectar conexión con .../appletFirma/AppletAplication.jar
    cache: Reading Signers from 1055 .../appletFirma/AppletAplication.jar | C:\Documents and Settings\Francisco Alvarez\Configuración local\Datos de programa\Sun\Java\Deployment\cache\6.0\51\609786b3-797751c9.idx
    cache: Done readSigners(.../appletFirma/AppletAplication.jar)
    cache: Read manifest for .../appletFirma/AppletAplication.jar: read=242 full=1552
    security: Validar la cadena de certificados utilizando la API CertPath
    security: El certificado no ha caducado. No es preciso comprobar la información sobre el registro de hora
    security: Se ha encontrado el archivo de lista de jurisdicciones
    security: No se necesita comprobar la extensión de confianza de este certificado
    security: El soporte de CRL está desactivado
    security: El soporte de OCSP está desactivado
    security: Esta validación de entidad final de OCSP está desactivada
    security: Comprobando si el certificado está en el almacén de certificados denegados de despliegue
    security: Comprobando si el certificado está en el almacén permanente de certificados de despliegue
    security: Comprobando si el certificado está en el almacén de certificados de la sesión de despliegue
    security: Validar la cadena de certificados utilizando la API CertPath
    security: El certificado no ha caducado. No es preciso comprobar la información sobre el registro de hora
    security: Se ha encontrado el archivo de lista de jurisdicciones
    security: No se necesita comprobar la extensión de confianza de este certificado
    security: El soporte de CRL está desactivado
    security: El soporte de OCSP está desactivado
    security: Esta validación de entidad final de OCSP está desactivada
    security: Comprobando si el certificado está en el almacén de certificados denegados de despliegue
    security: Comprobando si el certificado está en el almacén permanente de certificados de despliegue
    security: Comprobando si el certificado está en el almacén de certificados de la sesión de despliegue
    basic: Plugin2ClassLoader.getPermissions CeilingPolicy allPerms
    security: Validar la cadena de certificados utilizando la API CertPath
    security: El certificado no ha caducado. No es preciso comprobar la información sobre el registro de hora
    security: Se ha encontrado el archivo de lista de jurisdicciones
    security: No se necesita comprobar la extensión de confianza de este certificado
    security: El soporte de CRL está desactivado
    security: El soporte de OCSP está desactivado
    security: Esta validación de entidad final de OCSP está desactivada
    security: Comprobando si el certificado está en el almacén de certificados denegados de despliegue
    security: Comprobando si el certificado está en el almacén permanente de certificados de despliegue
    security: Comprobando si el certificado está en el almacén de certificados de la sesión de despliegue
    basic: Plugin2ClassLoader.getPermissions CeilingPolicy allPerms
    security: Validar la cadena de certificados utilizando la API CertPath
    security: El certificado no ha caducado. No es preciso comprobar la información sobre el registro de hora
    security: Se ha encontrado el archivo de lista de jurisdicciones
    security: No se necesita comprobar la extensión de confianza de este certificado
    security: El soporte de CRL está desactivado
    security: El soporte de OCSP está desactivado
    security: Esta validación de entidad final de OCSP está desactivada
    security: Comprobando si el certificado está en el almacén de certificados denegados de despliegue
    security: Comprobando si el certificado está en el almacén permanente de certificados de despliegue
    security: Comprobando si el certificado está en el almacén de certificados de la sesión de despliegue
    basic: Plugin2ClassLoader.getPermissions CeilingPolicy allPerms
    security: Validar la cadena de certificados utilizando la API CertPath
    security: El certificado no ha caducado. No es preciso comprobar la información sobre el registro de hora
    security: Se ha encontrado el archivo de lista de jurisdicciones
    security: No se necesita comprobar la extensión de confianza de este certificado
    security: El soporte de CRL está desactivado
    security: El soporte de OCSP está desactivado
    security: Esta validación de entidad final de OCSP está desactivada
    security: Comprobando si el certificado está en el almacén de certificados denegados de despliegue
    security: Comprobando si el certificado está en el almacén permanente de certificados de despliegue
    security: Comprobando si el certificado está en el almacén de certificados de la sesión de despliegue
    basic: Applet cargado.
    basic: Applet resized and added to parent container
    basic: PERF: AppletExecutionRunnable - applet.init() BEGIN ; jvmLaunch dt 305312 us, pluginInit dt 6347309 us, TotalTime: 6652621 us
    security: Validar la cadena de certificados utilizando la API CertPath
    security: El certificado no ha caducado. No es preciso comprobar la información sobre el registro de hora
    security: Se ha encontrado el archivo de lista de jurisdicciones
    security: No se necesita comprobar la extensión de confianza de este certificado
    security: El soporte de CRL está desactivado
    security: El soporte de OCSP está desactivado
    security: Esta validación de entidad final de OCSP está desactivada
    security: Comprobando si el certificado está en el almacén de certificados denegados de despliegue
    security: Comprobando si el certificado está en el almacén permanente de certificados de despliegue
    security: Comprobando si el certificado está en el almacén de certificados de la sesión de despliegue
    basic: Plugin2ClassLoader.getPermissions CeilingPolicy allPerms
    basic: Applet initialized
    basic: Starting applet
    basic: completed perf rollup
    basic: Applet made visible
    basic: Applet started
    basic: Told clients applet is started
    basic: Starting applet teardown
    basic: Finished applet teardown
    basic: Listener de progreso eliminado: sun.plugin.util.ProgressMonitorAdapter@bbe282
    plugin2manager.parentwindowDispose

  • Applet failed to load in Internet Explorer when using JRE 1.5 update 5

    I have downloaded JRE 1.5 Update 5 and checked the relevant checkbox in Internet Explorer Advanced tab to use JRE 1.5 for applets. Did the same in Java Control Panel. However none of the applets seem to load.
    For example I went to this site:
    http://java.com/en/download/help/testvm.xml
    The applet didn't load and I got the following error in my Sun Java Console :
    load: class JavaVersionDisplayApplet.class not found.
    java.lang.ClassNotFoundException: JavaVersionDisplayApplet.class
         at sun.applet.AppletClassLoader.findClass(Unknown Source)
         at java.lang.ClassLoader.loadClass(Unknown Source)
         at sun.applet.AppletClassLoader.loadClass(Unknown Source)
         at java.lang.ClassLoader.loadClass(Unknown Source)
         at sun.applet.AppletClassLoader.loadCode(Unknown Source)
         at sun.applet.AppletPanel.createApplet(Unknown Source)
         at sun.plugin.AppletViewer.createApplet(Unknown Source)
         at sun.applet.AppletPanel.runLoader(Unknown Source)
         at sun.applet.AppletPanel.run(Unknown Source)
         at java.lang.Thread.run(Unknown Source)
    Caused by: java.io.IOException: open HTTP connection failed.
         at sun.applet.AppletClassLoader.getBytes(Unknown Source)
         at sun.applet.AppletClassLoader.access$100(Unknown Source)
         at sun.applet.AppletClassLoader$1.run(Unknown Source)
         at java.security.AccessController.doPrivileged(Native Method)
         ... 10 more

    And it's the same behaviour in JRE 1.5 update 8 as well.

  • How to add checkboxes to frame

    So I have two classes in my package. I am having trouble adding the checkbox group to my frame. I got it to add to my applet but I can not figure out how to add it to my frame. Here is what I have so far. When I run this program it puts the checkboxes in my applet and not in my frame.
    this is my painter class:
    package pt;
    * <p>Title: </p>
    * <p>Description: </p>
    * <p>Copyright: Copyright (c) 2006</p>
    * <p>Company: </p>
    * @author unascribed
    * @version 1.0
    import java.applet.Applet;
    import java.awt.*;
    import java.awt.event.*;
    public class painter extends Applet {
    private int xValue=-10, yValue=-10;
    MyFrame x;
    Checkbox Red, Black, Magenta, Blue, Green, Yellow;
    CheckboxGroup cbg;
    public void init()
    x= new MyFrame("Christie's Window");
    x.show();
    x.resize(250,100);
    cbg = new CheckboxGroup();
           Red = new Checkbox("Red", cbg,true);
           Black = new Checkbox("Black", cbg,false);
           Magenta = new Checkbox("Magenta",cbg,false);
           Blue = new Checkbox("Blue", cbg, false);
           Green = new Checkbox("Green", cbg, false);
           Yellow = new Checkbox("Yellow", cbg, false);
           add(Red);
           add(Black);
           add(Magenta);
           add(Blue);
           add(Green);
           add(Yellow);
         addMouseMotionListener(new MotionHandler(this));
    public void paint(Graphics g)
    g.drawString("Drag the mouse to draw", 10, 20);
    g.fillOval(xValue, yValue, 4,4);
    //Override Component class update method to allow all ovals
    // to remain on the screen by not clearing the background
    public void update(Graphics g)   { paint(g); }
    // set the drawing coordinates and repaint
    public void setCoordinates(int x, int y)
      xValue = x;
      yValue = y;
      repaint();
    // Class to handle only mouse drag events for the Drag applet
    class MotionHandler extends MouseMotionAdapter {
      private painter dragger;
      public MotionHandler(painter d)  { dragger = d; }
      public void mouseDragged( MouseEvent e)
        { dragger.setCoordinates( e.getX(), e.getY() );   }
        } and here is MyFrame class:
    package pt;
    * <p>Title: </p>
    * <p>Description: </p>
    * <p>Copyright: Copyright (c) 2006</p>
    * <p>Company: </p>
    * @author unascribed
    * @version 1.0
    import java.applet.Applet;
    import java.awt.*;
    import java.awt.event.*;
    public class MyFrame extends Frame {
    MyFrame(String x){
       super(x);
        public boolean handleEvent(Event evtObj) {
          if(evtObj.id==Event.WINDOW_DESTROY) {
            hide();
            return true;
          return super.handleEvent(evtObj);
    }

    here's your conversion, with listeners to change the color
    //import java.applet.Applet;
    import java.awt.*;
    import java.awt.event.*;
    //public class painter extends Applet {
    class painter extends Frame {
    Color color = Color.RED;
    private int xValue=-10, yValue=-10;
    //MyFrame x;
    Checkbox Red, Black, Magenta, Blue, Green, Yellow;
    CheckboxGroup cbg;
    //public void init()
    public painter()
    //x= new MyFrame("Christie's Window");
    setTitle("Christie's Window");
    //x.show();
    //x.resize(250,100);
    setSize(600,400);
    setLocation(200,100);
    cbg = new CheckboxGroup();
           Red = new Checkbox("Red", cbg,true);
           Red.addItemListener(new ItemListener(){
            public void itemStateChanged(ItemEvent ie){
              if(Red.getState()) color = Color.RED;}});
           Black = new Checkbox("Black", cbg,false);
           Black.addItemListener(new ItemListener(){
            public void itemStateChanged(ItemEvent ie){
              if(Black.getState()) color = Color.BLACK;}});
           Magenta = new Checkbox("Magenta",cbg,false);
           Magenta.addItemListener(new ItemListener(){
            public void itemStateChanged(ItemEvent ie){
              if(Magenta.getState()) color = Color.MAGENTA;}});
           Blue = new Checkbox("Blue", cbg, false);
           Blue.addItemListener(new ItemListener(){
            public void itemStateChanged(ItemEvent ie){
              if(Blue.getState()) color = Color.BLUE;}});
           Green = new Checkbox("Green", cbg, false);
           Green.addItemListener(new ItemListener(){
            public void itemStateChanged(ItemEvent ie){
              if(Green.getState()) color = Color.GREEN;}});
           Yellow = new Checkbox("Yellow", cbg, false);
           Yellow.addItemListener(new ItemListener(){
            public void itemStateChanged(ItemEvent ie){
              if(Yellow.getState()) color = Color.YELLOW;}});
    Panel p = new Panel();
           p.add(Red);
           p.add(Black);
           p.add(Magenta);
           p.add(Blue);
           p.add(Green);
           p.add(Yellow);
    add(p,BorderLayout.NORTH);
         addMouseMotionListener(new MotionHandler(this));
    addWindowListener(new WindowAdapter(){
          public void windowClosing(WindowEvent we) { System.exit(0); }});
    public void paint(Graphics g)
    super.paint(g);
    g.setColor(color);
    g.drawString("Drag the mouse to draw", 10, 75);
    g.fillOval(xValue, yValue, 4,4);
    //Override Component class update method to allow all ovals
    // to remain on the screen by not clearing the background
    public void update(Graphics g)   { paint(g); }
    // set the drawing coordinates and repaint
    public void setCoordinates(int x, int y)
      xValue = x;
      yValue = y;
      repaint();
    // Class to handle only mouse drag events for the Drag applet
    class MotionHandler extends MouseMotionAdapter {
      private painter dragger;
      public MotionHandler(painter d)  { dragger = d; }
      public void mouseDragged( MouseEvent e)
        { dragger.setCoordinates( e.getX(), e.getY() );   }
      public static void main(String[] args){new painter().setVisible(true);}
    }

  • Some Java applets do not work after silent installation, solved by toggling "Enable Java content in the browser" - Why?

    We have about 1,800 workstations running Windows 7 (both 32-bit and 64-bit) running various versions of the Java JRE from 6 update 32 through 7 update 51.  Most are on 6 update 45.  We would like to standardize on Java 7 update 51 (32-bit) and get everyone updated to that version for security reasons.
    For the past two weeks, we have been having trouble with our installation pre-pilot.  What we are seeing is that our procedure successfully closes any open Internet Explorer windows and Java-related processes, uninstalls all old versions of the Java JRE, and then claims to have successfully installed Java 7 update 51.  The Java Control panel works.  We can even take Internet Explorer to Verify Java Version or Java Tester - What Version of Java Are You Running? and confirm that the Java applets on those sites are loading (though the latter only works after adding the site to the exceptions site list); however, when testers try to access our Kronos Workforce Central 6.3.10 system, the Java applets used by that system do not load.
    We have tried the following things, none of which worked:
    Clear Internet Explorer browser cache and cookies.
    Clear the local Java cache.
    Reboot the computer.
    Reset Internet Explorer settings, including personal settings.
    The one thing which does work is going into the Java Control Panel, going to the Security tab, unchecking "Enable Java content in the browser", pressing Apply, pressing OK on the pop-up window, checking the "Enable Java content in the browser" box again, pressing OK, pressing OK on the pop-up window, and then restarting Internet Explorer.  It is only after this point that all Java applets, including the ones used by Kronos Workforce Central 6.3.10, work.
    What I need to know is how I can automate the procedure of reinitializing the "Enable Java content in the browser" checkbox after installation or am I doing something wrong or missing a step in the automated installation that is causing this to happen?
    We are using Microsoft SCCM 2007 R3 to accomplish this upgrade, and everything is being run on the client machine using the SYSTEM account.  First, the PowerShell script "javaclean.ps1" is run, with part of the command-line process changing the PowerShell script execution policy to Bypass.  This script handles the closing of Java-dependent applications and Java processes and uninstalls old Java versions.
    javaclean.ps1:
    #Find all Java products excluding the auto updater which actually gets uninstalled when the main install is removed.
    write-host "Searching for all installed Java versions" -ForegroundColor Yellow
    [array]$javas=Get-WmiObject -query "select * from win32_Product where (Name like 'Java %' or Name like 'Java(TM)%' or Name like 'J2SE%') and Name <> 'Java Auto Updater'"
    if ($javas.count -gt 0)
        write-host "Java is already Installed" -ForegroundColor Yellow
        #Get all the Java processes and kill them. If java is running and the processes aren't killed then this script will invoke a sudden reboot.
        [array]$processes=Get-Process -Name "Java*" #-erroraction silentlycontinue
        $processes += Get-Process -Name "iexplore" #-erroraction silentlycontinue
        $processes += Get-Process -Name "firefox" #-erroraction silentlycontinue
        $processes += Get-Process -Name "chrome" #-erroraction silentlycontinue
        $processes += Get-Process -Name "jqs" #-erroraction silentlycontinue
        $processes += Get-Process -Name "jusched" #-erroraction silentlycontinue
        $processes += Get-Process -Name "jp2launcher" #-erroraction silentlycontinue
        if ($processes.Count -gt 0)
            foreach ($myprocess in $processes)
                $myprocess.kill()
        #Loop through the installed Java products.
        foreach($java in $javas){
            write-host "Uninstalling "$java.name -ForegroundColor Yellow
            $java.Uninstall()
    After this script is complete, SCCM calls a the VBS script "install.vbs" to perform the actual installation of Java JRE 7 update 51.
    install.vbs
    '* Script: Install JRE 7 routine
    '* Date:   3/14/14
    '* Author: [REDACTED]
    '* Rev:    1.0
    '* Notes: 
    '/// Common
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objWshShell = CreateObject("WScript.Shell")
    ' Get system architecture
    Dim colSys : Set colSys = GetObject("WinMGMTS://").ExecQuery("SELECT AddressWidth FROM Win32_Processor",, 48)
    Dim objSys
    For Each objSys In colSys
        If objSys.AddressWidth = 64 Then bolIs64Bit = True
    Next
    ' Get operating system
    Dim colOS : Set colOS = GetObject("WinMGMTS://").ExecQuery ("Select * from Win32_OperatingSystem",,48)
    Dim objOS
    For Each objOS In colOS
        If Left(objOS.caption, 20) = "Microsoft Windows 8 " Then
            bolIsWin8 = True
            WScript.Echo "win8"
        End If
        If Left(objOS.caption, 22) = "Microsoft Windows 8.1 " Then
            bolIsWin81 = True
            WScript.Echo "win81"
        End    If
    Next
    ' Set 32 bit program files directory
    If bolIs64Bit = True Then
        strPFILES = "Program Files (x86)"
        strSYSDIR = "SysWOW64"
        Else strPFILES = "Program Files"
        strSYSDIR = "System32"
    End If       
    ' Set windows directory
    strWIN = objWshShell.ExpandEnvironmentStrings("%windir%")
    ' Set the current directory
    strCurrentDir = objFSO.GetParentFolderName(Wscript.ScriptFullName)
    ' Set computer name
    strCompName = objWshShell.ExpandEnvironmentStrings("%computername%")
    '/// Main script
        '/// Install via .msi & capture exit code
        'intExitCode = objWshShell.Run("msiexec.exe /i """ & strCurrentDir & "\package.msi""" & " TRANSFORMS=""" & strCurrentDir & _
        '    "\transform.mst"" ALLUSERS=1 Reboot=ReallySuppress /qn", 8, True)
        'wscript.quit(intExitCode)
        '****RUN COMMANDS HERE****
        ' Create folder structure if it doesn't exist already   
        strFullPath = "c:\Windows\Sun\Java\Deployment" '
        ' How many levels are there in the path?
        nLevel = 0
        strParentPath = strFullPath
        Do Until strParentPath = ""
            strParentPath = objFSO.GetParentFolderName(strParentPath)
            nLevel = nLevel + 1
        Loop
        For iLevel = 1 To nLevel
            ' Figure out path for directory at level iLevel
            strParentPath = strFullPath
            For j = 1 To nLevel - iLevel
                strParentPath = objFSO.GetParentFolderName(strParentPath)
              Next
        ' Does this directory exist? If not, create it.
            If objFSO.FolderExists(strParentPath) = False Then
                Set newFolder = objFSO.CreateFolder(strParentPath)
            End If
        Next
        ' Kill running processes
        objWshShell.Run "taskkill /F /IM iexplore.exe", 8, True
        objWshShell.Run "taskkill /F /IM firefox.exe", 8, True
        objWshShell.Run "taskkill /F /IM chrome.exe", 8, True
        objWshShell.Run "taskkill /F /IM javaw.exe", 8, True
        objWshShell.Run "taskkill /F /IM java.exe", 8, True
        objWshShell.Run "taskkill /F /IM jqs.exe", 8, True
        objWshShell.Run "taskkill /F /IM jusched.exe", 8, True
        ' Copy deployment files
        objFSO.CopyFile strCurrentDir & "\deployment.config", "c:\Windows\Sun\Java\Deployment\", True
        objFSO.CopyFile strCurrentDir & "\deployment.properties", "c:\Windows\Sun\Java\Deployment\", True
        ' Disable UAC
    '    If bolIsWin8 Or bolIsWin81 = True Then
    '        objWshShell.Run "reg.exe ADD HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /v PromptOnSecureDesktop /t REG_DWORD /d 0 /f", 8, True
    '        objWshShell.Run "reg.exe ADD HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /v EnableLUA /t REG_DWORD /d 0 /f", 8, True
    '        objWshShell.Run "reg.exe ADD HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /v ConsentPromptBehaviorAdmin /t REG_DWORD /d 0 /f", 8, True
    '    End If
        ' Install application
        intExitCode = objWshShell.Run("msiexec.exe /i """ & strCurrentDir & "\jre1.7.0_51.msi"" IEXPLORER=1 AUTOUPDATECHECK=0 JAVAUPDATE=0 JU=0 WEB_JAVA=1 ALLUSERS=1 Reboot=ReallySuppress /qn", 8, True)
        ' Enable UAC
    '    If bolIsWin8 Or bolIsWin81 = True Then
    '        objWshShell.Run "reg.exe ADD HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /v PromptOnSecureDesktop /t REG_DWORD /d 1 /f", 8, True
    '        objWshShell.Run "reg.exe ADD HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /v EnableLUA /t REG_DWORD /d 1 /f", 8, True
    '        objWshShell.Run "reg.exe ADD HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /v ConsentPromptBehaviorAdmin /t REG_DWORD /d 5 /f", 8, True
    '    End If   
        wscript.quit(intExitCode)
        '/// Install via .exe on network
        'objWshShell.Run """" & strCurrentDir & "\Setup.exe"" -s -sms -f1""" & strCurrentDir & _
        '    "\setup.iss"" -f2""" & strWIN & "\Temp\Install-app.txt""", 8, True
        ' Need to turn off the open file security warning first
        Set objEnv = objWshShell.Environment("PROCESS")
        objEnv("SEE_MASK_NOZONECHECKS") = 1
    '    intExitCode = objWshShell.Run("""" & strCurrentDir & "\jre-7u45-windows-i586.exe"" /s /v""/norestart " & _
    '        "TRANSFORMS=""" & strCurrentDir & "\Tribe-jre7.mst""""", 8, True)
    '    WScript.Quit(intExitCode)
        '****RUN COMMANDS HERE****
        ' Then turn it back on
        objEnv.Remove("SEE_MASK_NOZONECHECKS")
    '/// Additional functions
    Help on this issue would be much appreciated!

    It turns out that this is actually a problem with Kronos Workforce Central.  We had the "site.java.plugin.CLSID.familyVersion" setting in that application set to "clsid:CAFEEFAC-0016-0000-FFFF-ABCDEFFEDCBA", which is the Java CLSID for Java 6.  After updating this value to "clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" (the Java universal CLSID), this problem did not occur upon the automatic upgrade of Java.
    We have both Java 6 and Java 7 in our environment, and did during our Kronos implementation, so I don't know why we were using the Java 6 CLSID in the first place.
    Case closed!

  • Signed applet works on pc  but can't print on mac! security issue!

    Hello
    I have an applet which works beautifully on the pc under ie, firefox, chrome and safari. Essentially - it uses the batik libraries to download an svg file and then print it.
    Problem is that firstly - no matter which operating system or browser the applet ALWAYS asks me if i want to give it access to the printer. The checkbox that says don't ask this again does not work except while the same applet is loaded. Subsequent loads make it reappear. So that one annoys me.
    But the big issue is that under the Mac OSX my applet will not print. It claims a SocketPermission issue for the localhost port 631 connect,resolve. Of course, before you ask, yes, the jar is signed , and yes i was asked on the mac if i trust this user. It is a self signed certificate by the way.
    I have no idea why the mac is not allowing my trusted app access to the printer when the other operating systems do. Is it perhaps that i am not somehow getting the AllPermission policy file read?
    I have no idea where to even put the java.policy.applet that eclipse generates so i also put it into my jar file. I can't find any knowledge of that file out there or where to deploy it but i keep seeing reference to java.policy. so i copied java.policy.applet and renamed it java.policy and also included that in my jar. the upshot of doing that? Nada. With or without those policy files in my jar it makes no difference.
    DocPrintJob tmpJob = tmpPrinter.createPrintJob();                    
    HashPrintRequestAttributeSet set = new HashPrintRequestAttributeSet();
    tmpJob.print(tmpDoc, set); // its this line that fails
    I am new to java development (well actually about 8 years abstained from it) and this is one of those prototypes that says we either will use java or we won't. Please help, its the final hurdle. If it doesn't work on the mac then all that effort getting it to work on the PC was wasted. I also need to understand how to stop the annoying access the printer dialog before i can go live.
    Cheers

    If it is in the wrong format it must probably still show up though, if your mac does detect it, go to disk utilities> choose the device from the left hand side > go to the "erase" tab and change format to "Mac OS extended (Journaled) then hit "erase".
    IMPRTANT! : this will erase ALL of the files on your external hard drive
    If this dosent work, make sure your external hard drive's USB port is compatibe with both USB 2.0 and 3.0 and also make sure your mac USB socket isnt damaged either.
    Hope this helped

  • File handling with applets

    I am trying to design am opinion poll applet in Java for my site. The poll consists of a CheckbokGroup and a "Submit" Button. On clicking "Submit" the proper percentage claculations are performed and written to an external file using byte streams. Now problem is that i get a security exception when the applet appempts to create the file. Please advice.
    Source Code
    import java.awt.*;
    import java.awt.event.*;
    import java.applet.*;
    import java.io.*;
    <applet code="Poll" width=144 height=500>
    </applet>
    public class Poll extends Applet implements ActionListener
    Checkbox cpp,java,assembly,vb,perl,asp;
    CheckboxGroup cbg;
    Label l1,l2,blank;
    Button submit;
    String q1="Which is your favourite";
    String q2="programming language?";
    boolean visible=true;
    public void init()
    setLayout(new GridLayout(9,1));
    l1=new Label(q1,Label.CENTER);
    l2=new Label(q2,Label.CENTER);
    blank=new Label("");
    cbg=new CheckboxGroup();
    cpp=new Checkbox("C/C++",cbg,false);
    java=new Checkbox("Java",cbg,false);
    assembly=new Checkbox("Assembly",cbg,false);
    vb=new Checkbox("Visual Basic",cbg,false);
    perl=new Checkbox("Perl",cbg,false);
    asp=new Checkbox("ASP",cbg,false);
    submit=new Button("Submit");
    add(l1);
    add(l2);
    add(cpp);
    add(java);
    add(assembly);
    add(vb);
    add(perl);
    add(asp);
    add(submit);
    submit.addActionListener(this);
    public void actionPerformed(ActionEvent ae)
    int index=-1;
    Checkbox temp=cbg.getSelectedCheckbox();
    if(temp==cpp) index=0;
    if(temp==java) index=1;
    if(temp==assembly) index=2;
    if(temp==vb) index=3;
    if(temp==perl) index=4;
    if(temp==asp) index=5;
    if(index!=-1)
    displayResults(index);
    void displayResults(int index)
    int size=7;
    byte buf[]=new byte[size];
    int pcent[]=new int[size];
    try
    InputStream fi=new FileInputStream("polldata.txt");
    fi.read(buf);
    fi.close();
    buf[index+1]++;
    buf[0]++;
    for(int i=0;i pcent[0]=buf*100/buf[0];
    try
    OutputStream fo=new FileOutputStream("polldata.txt");
    fo.write(buf);
    fo.close();
    }catch(FileNotFoundException fe)
    }catch(IOException ie)
    }catch(FileNotFoundException e)
    try
    for(int i=0;i<7;i++)
    buf[i]=0;
    OutputStream fi=new FileOutputStream("polldata.txt");
    fi.write(buf);
    fi.close();
    System.err.println("Here am I");
    //displayResults(index);
    }catch(FileNotFoundException ee)
    catch(IOException ee)
    }catch(IOException e)
    void graphResult(byte b[])
    //PLEASE IGNORE THE CODE IN THIS METHOD.
    //I STILL HAVE TO WRITE THE CODE FOR GRAPHICALLY
    //DIPLAYING THE RESULTS
    remove(l1);
    remove(l2);
    remove(cpp);
    remove(java);
    remove(assembly);
    remove(vb);
    remove(perl);
    remove(asp);
    remove(submit);
    submit.setLabel("O.K.");
    for(int i=0;i<8;i++)
    add(blank);
    add(submit);
    add(l1);
    add(l2);
    add(cpp);
    add(java);
    add(assembly);
    add(vb);
    add(perl);
    add(asp);
    add(submit);

    Are we talking about a local intranet site or a site on the web?
    If the answer is local, then it's a simple matter of mapping the drive.
    If the answer is the web, then you will need a server-side software (be it a servlet, cgi, asp, php, or whatever) to accomplish what you wanted to do.
    V.V.

Maybe you are looking for

  • List View Threshold and Relevant Documents

    I have a Sharepoint Site that contains several libraries.  Some with infopath forms and others with pdf's.  On the site's main page I had added the relevant documents web part.  The relevant documents web part is used frequently by certain users to a

  • Missing hard drive space after failed migration assistant transfer

    When I first got my 13" macbook pro (about a month ago), I attempted to use Migration Assistant to move my files from my old 15" MBP. After starting the transfer, my old MBP locked up (or so I thought) & I had to quit the process. When I looked to se

  • How to mapp logical repositories to physical ones

    hi, i ve created logical repository in miniSAP and know i want to know how to map it to physical repositories? waiting for reply regards, nasir

  • Download error, tab to retry..

    Γεα σας... συγχαρητήρια για το site σας!!..    έχω αγοράσει τραγούδια στο iTunes ,απο το iPad μου, και δεν κατεβαίνουν ... βγάζει  download error tab to retry ! αλλά στο iPhone μου κατεβαίνουν κανονικά .... έχω κάνει τα πάντα ... απο το να κάνω resto

  • Struts Action Download File

    Hi All I�m downloading a word file by action using the following java code: ByteArrayOutputStream writerBytes = new ByteArrayOutputStream(); response.setContentType("application/word"); response.setHeader("Content-disposition", "inline; filename=" +