i want to close it with an jbutton
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
i want to close it with an jbutton
If you want advice, answer the questions you were asked.
If you want help, post what you have tried and explain why it is not satisfactory to you.
i need help with to make the Jbutton = new Jbutton("EXIT"); i want to make the jbutton to close the jframe when its running so i dont have to click at the top for closing it
i have tried to add the system.dispose();
for see if its closing if you click the exit button but i want to make that button close the jframe when its running
is this more easier for you to understand?
i found out the solution i added this
setVisible(false);
super.dispose();
in the actionlistener but thanks for helping out
--- Update ---
but the last thing i need to find out is how i can open an new jframe with an jbutton while the first jframe is running
--- Update ---
but when i click at every button i made it closes automatic at all i just want to make the exit button to close the jframe
--- Update ---
how do i make an jbutton to open a new jframe while the first jframe is running
how can i makie an jbutton to open a new jframe while the first jframe is running
Glad you got it working the way you want.
See post number 19 in this thread for the answer to this question...
It sounds to me like you have a problem filtering your events.
--- Update ---
You do not need to start a new thread with the same question.
Especially in the case that your question was answered in this thread twice.
Threads merged
yup im a newbeginner so im having problem with filtering events
--- Update ---
i want to make the jbutton button = new jbutton("Start Spaceball"); to open a new jframe but if i add
button.addActionListener(this);
and this.add(button); and when i open the jframe and click start spaceball it closes beacuse i added this under
@Override
public void actionPerformed(ActionEvent e) {
this.setTitle("EXITING");
setVisible(false);
super.dispose();
it closes the start spaceball button beacuse i added the actionlistener to the jbutton and i dont want to let that happen if click it. i want it to open a new jframe while the first one is running thats the problem
i hope this explains more of that i need help to
Use an action command to help filter. If you are using 7 or later you can switch on the String
can i make one called addactionlistener(string) ?? can you type the code how to do it im using java 7 in the eclipse
--- Update ---
can you write the code ??? so i can see a little more about it?
how can i make my start spaceball jbutton to open a new jframe
with the actionlistener??
Please do not create another thread with the same question. This is your third try.
You can refer to the answer given in post #19. If you do not understand it, ask a question.
how can i make an jbutton to open a new jframe while the first one is running i want to create a new window so it openes the game when you click at start game button
What have you tried? Where are you stuck? Where is your SSCCE?
Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!
jps above asked you to stop creating new threads, and yet you do it again. Consider this a warning - do so again and you leave the moderating staff no other choice to take further action. I have merged your threads with this one.
Given you have yet to follow the advice given, or even elaborate on your problem, I'm not sure what sort of help you expect.
omg im a newbeginner i want the freaking JButton button = new JButton("Start Spaceball") i want that button to open a new jframe/window when the first one is running since the first jframe is running with the buttons on and i want to make the button i said to open a new jframe
i cant do that in actionlistener since it add's det closing at the exit button and if i click spaceball it closes the program since i added button.addActionlistener and that makes the buttons close since i added frame.dispose() under the actionperformed/ActionListener if you dont understand i dont have any more stuff to explain since that is all i need help with
but anyways man i have figured the both solution to get it work now i an jbutton opening a frame and a jbutton closing the frame
I am happy you figured it out and got it working.
Please post the final solution for future readers and mark the thread as solved if all is well
You could use frame.setVisible(false); There's probably a 'right' way to actually close it though
Window.setVisible(boolean) will make the window hide or show but not close.