Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This seems to be the start of your problems...</p> <pre><code>if (result == 2) { TimerTask tasknew = new TimerScheduleFixedRateDelay(); Timer timer = new Timer(); // scheduling the task at fixed rate delay timer.scheduleAtFixedRate(tasknew, 1000, 1000); @Override } public void run() { </code></pre> <p>There's no such class called <code>TimerScheduleFixedRateDelay</code>, <code>Timer</code> doesn't have a default constructor, you don't seem to have declared <code>tasknew</code> and I have no idea why <code>@Override</code> appears here...</p> <p>Let's start by commenting those out for the moment</p> <pre><code>if (result == 2) { //TimerTask tasknew = new TimerScheduleFixedRateDelay(); //Timer timer = new Timer(); // scheduling the task at fixed rate delay //timer.scheduleAtFixedRate(tasknew, 1000, 1000); //@Override } public void run() { </code></pre> <p>The next problem is you're missing a closing bracket...</p> <pre><code>if (result == 2) { ... } // Something is amiss here... public void run() { </code></pre> <p>It should look more like...</p> <pre><code> if (result == 2) { ... } } public void run() { </code></pre> <p>Next...</p> <pre><code>public void run() { msg = "It's too late, we're all dead!"; msg = "..."; msg = "Look at what you did, there's nothing left."; msg = "Looks like we have to start over again..."; window.setVisible(false); main(null); } display.setText (msg); </code></pre> <p><code>msg</code> is undefined, <code>window</code> is undefined and <code>main</code> is undefined and <code>display.setText</code> is being callout outside of a method context, which is illegal...</p> <pre><code>public void run() { String msg = "It's too late, we're all dead!"; msg = "..."; msg = "Look at what you did, there's nothing left."; msg = "Looks like we have to start over again..."; display.setText (msg); //window.setVisible(false); //main(null); } </code></pre> <p>It's easy enough to fix the <code>msg</code>, not sure about the <code>display.setText</code>, but since it's taking <code>msg</code>, I assume it belongs in the <code>run</code> method and I have no idea about <code>window</code> and <code>main</code> still needs to be resolved...</p> <p>Which leads us onto...</p> <pre><code>} private String makeWord(char move) { String word = ""; switch (move) { case 'R': word = "rock"; break; case 'P': word = "paper"; break; case 'S': word = "scissors"; break; case 'N': word = "nuke"; break; } return word; } public static void main(String[] args) //Here { RpsNuke window = new RpsNuke(); window.setBounds(300, 300, 400, 140); window.setDefaultCloseOperation(EXIT_ON_CLOSE); window.setVisible(true); } } //And here </code></pre> <p>Oh, I think I found where our missing brace went to....This means that everything below the <code>}</code> the first brace in the above code is actually being defined outside of the <code>class</code>, which, for the context of this question, is illegal...</p> <p>So, lets comment that out...</p> <pre><code>//} private String makeWord(char move) { String word = ""; switch (move) { case 'R': word = "rock"; break; case 'P': word = "paper"; break; case 'S': word = "scissors"; break; case 'N': word = "nuke"; break; } return word; } public static void main(String[] args) //Here { RpsNuke window = new RpsNuke(); window.setBounds(300, 300, 400, 140); window.setDefaultCloseOperation(EXIT_ON_CLOSE); window.setVisible(true); } } //And here </code></pre> <p>There, things look a "little" better...I also think I found <code>window</code>, but it's being defined in <code>main</code>...not very helpful ;)</p> <p>Based on look at your code, I think you should avoid <code>java.util.Timer</code> and use <code>javax.swing.Timer</code> instead, this will prevent you from updating the UI from outside the content of the Event Dispatching Thread which is just another cup of worms you would probably wish to avoid...</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload