pyro Δημοσ. 23 Νοεμβρίου 2002 Δημοσ. 23 Νοεμβρίου 2002 kalhmera paides! lipwn, na mpw me th mia sto 0ema: "Download Robot.class into your SD directory. Construct a Java applet RApplet.java that has two buttons labelled "STEP" and "TURN" respectively, a TextField length 20, labelled "location", that is not editable and an object of class Robot. Follow the same approach as Morelli in constructing code. Build it by progressively adding parts. Your applet's init() method should (amongst other things) construct a new Robot object using the constructor public Robot(int x, int y, int face); where x and y give the co-ordinates of the starting position of the Robot object and face is one of the named constants NORTH, EAST, SOUTH, WEST (in the Robot class). When the "STEP" button is pressed the applet should invoke the void step() method on the Robot object. When the "TURN" button is pressed the applet should invoke the void turn() method on the Robot object. In either case the applet then invokes the String tell() method on the Robot object and display the returned String in the "location" TextField. As a variant of the above, modify the applet by replacing the TextField by a TextArea and write each String returned by the tell() method on a new line in that TextArea." loipwn, arxisa etsi: <pre><font class="small">code:</font><hr> public class RApplet extends java.applet.Applet { /** Initialization method that will be called after the applet is loaded * into the browser. */ public void init () { Robot r; r = new Robot("HAL"); Step = new Button("Step"); /mia erwthsh edw, to actionlistener prepei Turn = mew Button("Turn"); /nte kai kala na exei diaforetiko onoma Step.addActionListener(step); /ean einai se panw apo dyo efarmoges? Turn.addActionListener(turn); add(Step); add(Turn); } public void actionPerformed (ActionEvent s) { (Step.getlabel().equals("Step")); step.setLabel("going..."); } public void actionPerformed (ActionEvent t) { (Turn.getlabel().equals("Turn")); turn.setLabel("a round!"); } } </pre><hr> twra, se ola ta actionperformed mou bgazei cannot resolve symbol! sto turn = new Button mou leei oti prepei na balw ; sto new! ti ginete re paides? help! :crazy:
Γηρυόνης Δημοσ. 23 Νοεμβρίου 2002 Δημοσ. 23 Νοεμβρίου 2002 Κατ' αρχάς αυτό Turn = mew Button("Turn"); πρέπει να είναι Turn = new Button("Turn"); To actionListener δεν πρέπει να έχει διαφορετικό όνομα. Για το cannot resolve symbol είσαι σίγουρος ότι έχεις εισάγει (import) την ActionEvent κλάση;
pyro Δημοσ. 23 Νοεμβρίου 2002 Μέλος Δημοσ. 23 Νοεμβρίου 2002 oops! to actioneven pws to eisagw? thanks
pyro Δημοσ. 23 Νοεμβρίου 2002 Μέλος Δημοσ. 23 Νοεμβρίου 2002 (dhladi kanw import ActionListener alla to actionlistener pws to ftiaxnw?)
Γηρυόνης Δημοσ. 23 Νοεμβρίου 2002 Δημοσ. 23 Νοεμβρίου 2002 Καταχώρησε το μήνυμα λάθους που σου βγάζει.
pyro Δημοσ. 23 Νοεμβρίου 2002 Μέλος Δημοσ. 23 Νοεμβρίου 2002 <pre><font class="small">code:</font><hr> RApplet.java [12:1] package Actionevent does not exist import Actionevent.*; ^ RApplet.java [26:1] cannot resolve symbol symbol : class ActionEvent location: class RApplet public void actionPerformed (ActionEvent s) ^ RApplet.java [31:1] cannot resolve symbol symbol : class ActionEvent location: class RApplet public void actionPerformed (ActionEvent t) ^ RApplet.java [18:1] cannot resolve symbol symbol : class Robot location: class RApplet Robot r; ^ RApplet.java [19:1] cannot resolve symbol symbol : class Robot location: class RApplet r = new Robot("HAL"); ^ RApplet.java [20:1] cannot resolve symbol symbol : variable Step location: class RApplet Step = new Button("Step"); ^ RApplet.java [20:1] cannot resolve symbol symbol : class Button location: class RApplet Step = new Button("Step"); ^ RApplet.java [21:1] cannot resolve symbol symbol : variable Turn location: class RApplet Turn = new Button("Turn"); ^ RApplet.java [21:1] cannot resolve symbol symbol : class Button location: class RApplet Turn = new Button("Turn"); ^ RApplet.java [22:1] cannot resolve symbol symbol : variable step location: class RApplet Step.addActionListener(step); ^ RApplet.java [22:1] cannot resolve symbol symbol : variable Step location: class RApplet Step.addActionListener(step); ^ RApplet.java [23:1] cannot resolve symbol symbol : variable turn location: class RApplet Turn.addActionListener(turn); ^ RApplet.java [23:1] cannot resolve symbol symbol : variable Turn location: class RApplet Turn.addActionListener(turn); ^ RApplet.java [24:1] cannot resolve symbol symbol : variable Step location: class RApplet add(Step); ^ RApplet.java [25:1] cannot resolve symbol symbol : variable Turn location: class RApplet add(Turn); } ^ RApplet.java [28:1] cannot resolve symbol symbol : variable Step location: class RApplet (Step.getlabel().equals("Step")); ^ RApplet.java [29:1] cannot resolve symbol symbol : variable step location: class RApplet step.setLabel("going..."); ^ RApplet.java [33:1] cannot resolve symbol symbol : variable Turn location: class RApplet (Turn.getlabel().equals("Turn")); ^ RApplet.java [34:1] cannot resolve symbol symbol : variable turn location: class RApplet turn.setLabel("a round!"); ^ 19 errors Errors compiling init. </pre><hr> basika ti 0elw na kanw: na exw 2 koumpia to Step kai Turn, otan pathsw ena na bgazei: NORTH, EAST, SOUTH, WEST kai analoga ama pathsa to Turn apla na gurizei kai ama pataw to step na phgenei...
Γηρυόνης Δημοσ. 23 Νοεμβρίου 2002 Δημοσ. 23 Νοεμβρίου 2002 Κάνε import java.awt.*; Επίσης πρέπει να δηλώσεις και τη μεταβλητή Step. Button Step = null; έξω από την init() μέθοδο.
pyro Δημοσ. 23 Νοεμβρίου 2002 Μέλος Δημοσ. 23 Νοεμβρίου 2002 euxaristw polly gia thn olh boh0eia, pana dw ti mporw na kanw...
apoc Δημοσ. 23 Νοεμβρίου 2002 Δημοσ. 23 Νοεμβρίου 2002 Προσεχε λιγο τα varuables η Java ειναι super case sensitive μια γραφεις Step απο κατω step. Επισης γραφε proper if στα ActionPerformed και ασε τις μαγκιες για μετα! Και το Step (οπως ειπε ο Γυρηονης) και το Turn εκτος απο την init το declaration .
pyro Δημοσ. 24 Νοεμβρίου 2002 Μέλος Δημοσ. 24 Νοεμβρίου 2002 loipwn: <pre><font class="small">code:</font><hr> /* * RApplet.java * * Created on 23 Νοέμβριος 2002, 3:03 πμ */ /** * * @author pyro * @version */ import java.awt.*; public class RApplet extends java.applet.Applet { /** Initialization method that will be called after the applet is loaded * into the browser. */ Button Step = null; public void actionPerformed (ActionEvent) { if (Step.getlabel().equals("Step")); then (Step.setlaveb().equals("moving.."); } public void actionPerformed (ActionEvent) { if (Turn.getlabel().equals("Turn")); then (Step.setlabel().equals("around")); } public void init () { Robot r; r = new Robot("HAL"); Step = new Button("Step"); Turn = new Button("Turn"); Step.addActionListener(step); Turn.addActionListener(turn); add(Step); add(Turn); } } </pre><hr> WoW MONO 4 errors! <pre><font class="small">code:</font><hr> RApplet.java [18:1] <identifier> expected public void actionPerformed (ActionEvent) ^ RApplet.java [38:1] ')' expected } ^ RApplet.java [18:1] cannot resolve symbol symbol : class ActionEvent location: class RApplet public void actionPerformed (ActionEvent) ^ RApplet.java [18:1] missing method body, or declare abstract public void actionPerformed (ActionEvent) ^ 4 errors Errors compiling class RApplet. </pre><hr> RApplet.java [38:1] ')' expected } sygnwmh, pwses fores 0elei na kleisw???
Γηρυόνης Δημοσ. 24 Νοεμβρίου 2002 Δημοσ. 24 Νοεμβρίου 2002 Ρε πύρο πάρε ένα βιβλίο Java και διάβασε ή έστω ψάξε λίγο. Αυτό είναι λάθος: <pre><font class="small">code:</font><hr> if (Turn.getlabel().equals("Turn")); then (Step.setlabel().equals("around")); </pre><hr> Το σωστό αφήνεται ως άσκηση στον αναγνώστη.
pyro Δημοσ. 24 Νοεμβρίου 2002 Μέλος Δημοσ. 24 Νοεμβρίου 2002 opa, sorry, ekana la0os sto code apo to biblio! <pre><font class="small">code:</font><hr> public void actionPerformed (ActionEvent) { if (Step.getlabel().equals("Step")); Step.setLabel("movig..."); else Step.seLabel("Step"); } public void actionPerformed (ActionEvent) { if (Turn.getlabel().equals("Turn")); Turn.setLabel("around!"); else Turn.seLabel("Turn"); } </pre><hr> alla kai pali <pre><font class="small">code:</font><hr> RApplet.java [18:1] <identifier> expected public void actionPerformed (ActionEvent) ^ RApplet.java [42:1] ')' expected } ^ RApplet.java [18:1] cannot resolve symbol symbol : class ActionEvent location: class RApplet public void actionPerformed (ActionEvent) ^ RApplet.java [18:1] missing method body, or declare abstract public void actionPerformed (ActionEvent) ^ 4 errors Errors compiling actionPerformed. </pre><hr> ahhhhhh loipwn, 0a to janarxoisw apo thn arxh, 0a to kanw apla na dumhourgei to robot, meta 0a tou balw to onomatou, kai meta 0a dw ti ginete me ta kompia... euxaristw polly pantos
Γηρυόνης Δημοσ. 24 Νοεμβρίου 2002 Δημοσ. 24 Νοεμβρίου 2002 Αυτό <pre><font class="small">code:</font><hr> if (Step.getlabel().equals("Step")); Step.setLabel("movig..."); else Step.seLabel("Step"); </pre><hr> γράφεται ως <pre><font class="small">code:</font><hr> if (Step.getlabel().equals("Step")) Step.setLabel("movig..."); else Step.seLabel("Step"); </pre><hr> επίσης κάνε import java.awt.event.*;
pyro Δημοσ. 24 Νοεμβρίου 2002 Μέλος Δημοσ. 24 Νοεμβρίου 2002 baresa ton toixo apo ta neura mou kai ekana mia trypa...den jerw ti skata toixos einai alla sigoura tsimento den einai... olo errors mou bgazei, taxw paizei, oute ena gamhmeno app pou na patas dyo gamhmena koumpakia den mporw na ftiajw??? sixtiri pia, mou ti dinei!!!!!!! /bangs head on the wall
daimonas Δημοσ. 25 Νοεμβρίου 2002 Δημοσ. 25 Νοεμβρίου 2002 Ελα ρε χαλάρωσε...αμα τα κάνεις τα κουμπάκια απλά και όχι γα####να ίσως είναι πιο εύκολο...:)
Προτεινόμενες αναρτήσεις
Αρχειοθετημένο
Αυτό το θέμα έχει αρχειοθετηθεί και είναι κλειστό για περαιτέρω απαντήσεις.