Newsgroup: it.comp.java
Titolo: Problema conversione in JAVA2

allora, ragazzi, innanzitutto salve a tutti il mio problema è che devo
convertire questo pezzo di applet dalla versione 1.1 alla 1.3 ma ho dei
problemi ...
aiutatemi per favore:
public class GraphAlgorithm extends java.applet.Applet {
    GraphCanvas graphcanvas = new GraphCanvas(this);
    Options options = new Options(this);
    Documentation documentation = new Documentation();
    public void init() {
 setLayout(new BorderLayout(10, 10));
 add("Center", graphcanvas);
 add("North", documentation);
 add("East", options);
    }
    public Insets insets() {
 return new Insets(10, 10, 10, 10);
    }
    public void lock() {
 graphcanvas.lock();
 options.lock();
    }
    public void unlock() {
 graphcanvas.unlock();
 options.unlock();
    }
    public static void main(String arg[]){
        GraphAlgorithm g = new GraphAlgorithm();
 Frame frame = new Frame("Dijkstra");
        g.init();
        frame.add("Center", g);
        frame.resize(800,600);
        frame.show();
        frame.resize(800,600);
    }
}
class Options extends Panel {
// set of options at the right of the screen
    Button b1 = new Button("clear");
    Button b2 = new Button("run");
    Button b3 = new Button("step");
    Button b4 = new Button("reset");
    Button b5 = new Button("example");
    Button b6 = new Button("exit");
    GraphAlgorithm parent;
    boolean Locked=false;
    Options(GraphAlgorithm myparent) {
 parent = myparent;
 setLayout(new GridLayout(6, 1, 0, 10));
 add(b1);
 add(b2);
 add(b3);
 add(b4);
 add(b5);
 add(b6);
    }
    public boolean action(Event evt, Object arg) {
 if (evt.target instanceof Button) {
   if (((String)arg).equals("step")) {
      if (!Locked) {
         b3.setLabel("next step");
         parent.graphcanvas.stepalg();
      }
      else parent.documentation.doctext.showline("locked");
   }
   if (((String)arg).equals("next step"))
      parent.graphcanvas.nextstep();
   if (((String)arg).equals("reset"))
      parent.graphcanvas.reset();
      b3.setLabel("step");
      parent.documentation.doctext.showline("all items");
   }
   if (((String)arg).equals("clear"))
      parent.graphcanvas.clear();
      b3.setLabel("step");
      parent.documentation.doctext.showline("all items");
   }
   if (((String)arg).equals("run")) {
      if (!Locked)
         parent.graphcanvas.runalg();
      else parent.documentation.doctext.showline("locked");
   }
   if (((String)arg).equals("example")) {
      if (!Locked)
         parent.graphcanvas.showexample();
      else parent.documentation.doctext.showline("locked");
   }
   if (((String)arg).equals("exit"))
      System.exit(0);
   }
 }
 return true;
    }
    public void lock() {
 Locked=true;
    }
    public void unlock() {
 Locked=false;
 b3.setLabel("step");
    }
}
class Documentation extends Panel {
// Documentation on top of the screen
    DocOptions docopt = new DocOptions(this);
    DocText doctext = new DocText();
    Documentation() {
 setLayout(new BorderLayout(10, 10));
 add("West", docopt);
 add("Center", doctext);
    }
}
class DocOptions extends Panel {
    Choice doc = new Choice();
    Documentation parent;
    DocOptions(Documentation myparent) {
 setLayout(new GridLayout(2, 1, 5, 0));
 parent = myparent;
 add(new Label("DOCUMENTATION:"));
 doc.addItem("draw nodes");
 doc.addItem("remove nodes");
 doc.addItem("move nodes");
 doc.addItem("the startnode");
 doc.addItem("draw arrows");
 doc.addItem("change weights");
 doc.addItem("remove arrows");
 doc.addItem("clear / reset");
 doc.addItem("run algorithm");
 doc.addItem("step through");
 doc.addItem("example");
 doc.addItem("exit");
 doc.addItem("all items");
 add(doc);
    }
    public boolean action(Event evt, Object arg) {
        if (evt.target instanceof Choice) {
     String str=new String(doc.getSelectedItem());
     parent.doctext.showline(str);
        }
        return true;
    }
}
class DocText extends TextArea {
    ....
    ....
    ....
}
    DocText() {
 super(5, 2);
 setText(doc);
    }
    public void showline(String str) {
 if (str.equals("draw nodes"))              setText(drawnodes);
 else if (str.equals("remove nodes"))       setText(rmvnodes);
 else if (str.equals("move nodes"))         setText(mvnodes);
 else if (str.equals("the startnode"))      setText(startnode);
 else if (str.equals("draw arrows"))        setText(drawarrows);
 else if (str.equals("change weights"))     setText(weight);
 else if (str.equals("remove arrows"))      setText(rmvarrows);
 else if (str.equals("clear / reset"))      setText(clrreset);
 else if (str.equals("run algorithm"))      setText(runalg);
 else if (str.equals("step through"))       setText(step);
 else if (str.equals("example"))            setText(example);
        else if (str.equals("exit"))               setText(exitbutton);
 else if (str.equals("all items"))          setText(doc);
 else if (str.equals("toclose"))            setText(toclose);
 else if (str.equals("done"))               setText(done);
 else if (str.equals("locked"))             setText(locked);
 else if (str.equals("maxnodes"))           setText(maxnodes);
        else if (str.equals("none"))               setText(none);
        else if (str.equals("some"))               setText(some);
 else setText(str);
    }
}
PER FAVORE NON CI RIESCO PROPRIO, GRAZIE IN ANTICIPO ...

 wrote in message
news:ZWmz7.7334$V75.1...@news1.tin.it...


 API e li c'e' scritto come devi modificare il codice.
giusto, il problema è che devo usare Swing al posto di AWT ... piccola
dimenticanza :))



[mega-snip]
|
| Bruno Bossola
| A Java Software Engineer :-)
| 
http://bbruno.fasturl.it
|
| 
http://members.xoom.it/bbruno
| 
http://digilander.iol.it/bbossola
|

     Bruno.
Ho solo bisogno di usare JApplet e di sostituire i Panel con i JPanel ...
tutto qui ...se puoi aiutarmi ...

Ad esempio, perchè una cosa del genere on funzia??
public class GraphAlgorithm extends JApplet {
 GraphCanvas graphcanvas = new GraphCanvas(this);        /* estende Canvas
*/
 Options options = new Options(this);                                /*
estende JPanel */
 Documentation documentation = new Documentation();    /* estende JPanel */
    public void init() {
     setLayout(new BorderLayout(10, 10));
     Container contentPane = getContentPane();
       contentPane.add(graphcanvas, BorderLayout.CENTER);
      contentPane.add(options, BorderLayout.EAST);
      contentPane.add(documentation, BorderLayout.NORTH);
    }
    public static void main(String arg[]){
      GraphAlgorithm g = new GraphAlgorithm();
      JFrame frame = new JFrame("Dijkstra");
      g.init();
         frame.add("Center", g);
         frame.setSize(800,600);
         frame.show();
    }
}
Non mi disegna niente e anzi mi dice che non trova la classe GraphAlgorithm
... anche se i path sono giusti ...