Java open a new GUI window 🗔

preview_player
Показать описание
Java new window

#java #new #window

// **********************************************
public class Main {

public static void main(String[] args) {

LaunchPage launchPage = new LaunchPage();

}
}
// **********************************************

public class LaunchPage implements ActionListener{

JFrame frame = new JFrame();
JButton myButton = new JButton("New Window");

LaunchPage(){




}

@Override
public void actionPerformed(ActionEvent e) {

NewWindow myWindow = new NewWindow();
}
}
}
// **********************************************
public class NewWindow {

JFrame frame = new JFrame();
JLabel label = new JLabel("Hello!");

NewWindow(){



}
}
Рекомендации по теме
Комментарии
Автор

//
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);



frame.add(myButton);


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.setSize(420, 420);
frame.setLayout(null);
frame.setVisible(true);
}
}

BroCodez
Автор

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

pavelkvasnicka
Автор

Very nice video, I like it very much. 40 degrees Celsius, drink beer 😃😃😃

stanislavdimitrov
Автор

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

byThaxar
Автор

Finally at tutorial that explains what happens in the process

kyledarylltabuzo
Автор

another great video! i'm about to be up to date with your series!

angelcastineira
Автор

You just saved my proyect!! I LOVE YOU!!

charliesellsaenz
Автор

i’m a student and i’m learning from my college that is called Bro Code and it’s free

funwithalbi
Автор

Heey Bro, you are awesome, your way of teaching is very nice..
I smashed the like button, that my phone screen is gonna crack..

All_In_
Автор

I love how you say "button"!

minerliton
Автор

You don't know how much it helped!

Joy-mfxo
Автор

Thanks, I'm working on a project, you are helping me a lot

mariorossi
Автор

Just found your channel through this video, with all the great content how could I not subscribe?

schroedenger
Автор

Hey Bro Code, please do videos on constructors(their types), and objects in Java

amadujalloh
Автор

Thank you very much bro, you helped me out of a problem with this tutorial.

abdulkudduskosimov
Автор

Thanks man exactly the solution to my problem! I am glad i subbed to you!

enow
Автор

Awesome tut bro looking forward for more tuts like this 😍

Ashish_singh_dev
Автор

This is interesting and it helps, thank you

darokimagandor
Автор

You earned yourself a sub... thank you so much broski

prod.xavgvst
Автор

wow that frame.setSize parameters must be really coincidence :P

rabomeister