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
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?
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.
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
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
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
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?
// **********************************************
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);
}
}
2 420'S?!?
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);
}
}
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
another great video! i'm about to be up to date with your series!
You don't know how much it helped!
You just saved my proyect!! I LOVE YOU!!
awesome!! thanks for watching Charlie!
Very nice video, I like it very much. 40 degrees Celsius, drink beer 😃😃😃
Finally at tutorial that explains what happens in the process
our lord and savoir is here
This is interesting and it helps, thank you
I love how you say "button"!
Thanks, I'm working on a project, you are helping me a lot
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
You earned yourself a sub... thank you so much broski
Thank you very much bro, you helped me out of a problem with this tutorial.
You made me love coding again
Thanks man exactly the solution to my problem! I am glad i subbed to you!
Amazing video
Heey Bro , you are awesome , your way of teaching is very nice..
I smashed the like button, that my phone screen is gonna crack..
Bro, thanks a lot for your wonderful tutorials
Bro you helped me a LOT . Thanks man
Awesome tut bro looking forward for more tuts like this 😍
this helped me a ton, thanks!
Just found your channel through this video, with all the great content how could I not subscribe?
wow that frame.setSize parameters must be really coincidence :P
i’m a student and i’m learning from my college that is called Bro Code and it’s free
Same
Hey Bro Code, please do videos on constructors(their types), and objects in Java
I think I might have a video on what you're looking for here:
ruclips.net/video/J4g6iuKoo_0/видео.html
Bro that's the code 👊I've definitely smashed that like button
muchas gracias por tus videos. Aprendo varias cosas....
this was soo helpful, thank you!
Helpful and compact.
You are doing great man❤
New subscriber here😌
Great 👍
Thanks man, it worked!
Please make videos for mobile app development 🙏 😊
thanks bro
this was pretty cool! idk why but the second window doesn't open and the @Override causes an error but nevertheless, cool!
Nice tutorial bro thanks!
Amazing tutorial
Thank you for the content
awesome👍
A fine tutorial !!
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?
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.
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
@@BroCodez What language have you been using recently?
YOU'RE THE BEST RUclipsR EVER!!
Thank you bro
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
the tutorial is very help full...
how can you make the button to link with another website like "click here to access Gmail account?"
Thanks
thanks for this...
idk how to use jframe but maybe u know how to do this in window builder if i already got 2 windows?
can you plz sent another video to Java open a new GUI window with hiding first one
You’re a legend Bro
Thanks 🙏
Will this work on notepad++? Where is your code written in??
Hey bro i know this is late but can you explain why you need 3 file instead of 2 only?
it's so easy thanks
thank broooo
Mandatory supportive comment for the algorithm. Keep scrolling...
thank you bro
Perfect
Hello!
awesome ! thanks
About 300 likes and 0 dislikes!!! wow
i understand this part, but how does the package actually create the window?
can u please help,
i want to add 4 window, what should i do.
thanks for the help
is there a way to choose where on the screen the window will appear?
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);
}
}
}
another great vid
Good job Bro
3.4🔷️💻🛰♾️🔝🎱
My window in windowbulder is distorted and idk how to fix it
tnx a lot
the like ratio is impressive lol
how to open the new window on the same spot as the previous window in case you drag it?
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
awesome!
my mother was a window
how do I make a new window come up when a username and password is entered in and clicked on a log in button
TYSM
Nice, bro!
best man
yay!! it works
>if you learnt something new
no i didnt.
It doesn’t work
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?
Use 'setDispose()' on both frames.
comment
420 lol
COMMENT
wow 0 disslikes
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
Anyone know why "(JFrame.EXIT_ON CLOSE)" is throwing an error when I typed it exactly like he did and imported swing.JFrame ??
1.00000.MAS.PASS.1.11111
Thank you bro
Thanks