8/31/2023 0 Comments Illegal start of expression![]() So, I figured that using the addActionListener() method would solve the problem, but I just get two error messages instead. Could anyone help me figure this out I've been trying to retype it again, and look for curly brackets, but I can't fix it. Now, I don't get any errors excluding the addActionListener() methods from the code, but when I press the "Start Timer" button, it does nothing. I finally finished about 3/4ths of the coding for this actor and when I hit compile, it keeps saying that I have an illegal start of expression in a line of code (I'll provide it at the bottom). Ok, I have two errors now, both regarding addActionListener(). ![]() Also at this point it would make more sense to just use a Label and change its text (and don't even bother with writing your own paint method). ![]() That is, your paint() method always paints exactly the same thing right now, and rather than painting in the main applet, you'll probably want to create a separate widget to draw the text in. I don't see where you're adding the buttons.Īlso, is this a standalone app or an applet? I made my example a standalone app for convenience, but if yours is going to be an applet, then you shouldn't use the main() method, since it won't be called when the applet is viewed in the appletviewer or the browser.īutton starttimer = new Button("Start Timer") īutton stoptimer = new Button("Stop Timer") ĪctionListener taskPerformer = new ActionListener() You'll also need separate action listeners for the buttons (they don't do anything yet) and you'll probably want to paint differently.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |