So, I figured that using the addActionListener() method would solve the problem, but I just get two error messages instead. 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. ![]() Ok, I have two errors now, both regarding addActionListener(). 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. 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). 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). 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. 1.7K Training / Learning / Certification.165.3K Java EE (Java Enterprise Edition).7.9K Oracle Database Express Edition (XE).3.8K Java and JavaScript in the Database.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |