Re: Main Loop porblm

Posted by Silvi... on 18. May 2015

On 05/18/2015 03:50 PM, Michael wrote:




Simple window application with JSlider. Thereis main loop "while(true)" and "if(show==true)" statement, inside it we done "show=true" and "System.out.println("+")".



At the Slider Listener we change variable show to true.



When program starts we can see one plus. Its Ok. When mooving slider variable "show" changed to true like we want, but IF statement in main loop does not work. What is the solution? Sorry for the simple question :)



  while(true)
{
if(show == true)
{
show = false;
System.out.println("+");
}
}


class SliderListener implements ChangeListener {
public void stateChanged(ChangeEvent e) {
JSlider source = (JSlider)e.getSource();
if (!source.getValueIsAdjusting()) {
int fps = (int)source.getValue();



         Loop.show = true;

System.out.println((int)source.getValue());

}
}


}




From the limited amount of information you provide it is impossible for
us to determine what you are trying to achieve. But whatever you want to
do you have given enough details for us to conclude you are doing it wrong.



Please provide more information and we might be able to help.


13. May 2015: Re: Puzzler: Fun with Streams. by Jeff ...

13. May 2015: Call for Papers: World Congress on Engineering and Computer Science WCECS 2015 by iaeng...

12. May 2015: Re: how does a marker interface give specific instruction to jvm(java internals) by Jeff ...

12. May 2015: Re: How to programatically limit the number of threads in a java by Marce...

12. May 2015: Re: JScrollPane not scrolling smoothly on fast computer by Knute...

12. May 2015: Re: how does a marker interface give specific instruction to jvm(java internals) by Jeff ...

12. May 2015: Puzzler: Fun with Streams. by Danie...

12. May 2015: Re: how does a marker interface give specific instruction to jvm(java internals) by Rober...

12. May 2015: Re: how does a marker interface give specific instruction to jvm(java internals) by ram a...

12. May 2015: Re: Use URL for HTTPS request using Proxy by Silvi...

12. May 2015: Use URL for HTTPS request using Proxy by Silvi...

12. May 2015: Re: what are the senarios when we should override equals and hashcode by Lew l...

12. May 2015: JNI Wrapper for Delphi and FreePascal version 2.8 by Ramin...

12. May 2015: Re: How to programatically limit the number of threads in a java by Eric ...

12. May 2015: Re: how does a marker interface give specific instruction to jvm(java internals) by Ajay ...

12. May 2015: How to programatically limit the number of threads in a java by Ajay ...

12. May 2015: Re: API vc MVC by Joerg...

12. May 2015: Need Java Developers/Tech Leads/Architects at Reston, VA (Permanent) by ashok...

11. May 2015: API vc MVC by Leona...

11. May 2015: Re: best and worst sorting algorithm for 1 to 10, 000 and then 10, 000 + elements by Eric ...

11. May 2015: Re: best and worst sorting algorithm for 1 to 10, 000 and then 10, 000 + elements by Gene ...

11. May 2015: Re: JScrollPane not scrolling smoothly on fast computer by e d p...

11. May 2015: Re: best and worst sorting algorithm for 1 to 10, 000 and then 10, 000 + elements by v_bor...

10. May 2015: Re: Animations with jTextPane by Knute...

10. May 2015: Re: how does a marker interface give specific instruction to jvm(java internals) by Joerg...

10. May 2015: Re: Animations with jTextPane by H L a...

10. May 2015: Re: Animations with jTextPane by Knute...

10. May 2015: Re: Animations with jTextPane by Knute...

10. May 2015: Re: Animations with jTextPane by H L a...

10. May 2015: Re: Animations with jTextPane by Knute...

10. May 2015: Re: how does a marker interface give specific instruction to jvm(java internals) by Jeff ...

10. May 2015: how does a marker interface give specific instruction to jvm(java internals) by Ajay ...

10. May 2015: Animations with jTextPane by H L a...

09. May 2015: JScrollPane not scrolling smoothly on fast computer by Knute...

09. May 2015: PEZZO DI MERDA BASTARDO DAVIDE SERRA DI ALGEBRIS INVESTMENTS - TWITTER, HA RICEVUTO INSIDER SULLE POPOLARI DAL MEGALAVA SOLDI MAFIOSI PIER LUIGI BOSCHI DI BANCA ETRURIA! SON TUTTI NAZISTI, TIPO NOTO VERME PAOLO BARRAI DI WMO, CHE SI FINGON DEL PD X.. by CARME...

09. May 2015: Re: best and worst sorting algorithm for 1 to 10, 000 and then 10, 000 + elements by Eric ...

08. May 2015: Re: best and worst sorting algorithm for 1 to 10, 000 and then 10, 000 + elements by ram a...

08. May 2015: How to read the Java tutorial offline? by ram a...

08. May 2015: Re: best and worst sorting algorithm for 1 to 10,000 and then 10,000 + elements by Marti...

08. May 2015: Re: How to read the Java tutorial offline? by Jeff ...

06. May 2015: Re: Why Islam is the true religion of God. by Danci...

