Java open a new GUI window

Java open a new GUI window

Bro Code

3 года назад

107,437 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

Bro Code
Bro Code - 06.06.2020 04:37

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

Ответить
Aviv Dukhovich
Aviv Dukhovich - 03.11.2023 16:21

Amazing video

Ответить
UNLIMITED CODER
UNLIMITED CODER - 09.08.2023 19:59

can you plz sent another video to Java open a new GUI window with hiding first one

Ответить
stanislav dimitrov
stanislav dimitrov - 26.07.2023 18:04

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

Ответить
Abdulkuddus Kosimov
Abdulkuddus Kosimov - 19.07.2023 23:17

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

Ответить
mel
mel - 17.05.2023 00:37

My window in windowbulder is distorted and idk how to fix it

Ответить
Pavel Kvasnička
Pavel Kvasnička - 09.04.2023 13:46

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

Ответить
Hüseyin Şenol
Hüseyin Şenol - 05.04.2023 21:38

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

Ответить
Paul Antonucci
Paul Antonucci - 04.04.2023 23:46

A fine tutorial !!

Ответить
izic
izic - 26.03.2023 06:04

Thanks

Ответить
SLURPZZZ4461
SLURPZZZ4461 - 21.02.2023 22:56

I don't understand how myButton.addActionListener(this); works. Why do we pass in this?

Ответить
SLURPZZZ4461
SLURPZZZ4461 - 21.02.2023 22:36

comment

Ответить
Christian Rodriguez
Christian Rodriguez - 06.02.2023 17:15

muchas gracias por tus videos. Aprendo varias cosas....

Ответить
KYLE DARYLL TABUZO
KYLE DARYLL TABUZO - 17.01.2023 18:26

Finally at tutorial that explains what happens in the process

Ответить
Powered By Ducks
Powered By Ducks - 12.12.2022 03:43

i understand this part, but how does the package actually create the window?

Ответить
Yavit Vargas
Yavit Vargas - 08.12.2022 23:41

Suscribing just because you set the size to (420,420) hahaha that's funny!

Ответить
Raen
Raen - 05.12.2022 02:47

Hey bro i know this is late but can you explain why you need 3 file instead of 2 only?

Ответить
Konrad Gałązka
Konrad Gałązka - 02.12.2022 17:55

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

Ответить
Odaa Keenya
Odaa Keenya - 21.11.2022 17:08

You’re a legend Bro

Ответить
DEX SPITS
DEX SPITS - 09.11.2022 10:41

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

Ответить
Server22 Server22
Server22 Server22 - 29.10.2022 10:44

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

Ответить