// ********************************************** public class Main { public static void main(String[] args) { LaunchPage launchPage = new LaunchPage(); } } // ********************************************** import java.awt.event.*; import javax.swing.*; public class LaunchPage implements ActionListener{ JFrame frame = new JFrame(); JButton myButton = new JButton("New Window"); LaunchPage(){ myButton.setBounds(100,160,200,40); myButton.setFocusable(false); myButton.addActionListener(this); frame.add(myButton); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(420,420); frame.setLayout(null); frame.setVisible(true); } @Override public void actionPerformed(ActionEvent e) { if(e.getSource()==myButton) { frame.dispose(); NewWindow myWindow = new NewWindow(); } } } // ********************************************** import java.awt.*; import javax.swing.*; public class NewWindow { JFrame frame = new JFrame(); JLabel label = new JLabel("Hello!"); NewWindow(){ label.setBounds(0,0,100,50); label.setFont(new Font(null,Font.PLAIN,25)); frame.add(label); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(420,420); frame.setLayout(null); frame.setVisible(true); } }
@valencefootball9740
3 жыл бұрын
2 420'S?!?
@joyceasante8292
Жыл бұрын
Practicing... public class Main{ public static void main(String[ ]args){ LaunchPage launchPage = new LaunchPage(); } } ************************ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JButton; import javax.swing.JFrame; public class LaunchPage implements ActionListener { JFrame frame = new JFrame (); JButton button = new JButton ("New Window"); LaunchPage () { button.setBounds (100, 160, 200, 40); button.setFocusable (false); button.addActionListener (this); frame.add(button); frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE); frame.setSize (400, 400); frame.setLayout (null); frame.setVisible (true); } @Override public void actionPerformed (ActionEvent e) { if(e.getSource()==button){ frame.dispose(); NewWindow window = new NewWindow(); } } } ****************** import java.awt.*; import javax.swing.JFrame; import javax.swing.JLabel; public class NewWindow { JFrame frame = new JFrame (); JLabel label = new JLabel ("Salut!"); NewWindow () { label.setBounds (0, 0, 100, 50); label.setFont (new Font ("Times New Roman", Font.PLAIN,12)); frame.add(label); frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE); frame.setSize (400, 400); frame.setLayout (null); frame.setVisible (true); } }
@pavelkvasnicka6856
Жыл бұрын
This is the best Java tutorial for beginners, so you can learn Java and English in one hit. Please keep going! I vote for Java advance tutorial. Thanks a lot Bro
@speklex779
11 ай бұрын
Amazing video
@byThaxar
2 жыл бұрын
OMG thank you so much this help me a lot i tried to open a window with other events but didn't work, I see your video a work inmediatly
@Joy-mf6xo
2 жыл бұрын
You don't know how much it helped!
@funwithalbi2425
2 жыл бұрын
i’m a student and i’m learning from my college that is called Bro Code and it’s free
@dhiyanabdurazack5257
Жыл бұрын
Same
@charliesellsaenz1092
3 жыл бұрын
You just saved my proyect!! I LOVE YOU!!
@BroCodez
3 жыл бұрын
awesome!! thanks for watching Charlie!
@angelcastineira2561
4 жыл бұрын
another great video! i'm about to be up to date with your series!
@kyledarylltabuzo4568
Жыл бұрын
Finally at tutorial that explains what happens in the process
@abdulkudduskosimov4443
Жыл бұрын
Thank you very much bro, you helped me out of a problem with this tutorial.
@mariorossi1456
4 жыл бұрын
Thanks, I'm working on a project, you are helping me a lot
@minerliton2481
9 ай бұрын
I love how you say "button"!
@enow0049
2 жыл бұрын
Thanks man exactly the solution to my problem! I am glad i subbed to you!
@schroedenger
2 жыл бұрын
Just found your channel through this video, with all the great content how could I not subscribe?
@amadujalloh4700
4 жыл бұрын
Hey Bro Code, please do videos on constructors(their types), and objects in Java
@BroCodez
4 жыл бұрын
I think I might have a video on what you're looking for here: kzitem.info/news/bejne/q2qdnJ2rhKGgkmU
@All_In_786
3 жыл бұрын
Heey Bro , you are awesome , your way of teaching is very nice.. I smashed the like button, that my phone screen is gonna crack..
@forte2265
2 жыл бұрын
this helped me a ton, thanks!
@darokimagandor1671
6 ай бұрын
This is interesting and it helps, thank you
@prod.xavgvst
Жыл бұрын
You earned yourself a sub... thank you so much broski
@dexspits7869
Жыл бұрын
I have an assignment where the first window needs to be closed after pressing okay button on the second window, like the second window needs to have a button that makes the first window close after it being pressed, im going crazy
@kabirahmed9626
3 жыл бұрын
Bro you helped me a LOT . Thanks man
@desmondchiemezieugwuanyi8197
2 жыл бұрын
Bro, thanks a lot for your wonderful tutorials
@Ashish_singh_dev
3 жыл бұрын
Awesome tut bro looking forward for more tuts like this 😍
@Roxy377
2 жыл бұрын
our lord and savoir is here
@antoinealam6531
21 күн бұрын
You made me love coding again
@grace_upon_linda
2 жыл бұрын
Thanks man, it worked!
@stanislavdimitrov1643
Жыл бұрын
Very nice video, I like it very much. 40 degrees Celsius, drink beer 😃😃😃
@jacksongetangita9061
3 жыл бұрын
the tutorial is very help full... how can you make the button to link with another website like "click here to access Gmail account?"
@jadasarchives
2 жыл бұрын
this was soo helpful, thank you!
@ibrahimylmaz8378
2 жыл бұрын
thanks bro
@rabomeister
Жыл бұрын
wow that frame.setSize parameters must be really coincidence :P
@stephanieezat-panah7750
2 жыл бұрын
As always, another great video. Question please: I do not want to dispose of the main front window, but I would like to limit the pop up to one instance. how? I intend to have several buttons on the front page, each to it's own window. I am thinking something like modal would be the answer. how?
@BroCodez
2 жыл бұрын
Hi Stephanie! I'm a little rusty at Java. I haven't used the language in a few years. If I'm understanding right, a possible solution would be to create a separate class for each unique window that you would need. Then on the main window, have separate buttons that would call the constructor of each unique class. Then disable buttons if needed. Hopefully I understood the question correctly.
@keerthanavemula24
Жыл бұрын
If you want to click the button only once then use the - button. setEnabled(false) in the actionPerformed method, then it grays out the button after performing the task once
@stranger9951
Жыл бұрын
@@BroCodez What language have you been using recently?
@martontoth3578
2 жыл бұрын
Helpful and compact.
@qazijawad6451
2 жыл бұрын
You are doing great man❤
@odaakeenya
Жыл бұрын
You’re a legend Bro
@paulantonucci9002
Жыл бұрын
A fine tutorial !!
@new_direction_net
2 жыл бұрын
Bro that's the code 👊I've definitely smashed that like button
@augischadiegils.5109
3 жыл бұрын
Nice tutorial bro thanks!
@raen7171
Жыл бұрын
Hey bro i know this is late but can you explain why you need 3 file instead of 2 only?
@programmer5834
2 жыл бұрын
Great 👍
@ChristianRodriguez-tm3jg
Жыл бұрын
muchas gracias por tus videos. Aprendo varias cosas....
@redahple6375
3 жыл бұрын
New subscriber here😌
@henriquefelinimena3693
3 жыл бұрын
Thank you for the content
@zari_723
2 жыл бұрын
another great vid
@PoweredByDucks
Жыл бұрын
i understand this part, but how does the package actually create the window?
@abhayshaji3744
3 жыл бұрын
Amazing tutorial
@yuvalv7589
3 жыл бұрын
idk how to use jframe but maybe u know how to do this in window builder if i already got 2 windows?
@erawanthewise8227
3 жыл бұрын
YOU'RE THE BEST KZitemR EVER!!
@musoxoshimov4908
3 жыл бұрын
awesome👍
@kaushalprasadyadav9242
2 жыл бұрын
Please make videos for mobile app development 🙏 😊
@UNLIMITEDCODER-nn1hv
Жыл бұрын
can you plz sent another video to Java open a new GUI window with hiding first one
@nawfalnjm5699
3 жыл бұрын
awesome ! thanks
@realtimiksomg
5 күн бұрын
yay!! it works
@hannbebeeb
2 жыл бұрын
is there a way to choose where on the screen the window will appear?
@markjosephlargo7446
3 жыл бұрын
can u please help, i want to add 4 window, what should i do. thanks for the help
@just_some_greek_dude
Жыл бұрын
My window in windowbulder is distorted and idk how to fix it
@angelrodriguez7647
2 жыл бұрын
how do I make a new window come up when a username and password is entered in and clicked on a log in button
@alexshepel5599
4 жыл бұрын
Nice, bro!
@kemann3815
2 жыл бұрын
Perfect
@sergeyb6071
4 жыл бұрын
awesome!
@kitsune5661
2 жыл бұрын
how to open the new window on the same spot as the previous window in case you drag it?
@matthewgarber5517
Жыл бұрын
You shouldn’t be opening new windows. Instead don’t add items to a JFramw directly. Add them to a JPanel and add the panel to the frame. Then you can swap panels
@ultimatelegoman1279
3 жыл бұрын
About 300 likes and 0 dislikes!!! wow
@millejadecabrera4544
3 жыл бұрын
thanks for this...
@nehalayaaz9406
4 жыл бұрын
Thanks 🙏
@izic339
Жыл бұрын
Thanks
@developerjunior446
3 жыл бұрын
Good job Bro
@omersond4891
3 жыл бұрын
best man
@ajaykumar_tamilan
Жыл бұрын
Thank you bro
@hplat-vku
9 ай бұрын
thank broooo
@coma5084
2 жыл бұрын
it's so easy thanks
@ottttoooo
3 жыл бұрын
thank you bro
@islamgoda4208
3 жыл бұрын
Hi I have 2 windows and I want to be able to go back and forth to each other I can do the go to the second window part -thanks to you- but when I go back to the first window it duplicates.can you help?
@discontinued645
3 жыл бұрын
Use 'setDispose()' on both frames.
@mehdiebrahimzadeh9032
3 жыл бұрын
tnx a lot
@BeastGotClipped
3 жыл бұрын
TYSM
@blackpearl1066
2 жыл бұрын
Hello!
@splerix
3 жыл бұрын
the like ratio is impressive lol
@eugenezuev7349
4 ай бұрын
@johnysimps1191
10 ай бұрын
Mandatory supportive comment for the algorithm. Keep scrolling...
@blastsyt
3 жыл бұрын
It doesn’t work
@augischadiegils.5109
3 жыл бұрын
@greeneggsandmushrooms9855
3 жыл бұрын
my mother was a window
@borscht7743
7 ай бұрын
>if you learnt something new no i didnt.
@mssi3idbahma111
6 ай бұрын
3.4🔷️💻🛰♾️🔝🎱
@sushantlama9010
3 жыл бұрын
package CodeBro; import javax.swing.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; public class ACTION_LISTENER_CLASS implements ActionListener { int i =0; static JFrame frame2; String title ; static JButton button =new JButton(); public static void main(String[] args) { button.setBounds(200,200,200,200); button.setText("new frame"); button.setFocusable(false); button.addActionListener(new ACTION_LISTENER_CLASS());//to add action listener JFrame frame = new JFrame("ACTION LISTENER CLASS AND MULTIPLE FILE AT SAME TIME"); frame.setBounds(0,0,800,800); frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); frame.setLayout(null); frame.add(button); frame.setVisible(true); frame2 = new JFrame(); frame2.setBounds(0,0,200,200); frame2.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); } @Override public void actionPerformed(ActionEvent e) { if (e.getSource()==button){ int z=i++; title="frame"+i; frame2.setTitle(title); frame2.setVisible(true); } } }
@SLURPZZZ4461
Жыл бұрын
comment
@subs9054
2 жыл бұрын
COMMENT
@atomik9469
2 жыл бұрын
420 lol
@lorenzschwarz5877
3 жыл бұрын
wow 0 disslikes
@ServerServer-vb4oj
Жыл бұрын
i know im a little late but on the label I put the text "You are dead" and it cut it off and said "you ar.." how I fix
@ProbablyAnEarthbender
2 жыл бұрын
Anyone know why "(JFrame.EXIT_ON CLOSE)" is throwing an error when I typed it exactly like he did and imported swing.JFrame ??
Пікірлер: 106