java - Something is wrong with my timer gui panel -


I am making a timer to go with a Sudoku Grid IM and the code in bold spoken is making errors to me and I do not know why if someone can point out any mistake and provides a solution which would be helpful thanks. import javax.swing. *; Import java.awt. *; Import java.awt.event. *; Public class Timer Jepianel (private Jeelabl time display; private Jebtn Risetbtn; private Jebtn Startbtn; private Jebtn Stopbutn; public Timer () {final Timer; Startbutton = new Jebtn ( "Start Timer"); Stopbutn = new Jebtn ( "Stop Button "); Taimdisple = new Jeelabel (" ... waiting ... "); Risetbtn = new Jebtn (" reset timer "); this.add (resetButton); this.add (startButton); this. Add (stopButton); this.add (timeDisplay); Class TimerClass ActionListener's Function Wyn {int counter; public Taimrclas (Int counter) {this.counter = counter;} @ Override public void Akshnprrfed (ActionEvent TC) {counter ++;}} class Startbtntnakshn Akshnlistr (public void Akshnprrfed (Action Event e) {Int count = 0; TimeDisplay.setText ( "time has passed seconds:" + count); Taimrclas TC = new timer class (count); ** timer = new timer (1000, TC); Timerkstart (); **} }}}

you're using ta Emaclas variable as a local variable in an internal class, and it has not been declared as the final variable. You can do this, or declare variables at the class level.

Note, if you have any questions about errors in the future, post the error message.


Edit
Problem 2: You named this class timer ! When you try to use the swing timer it will be a name conflict. MyTimer .


E.g.,

  import javax.swing. *; Change some of your class names. Import java.awt. *; Import java.awt.event. *; Public Class Mattimer extends JPNail {Private JLabel Time Display; Personal pocket reset button; Private pocket startbutt; Private Jebton Stopbutton; Private Timer Timer; Public MyTimer () {startButton = New Pocket ("Start Timer"); Stopbutton = new pocket ("stop button"); TimeDisplay = new JLabel ("... is waiting ..."); Reset button = new pocket ("reset timer"); This.add (resetButton); This.add (startButton); This.add (stopButton); This.add (timeDisplay); } Private Class TimerClass Apply ActionListener {int counter; Public timer (int counter) {this.counter = counter; } @ Override Public Zero Action Perfid (ActionEvent TC) {Counter ++; }} Private class Startbtntnakshn Akshnlistr (public void Akshnprrfed (Akshnavent e) {Int count = 0; TimeDisplay.setText ( "Time has passed seconds:" + count); Taimrclas TC = new Timer class (count); timer = new Timer (1000, TC); timer.start ();}}}   

You also have problems with your counting variables because it is not well as timer's functionalist and button It could be an area of ​​the main program Ahia.

For further examples of functional timer, please refer to my answer.

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -