Java prog#8. How to close previous jframe on the opening of new jframe in netbeans
Вставка
- Опубліковано 19 вер 2024
- it's simple just follow the below code:
First import these two files below
import java.awt.event.*;
import java.awt.*;
then write the method for close
public void close(){
WindowEvent winClosingEvent = new WindowEvent(this,WindowEvent.WINDOW_CLOSING);
Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(winClosingEvent);
}
★★★Top Online Courses From ProgrammingKnowledge ★★★
Python Programming Course ➡️ bit.ly/2vsuMaS ⚫️ bit.ly/2GOaeQB
Java Programming Course ➡️ bit.ly/2GEfQMf ⚫️ bit.ly/2Vvjy4a
Bash Shell Scripting Course ➡️ bit.ly/2DBVF0C ⚫️ bit.ly/2UM06vF
Linux Command Line Tutorials ➡️ bit.ly/2IXuil0 ⚫️ bit.ly/2IXukt8
C Programming Course ➡️ bit.ly/2GQCiD1 ⚫️ bit.ly/2ZGN6ej
C++ Programming Course ➡️ bit.ly/2V4oEVJ ⚫️ bit.ly/2XMvqMs
PHP Programming Course ➡️ bit.ly/2XP71WH ⚫️ bit.ly/2vs3od6
Android Development Course ➡️ bit.ly/2UHih5H ⚫️ bit.ly/2IMhVci
C# Programming Course ➡️ bit.ly/2Vr7HEl ⚫️ bit.ly/2W6RXTU
JavaFx Programming Course ➡️ bit.ly/2XMvZWA ⚫️ bit.ly/2V2CoAi
NodeJs Programming Course ➡️ bit.ly/2GPg7gA ⚫️ bit.ly/2GQYTQ2
Jenkins Course For Developers and DevOps ➡️ bit.ly/2Wd4l4W ⚫️ bit.ly/2J1B1ug
Scala Programming Tutorial Course ➡️ bit.ly/2PysyA4 ⚫️ bit.ly/2PCaVj2
Bootstrap Responsive Web Design Tutorial ➡️ bit.ly/2DFQ2yC ⚫️ bit.ly/2VoJWwH
MongoDB Tutorial Course ➡️ bit.ly/2LaCJfP ⚫️ bit.ly/2WaI7Ap
QT C++ GUI Tutorial For Beginners ➡️ bit.ly/2vwqHSZ
★★★ Online Courses to learn ★★★
Get 2 FREE Months of Unlimited Classes from skillshare - skillshare.eqc...
Data Science - bit.ly/2lD9h5L | bit.ly/2lI8wIl
Machine Learning - bit.ly/2WGGQpb | bit.ly/2GghLXX
Artificial Intelligence - bit.ly/2lYqaYx | bit.ly/2NmaPya
MERN Stack E-Degree Program - bit.ly/2kx2NFe | bit.ly/2lWj4no
DevOps E-degree - bit.ly/2k1PwUQ | bit.ly/2k8Ypfy
Data Analytics with R - bit.ly/2lBKqz8 | bit.ly/2lAjos3
AWS Certification Training - bit.ly/2kmLtTu | bit.ly/2lAkQL1
Projects in Java - bit.ly/2kzn25d | bit.ly/2lBMffs
Machine Learning With TensorFlow - bit.ly/2m1z3AF | bit.ly/2lBMhnA
Angular 8 - Complete Essential Guide - bit.ly/2lYvYRP
Kotlin Android Development Masterclass - bit.ly/2GcblsI
Learn iOS Programming Building Advance Projects - bit.ly/2kyX7ue
★★★ Follow ★★★
My Website - www.codebind.com
DISCLAIMER: This video and description contains affiliate links, which means that if you click on one of the product links, I’ll receive a small commission. This help support the channel and allows us to continue to make videos like this. Thank you for the support!
------------------------------------------------------------------------
Java: How do I close a JFrame while opening another one?
How to close a jframe without closing the main program
Close one JFrame without closing another?
passing data from one jframe to another
How to disable main JFrame when open new JFrame
Opening new JFrame replaces current window
NetBeans Forums - Opening new Jframe in existing window
iit Learn java netbeans
java tutorial netbeans
'Thanks men! Been solving this from night to morning, then I found this video. Noob here by the way so I'm so glad I found this. Thank you.
very helpful, every word of you was clear and every step is slow and clear that we can follow step by step
may ALLAH bless you
i think i learn more watching your videon than at school jajaja thnks for your tutorials my friend, regards from mexico :)
This video just helped me take a MAJOR step in getting my Computer Science degree. Thank to so much, bro! JUST what I needed.
You're the true king
Tnxs Baddy you just solved the biggest problem I was facing!!!
nice work, waiting for the next video ;)
we can also put cammand dispose(); insted of window.closing
Hello friend, excuse the trouble first of all these video tutorials are helpful. As you can disable the close button of the window JFrame. In this video the Close method to close the JFrame not be disabled when you disable the close button of the window.
Greetings Friends ...
I normally use hide method to close a frame, but I think it is not the right way to actually close a frame because that frame is just invisible but not actually close. Any better idea?
I think better and easier would be:
public void close() {
this.setVisible(false);
this.dispose();
}
dispose doesnt work when you have a static class
thanks
i used this and it worked
Thanks. It really woks.
Jacek Dąbek Its also work for me
thanks bro it's actually easier to handle this way
Mine is saying, cannot fins symbol, and it is pointing to the Toolkit.getDefaultToolkit line. Any ideas?
Thank you. It was very helpful :)
hi thanks for showing me easier code for opening a new jForm I also made a video for that so everybody can learn that and I mansion ur name in the video no 37..........
this videos helped me with the first form but more the second form links to a third form then this same function closes everything. How do you make it work when there are more than 2 levels of forms?
use f.hide(); inside the action of the login
Thank you !!!
Thank yoy,
You should be attention to change the state of fram in the runtime also
Dear
This code instead of closing the current window, it closes the whole application.
I used instead this line:
this.setVisible(false);
You're wrong it doesn't
You. Are. Awesome! Thank you very much that helped alot.
How to not closing main jframe when closing new. I mean that, when we run the program, there is a button on that jframe, when I click that button new jframe will open, and when I close this new jframe the old one also will be closed. but my wish is that not closing the old jframe until I close it myself.
Thank you very much ❤❤
Thank you so much!
How about InternalFrame ?
ur great dude :)
Click link to Download Source code - www.codebind.com/java-tutorials/whole-java-netbeans-gui-project-source-code/
Thanks it did Helped me....!!!
how to go back to main jframe after hiding it and moved to another frame
for example
mainframe.setvisible(false);
goto"second frame";
how to set mainframe to true visible via a back button in the second frame
I got it but still the same thing
i am not getting the previous window closed at all.
how about the code for moving from one panel to another pls
Thnk you so so much thnka man
can use in Eclipse ?
you can do it with dispose method!
what programm do you use ?
Thanks. Quite useful.
Thank you! You solved my error!
Some smart people have a tendency to over complicate things Ahmed.
very helpful
thanks a lot....
mantap pak abu
I tried but is not working. I have imported 'import java.awt.event.WindowEvent;'. This is what i have in my method. " public void close(){
WindowEvent winClosingEvent=new WindowEvent(this,WindowEvent.WINDOW_CLOSING);
ToolKit.getDefaultToolKit().getSystemEventQueue().postEvent(winClosingEvent);
}"
Is complaining of no suitable constructor found for windows Event.
Could you help me? Thank you
simply use this.dispose() on the method of the button.
You don't have to write this much code.
Lol you saved me thank you
Yeah I have. I only use dispose() . Hey thanks
Helpful (:
Thank you man
but Employeeid name surname age????? this form ??
Helpful tutorials
we can also use : this hide();
It also work too but i am not sure it just hide it or close it too
does someone know that???
this.close();
close it's already defined in java
thanks and great post...
Can you please move the cursor when you're explaining on something in the next video. I can't read. haha. I noticed that on most of your videos.
Thanks
Thank you verry Much
Thanks this video bro :)
u can just type
this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
in the contructer :D
Thanks mate.
what is .WINDOW_CLOSING);??? i am not getting it
It is a DATA_MEMBER, which comes under class WindowEvent.
thank you! very useful >O
how to close previous window when using framename.main(argv);
ty bro !!
If you use eclipse,in your actionPerformed method all you need to write is yourFrameName.hide(); so for me that was frmLogin.hide();
Seeker but if your class already extends JFrame, you should be able to call hide(); or use this.hide(); still in the actionPerformed method and before initialising the new frame.
Thanks Bro !
thank u so much !!!
or just add "dispose();" before opening another frame.
I did the public void close exactly like the video:
public void close(){
WindowEvent winClosingEvent = new WindowEvent(this,WindowEvent.WINDOW_CLOSING);
Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(WinClosingEvent);
}
But it says it can't find symbol: class WindowEvent
Can someone please explain why?
write package "import java.awt.*;" & "import java.awt.event.*;". Because WindowEvent comes under these packages.
use this.hide();
Thank you!
Thank you
Thanks!!!
Or you can use
ThisFrame.Dispose();
:D
haha i wonder why a person who already knows would be here. thanks though
YOU ARE AN ANGEL
Why not just use this.setVisible(false);
is there another method to close only a frame because your method is too long :V
didnt work :/
How to connect with you? do you have facebook, skype or any?
thanks,...
Don't put it in the public frame() {... } constructor. Put it outside and it will work:
e.g.
public class MainFrame extends JFrame {
public MainFrame() {
....
}
public void closeFrame() {
WindowEvent winClosingEvent =......
}
}
Being u asked this 3 months ago I'm probably wasting time answering..u must hav found the solution in these 3 months?...
7:00
verty esay methode tankes
it closes out both windows
just set the first frame property to dispose after this process shown in video
the easiest would be this.setVisible(false);
:) God bless you (y)
Whatsup
Pls stop being annoying my big brain cannot follow ur methodolgical proceedings with the Java Graphical User Interface code so pls halp and extand my mind
btw. it is easier to just write dispose(); before the code for opening a new jForm...for example dispose ();
new jForm().setVisible(true);
xD
;)
at Login.java (or whatever you named it):
if(rs.next()){
JOptionPane.showMessageDialog(null, "Username and Password is correct");
rs.close();
pst.close();
patient_info s = new patient_info();
s.setVisible(true);
this.dispose(); //use this line of code which makes this entire video pointless
}
Whatsapp
thanx
How to connect with you? do you have facebook, skype or any?
Thanks
thanks