Never mind. I solved my issue. All I had to do was make frame a static public object.
Type: Posts; User: Shivam24
Never mind. I solved my issue. All I had to do was make frame a static public object.
My issue is that in my code, I create a new JFrame object called frame. In another method I want to close that frame. Any suggestions?
// Non-relevant code
private static class oddbutton...
all i needed to was restart the IDE. Thanks
I've written code to draw a rectangle. I'm pretty sure i did everything right. This is my code:
package hmm;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
I'm trying to display an oval but the oval doesn't show.
This is my code:
package guitut;
import javax.swing.*;
import java.awt.*;
public class GUItut {
what are the errors? forgive me for being a noob at java programming
When i try running my program i get this error:
java.lang.NoSuchMethodError: main
Exception in thread "main" Java Result: 1
This is my code:
package button_game;
import javax.swing.*; ...
im very sorry
Im sorry again.
I messed up and posted "while (randomInt != randomInt)"
it should be "while (number != randomInt)"
"!=" means does not equal and that's why your program stops. a variable can never...
Ok i see. I'm sorry i forgot to add a bracket so the while loop should look like this
while (randomInt != randomInt) {
if (number < randomInt)
{
c.print("The number you have guessed is too...
ur welcome : )
Try using a while loop instead of a for loop and change the position of your loop.
Also in your if statements have the user enter input.
It would look something like this
//your code
int...
Im not sure exactly what you meant by starting a new thread. Do you mean start it inside:
private static class A1 implements ActionListener{
public void actionPerformed(ActionEvent e){
...
sorry this is the error: method main in class button_game.Button_Game cannot be applied to given types;
required: java.lang.String[]
found: no arguments
reason: actual and formal argument...
I am trying to start a new thread to call main() but i can't understand the error.
package button_game;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class...
never mind they un-align when i post the code
By whole thing, I mean that I want the whole program to run again and again as long as you keep clicking Button A1 and it to exit when you click Button B1.
Here is my revised code:
I think i got...
I want to loop the whole program so that if you click on button A, the whole thing restarts and the buttons shift positions. If you click button B, the program exits.
Alright i think this is what...
please someone respond!
im trying to create a game where there are two buttons and you have to click the one with the even number to continue or else you lose. I need help on how to make it loop. I am a noob at java...