Тёмный

Java prog#8. How to close previous jframe on the opening of new jframe in netbeans 

ProgrammingKnowledge
Подписаться 1,8 млн
Просмотров 163 тыс.
50% 1

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.eqcm.net/r1KEj
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

Опубликовано:

 

29 апр 2012

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 114   
@luigimarideleon6093
@luigimarideleon6093 8 лет назад
'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.
@ridaayubch2814
@ridaayubch2814 7 лет назад
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
@ProgrammingKnowledge
@ProgrammingKnowledge 8 лет назад
Click link to Download Source code - www.codebind.com/java-tutorials/whole-java-netbeans-gui-project-source-code/
@pinkicito0w
@pinkicito0w 11 лет назад
i think i learn more watching your videon than at school jajaja thnks for your tutorials my friend, regards from mexico :)
@lishaneticha8663
@lishaneticha8663 9 лет назад
Tnxs Baddy you just solved the biggest problem I was facing!!!
@brandomarebole329
@brandomarebole329 5 лет назад
This video just helped me take a MAJOR step in getting my Computer Science degree. Thank to so much, bro! JUST what I needed.
@Hydraxon3200
@Hydraxon3200 12 лет назад
nice work, waiting for the next video ;)
@mtxx80
@mtxx80 7 лет назад
I think better and easier would be: public void close() { this.setVisible(false); this.dispose(); }
@aryastark1833
@aryastark1833 7 лет назад
dispose doesnt work when you have a static class
@serahganjawala
@serahganjawala 7 лет назад
thanks i used this and it worked
@user-ml9xs8kc4q
@user-ml9xs8kc4q 7 лет назад
Thanks. It really woks.
@faizrasulanwar8458
@faizrasulanwar8458 7 лет назад
Jacek Dąbek Its also work for me
@Aestridd
@Aestridd 7 лет назад
thanks bro it's actually easier to handle this way
@channsothun9431
@channsothun9431 9 лет назад
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?
@Mhtwy
@Mhtwy 12 лет назад
You. Are. Awesome! Thank you very much that helped alot.
@putri4957
@putri4957 5 лет назад
Thank you! You solved my error!
@Sanjay54251
@Sanjay54251 8 лет назад
we can also put cammand dispose(); insted of window.closing
@faizrasulanwar8458
@faizrasulanwar8458 7 лет назад
Helpful (: Thank you man
@justintheoreo
@justintheoreo 6 лет назад
Mine is saying, cannot fins symbol, and it is pointing to the Toolkit.getDefaultToolkit line. Any ideas?
@amalpfranglin
@amalpfranglin 2 года назад
Thank you. It was very helpful :)
@Lusches77
@Lusches77 10 лет назад
what programm do you use ?
@Swiftkillah1300
@Swiftkillah1300 11 лет назад
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?
@waqarjamali
@waqarjamali 7 лет назад
use f.hide(); inside the action of the login
@omkomawar
@omkomawar 11 лет назад
Thanks it did Helped me....!!!
@philipakpan5898
@philipakpan5898 7 лет назад
Thanks. Quite useful.
@raip0d
@raip0d 3 года назад
You're the true king
@TheErdemgencoglu
@TheErdemgencoglu 10 лет назад
Thanks this video bro :)
@ProgrammingKnowledge
@ProgrammingKnowledge 12 лет назад
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..........
@nitishkumar-zh2wx
@nitishkumar-zh2wx 5 лет назад
very helpful thanks a lot....
@AboMSGL
@AboMSGL 8 лет назад
Thank yoy, You should be attention to change the state of fram in the runtime also
@MehdiBouzidi
@MehdiBouzidi 10 лет назад
Thank you verry Much
@goralAdrian
@goralAdrian 6 лет назад
Thanks mate.
@niranjanchakankar4428
@niranjanchakankar4428 8 лет назад
thanks and great post...
@srishtigupta361
@srishtigupta361 7 лет назад
Helpful tutorials
@trunghieunguyen7153
@trunghieunguyen7153 8 лет назад
thank u so much !!!
@crisalide98
@crisalide98 8 лет назад
Thanks!!!
@kanananonim3132
@kanananonim3132 11 лет назад
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.
@jerry04SAVED
@jerry04SAVED 11 лет назад
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 ...
@fathiafraznaaz-zahra1453
@fathiafraznaaz-zahra1453 9 лет назад
thank you! very useful >O
@shell3371
@shell3371 Год назад
Thank you so much!
@V_Bhatia
@V_Bhatia 9 месяцев назад
Thank you very much ❤❤
@joeyczo5008
@joeyczo5008 3 года назад
Thank you !!!
@jimleoromines8114
@jimleoromines8114 7 лет назад
How about InternalFrame ?
@lu1sner193
@lu1sner193 11 лет назад
Thanks Bro !
@razoR2k
@razoR2k 12 лет назад
this.close(); close it's already defined in java
@luisfernandofragosocarranz1526
@luisfernandofragosocarranz1526 3 года назад
ur great dude :)
@dekbd2
@dekbd2 10 лет назад
can use in Eclipse ?
@khaledsale7
@khaledsale7 9 лет назад
u can just type this.setDefaultCloseOperation(DISPOSE_ON_CLOSE); in the contructer :D
@zahidshabbir2499
@zahidshabbir2499 10 лет назад
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???
@sriramkuwaitful
@sriramkuwaitful 8 лет назад
I got it but still the same thing i am not getting the previous window closed at all.
@kenhgiaitriviet9013
@kenhgiaitriviet9013 10 лет назад
you can do it with dispose method!
@natasuah
@natasuah 10 лет назад
Yeah I have. I only use dispose() . Hey thanks
@WaleedMdAlHasanOmer
@WaleedMdAlHasanOmer 10 лет назад
Dear This code instead of closing the current window, it closes the whole application. I used instead this line: this.setVisible(false);
@MaxSandberg
@MaxSandberg 9 лет назад
You're wrong it doesn't
@hamzasiddiq8179
@hamzasiddiq8179 4 года назад
Thnk you so so much thnka man
@natasuah
@natasuah 11 лет назад
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
@riskinovasaputra4018
@riskinovasaputra4018 8 лет назад
Thank you
@abhishekjilla6782
@abhishekjilla6782 9 лет назад
thanx
@toeksh
@toeksh 11 лет назад
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
@charlesndlovu6350
@charlesndlovu6350 7 лет назад
how about the code for moving from one panel to another pls
@riadfaical
@riadfaical 11 лет назад
ty bro !!
@RecoverIman01
@RecoverIman01 3 года назад
Thanks
@lifeoftomi_
@lifeoftomi_ 9 лет назад
If you use eclipse,in your actionPerformed method all you need to write is yourFrameName.hide(); so for me that was frmLogin.hide();
@lifeoftomi_
@lifeoftomi_ 9 лет назад
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.
@anamikaahmed4887
@anamikaahmed4887 7 лет назад
simply use this.dispose() on the method of the button. You don't have to write this much code.
@RenXenpai
@RenXenpai Год назад
Lol you saved me thank you
@iondhai6074
@iondhai6074 3 года назад
mantap pak abu
@manishpaul_
@manishpaul_ 7 лет назад
or just add "dispose();" before opening another frame.
@Bluemangrup
@Bluemangrup 7 лет назад
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?
@sureshnaame6982
@sureshnaame6982 7 лет назад
write package "import java.awt.*;" & "import java.awt.event.*;". Because WindowEvent comes under these packages.
@waqarjamali
@waqarjamali 7 лет назад
use this.hide();
@Bluemangrup
@Bluemangrup 7 лет назад
Thank you!
@markjason2
@markjason2 9 лет назад
Or you can use ThisFrame.Dispose(); :D
@sanskarsingh9538
@sanskarsingh9538 6 лет назад
haha i wonder why a person who already knows would be here. thanks though
@joanasflute
@joanasflute 5 лет назад
YOU ARE AN ANGEL
@MonoarBinahmed
@MonoarBinahmed 6 лет назад
but Employeeid name surname age????? this form ??
@deepakkumar-pk4kt
@deepakkumar-pk4kt 8 лет назад
thanks,...
@winlenglean4224
@winlenglean4224 8 лет назад
thanks
@ruzainiamer1032
@ruzainiamer1032 8 лет назад
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.
@Nousa460
@Nousa460 11 лет назад
:) God bless you (y)
@sriramkuwaitful
@sriramkuwaitful 8 лет назад
what is .WINDOW_CLOS­ING);??? i am not getting it
@sureshnaame6982
@sureshnaame6982 7 лет назад
It is a DATA_MEMBER, which comes under class WindowEvent.
@fernandohood5542
@fernandohood5542 4 года назад
Some smart people have a tendency to over complicate things Ahmed.
@mukulbadhan5336
@mukulbadhan5336 11 лет назад
how to close previous window when using framename.main(argv);
@SuperAlphabetagama
@SuperAlphabetagama 10 лет назад
Why not just use this.setVisible(false);
@kanananonim3132
@kanananonim3132 11 лет назад
How to connect with you? do you have facebook, skype or any?
@harveybarcelona7252
@harveybarcelona7252 7 лет назад
is there another method to close only a frame because your method is too long :V
@loooooooooool77
@loooooooooool77 11 лет назад
didnt work :/
@Shadrech
@Shadrech 10 лет назад
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?...
@lighttech7750
@lighttech7750 5 лет назад
verty esay methode tankes
@feero9680
@feero9680 3 года назад
7:00
@XC3rocks
@XC3rocks 7 лет назад
it closes out both windows
@bbd9106
@bbd9106 6 лет назад
just set the first frame property to dispose after this process shown in video
@Hydraxon3200
@Hydraxon3200 12 лет назад
btw. it is easier to just write dispose(); before the code for opening a new jForm...for example dispose (); new jForm().setVisible(true); xD ;)
@EMINEMisnr1
@EMINEMisnr1 11 лет назад
the easiest would be this.setVisible(false);
@jeanrodrigues6249
@jeanrodrigues6249 2 года назад
Whatsup
@Tomahoop
@Tomahoop 6 лет назад
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 }
@jeanrodrigues6249
@jeanrodrigues6249 2 года назад
Whatsapp
@fifatemple4781
@fifatemple4781 5 лет назад
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
@ridhokurniawan8899
@ridhokurniawan8899 10 лет назад
Thanks
@kanananonim3132
@kanananonim3132 11 лет назад
How to connect with you? do you have facebook, skype or any?
Далее
Learn JSON in 10 Minutes
12:00
Просмотров 3,1 млн
Java prog#26.How to print JTable in Java netbeans
11:41
Learn Kotlin in 12 Minutes
12:01
Просмотров 311 тыс.