06. May 2015: CCC: CIUCCIA CAZZI DI CAVALLO PAOLO BARRAI DI CRIMINALI WMO E BSI ITALIA SRL, UNA VOLTA CACCIATO (E FATTO CONDANNARE AL CARCERE) DA CITIBANK, PRIMA DI SPENNARE POLLI NEL WEB, FECE FILM PEDOPORNOMOSESSUALI! E CON CAVALLI! CIUCCIANDO CAZZI EQUINI E ... by CHE S...

05. May 2015: Why Islam is the true religion of God. by BV BV...

04. May 2015: Re: best and worst sorting algorithm for 1 to 10, 000 and then 10, 000 + elements by Marce...

04. May 2015: Re: best and worst sorting algorithm for 1 to 10, 000 and then 10, 000 + elements by Eric ...

04. May 2015: Re: best and worst sorting algorithm for 1 to 10, 000 and then 10, 000 + elements by Eric ...

04. May 2015: best and worst sorting algorithm for 1 to 10, 000 and then 10, 000 + elements by Ajay ...

04. May 2015: Re: What is your favorite WC++IETJ? by ram a...

03. May 2015: Re: What is your favorite WC++IETJ? by Joshu...

03. May 2015: Re: what are the senarios when we should override equals and hashcode by Arne ...

03. May 2015: Re: what are the senarios when we should override equals and hashcode by ram a...

02. May 2015: what are the senarios when we should override equals and hashcode by Ajay ...

02. May 2015: imported maven project can't be recognized as java in eclipse by Ajay ...

02. May 2015: Re: Good example of EJB interface for CRUD operations by pavel...

01. May 2015: Very urgent requirement || Technical Lead - .Net @ Golden Valley, MN by Vasan...

01. May 2015: Re: If java doesn't support operator overloading, how does String + concatenation work by v_bor...

30. Apr 2015: Re: If java doesn't support operator overloading, how does String + concatenation work by Rober...

30. Apr 2015: Re: What is your favorite WC++IETJ? by Robbi...

30. Apr 2015: Re: What is your favorite WC++IETJ? by Sebas...

30. Apr 2015: Re: What is your favorite WC++IETJ? by ram a...

30. Apr 2015: Re: What is your favorite WC++IETJ? by ram a...

30. Apr 2015: Re: What is your favorite WC++IETJ? by Jerry...

30. Apr 2015: What is your favorite WC++IETJ? by ram a...

30. Apr 2015: Re: If java doesn't support operator overloading, how does String + concatenation work by Eric ...

30. Apr 2015: Re: What is your favorite WC++IETJ? by Eric ...

30. Apr 2015: Re: Easy exhaustive search with Java 8 Streams by j4n b...

30. Apr 2015: If java doesn't support operator overloading, how does String + concatenation work by Ajay ...

29. Apr 2015: Re: Easy exhaustive search with Java 8 Streams by Sebas...

29. Apr 2015: Re: Easy exhaustive search with Java 8 Streams by Sebas...

29. Apr 2015: Re: Survey Request for Research related to Software Engineering and Social Media by Jerry...

29. Apr 2015: Survey Request for Research related to Software Engineering and Social Media by Augus...

29. Apr 2015: Re: Cannot seem to lock HashMap by pww19...

28. Apr 2015: Re: Easy exhaustive search with Java 8 Streams by ram a...

28. Apr 2015: Re: Easy exhaustive search with Java 8 Streams by Jan B...

27. Apr 2015: Re: Good example of EJB interface for CRUD operations by Rober...

27. Apr 2015: Easy exhaustive search with Java 8 Streams by Sebas...

27. Apr 2015: Re: Good example of EJB interface for CRUD operations by pavel...

27. Apr 2015: Good example of EJB interface for CRUD operations by pavel...

25. Apr 2015: Re: enum, what is it good for? by Rober...

24. Apr 2015: Re: enum, what is it good for? by Sebas...

24. Apr 2015: Re: enum, what is it good for? by Rober...

22. Apr 2015: Javascript advance by sheik...

22. Apr 2015: What is Armstrong number? Learn about Armstrong Number by sheik...

22. Apr 2015: Re: FileChooser on 2K Displays by j4n b...

22. Apr 2015: FileChooser on 2K Displays by j4n b...

22. Apr 2015: Re: how to hide and show cursor in JTextField? by Eric ...

22. Apr 2015: Re: how to hide and show cursor in JTextField? by karth...

21. Apr 2015: Re: enum, what is it good for? by Kevin...

21. Apr 2015: Re: runnable jar by Arne ...

21. Apr 2015: Re: C++ hash function -> Java by pww19...

21. Apr 2015: Re: Abuse of AssertionError? by Thoma...

21. Apr 2015: Re: Abuse of AssertionError? by j4n b...

21. Apr 2015: runnable jar by cebi ...

21. Apr 2015: Re: Abuse of AssertionError? by Jerry...

21. Apr 2015: Re: Abuse of AssertionError? by Eric ...

21. Apr 2015: Re: Abuse of AssertionError? by Eric ...

21. Apr 2015: Re: Abuse of AssertionError? by Jerry...

21. Apr 2015: Abuse of AssertionError? by Eric ...

21. Apr 2015: Re: enum, what is it good for? by Marce...

21. Apr 2015: Re: What could be improved about the assert statement by Eric ...