Java open a new GUI window 🗔

Поделиться
HTML-код
  • Опубликовано: 19 дек 2024

Комментарии • 108

  • @BroCodez
    @BroCodez  4 года назад +56

    // **********************************************
    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
      @valencefootball9740 3 года назад

      2 420'S?!?

    • @joyceasante8292
      @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
    @pavelkvasnicka6856 Год назад +2

    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

  • @angelcastineira2561
    @angelcastineira2561 4 года назад +1

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

  • @Joy-mf6xo
    @Joy-mf6xo 2 года назад

    You don't know how much it helped!

  • @charliesellsaenz1092
    @charliesellsaenz1092 4 года назад +2

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

    • @BroCodez
      @BroCodez  4 года назад

      awesome!! thanks for watching Charlie!

  • @stanislavdimitrov1643
    @stanislavdimitrov1643 Год назад

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

  • @kyledarylltabuzo4568
    @kyledarylltabuzo4568 Год назад +1

    Finally at tutorial that explains what happens in the process

  • @Roxy377
    @Roxy377 2 года назад +1

    our lord and savoir is here

  • @darokimagandor1671
    @darokimagandor1671 8 месяцев назад

    This is interesting and it helps, thank you

  • @minerliton2481
    @minerliton2481 Год назад

    I love how you say "button"!

  • @mariorossi1456
    @mariorossi1456 4 года назад +2

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

  • @byThaxar
    @byThaxar 3 года назад +1

    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

  • @prod.xavgvst
    @prod.xavgvst 2 года назад

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

  • @abdulkudduskosimov4443
    @abdulkudduskosimov4443 Год назад

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

  • @antoinealam6531
    @antoinealam6531 3 месяца назад +1

    You made me love coding again

  • @enow0049
    @enow0049 2 года назад

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

  • @speklex779
    @speklex779 Год назад +1

    Amazing video

  • @All_In_786
    @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..

  • @desmondchiemezieugwuanyi8197
    @desmondchiemezieugwuanyi8197 2 года назад

    Bro, thanks a lot for your wonderful tutorials

  • @kabirahmed9626
    @kabirahmed9626 3 года назад

    Bro you helped me a LOT . Thanks man

  • @Ashish_singh_dev
    @Ashish_singh_dev 3 года назад

    Awesome tut bro looking forward for more tuts like this 😍

  • @forte2265
    @forte2265 2 года назад

    this helped me a ton, thanks!

  • @schroedenger
    @schroedenger 2 года назад

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

  • @rabomeister
    @rabomeister Год назад

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

  • @funwithalbi2425
    @funwithalbi2425 2 года назад +6

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

  • @amadujalloh4700
    @amadujalloh4700 4 года назад +4

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

    • @BroCodez
      @BroCodez  4 года назад +5

      I think I might have a video on what you're looking for here:
      ruclips.net/video/J4g6iuKoo_0/видео.html

  • @new_direction_net
    @new_direction_net 2 года назад

    Bro that's the code 👊I've definitely smashed that like button

  • @ChristianRodriguez-tm3jg
    @ChristianRodriguez-tm3jg Год назад

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

  • @jadasarchives
    @jadasarchives 2 года назад

    this was soo helpful, thank you!

  • @martontoth3578
    @martontoth3578 3 года назад

    Helpful and compact.

  • @qazijawad6451
    @qazijawad6451 2 года назад

    You are doing great man❤

  • @redahple6375
    @redahple6375 3 года назад

    New subscriber here😌

  • @programmer5834
    @programmer5834 2 года назад

    Great 👍

  • @grace_upon_linda
    @grace_upon_linda 2 года назад

    Thanks man, it worked!

  • @kaushalprasadyadav9242
    @kaushalprasadyadav9242 2 года назад

    Please make videos for mobile app development 🙏 😊

  • @ibrahimylmaz8378
    @ibrahimylmaz8378 2 года назад +1

    thanks bro

  • @Sireington
    @Sireington 14 дней назад

    this was pretty cool! idk why but the second window doesn't open and the @Override causes an error but nevertheless, cool!

  • @augischadiegils.5109
    @augischadiegils.5109 4 года назад

    Nice tutorial bro thanks!

  • @abhayshaji3744
    @abhayshaji3744 3 года назад

    Amazing tutorial

  • @henriquefelinimena3693
    @henriquefelinimena3693 3 года назад

    Thank you for the content

  • @musoxoshimov4908
    @musoxoshimov4908 3 года назад

    awesome👍

  • @paulantonucci9002
    @paulantonucci9002 Год назад

    A fine tutorial !!

  • @stephanieezat-panah7750
    @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
      @BroCodez  2 года назад +1

      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
      @keerthanavemula24 2 года назад +1

      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
      @stranger9951 Год назад

      @@BroCodez What language have you been using recently?

  • @erawanthewise8227
    @erawanthewise8227 3 года назад

    YOU'RE THE BEST RUclipsR EVER!!

  • @voidd-cp5ke
    @voidd-cp5ke 2 года назад

    Thank you bro

  • @dexspits7869
    @dexspits7869 2 года назад

    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

  • @jacksongetangita9061
    @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?"

  • @MrLoser-ks2xn
    @MrLoser-ks2xn 2 года назад

    Thanks

  • @millejadecabrera4544
    @millejadecabrera4544 3 года назад

    thanks for this...

  • @yuvalv7589
    @yuvalv7589 3 года назад

    idk how to use jframe but maybe u know how to do this in window builder if i already got 2 windows?

  • @UNLIMITEDCODER-nn1hv
    @UNLIMITEDCODER-nn1hv Год назад

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

  • @odaakeenya
    @odaakeenya 2 года назад

    You’re a legend Bro

  • @nehalayaaz9406
    @nehalayaaz9406 4 года назад

    Thanks 🙏

  • @willowbrown5320
    @willowbrown5320 День назад

    Will this work on notepad++? Where is your code written in??

  • @raen7171
    @raen7171 2 года назад +1

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

  • @coma5084
    @coma5084 2 года назад

    it's so easy thanks

  • @hplat-vku
    @hplat-vku Год назад

    thank broooo

  • @johnysimps1191
    @johnysimps1191 Год назад

    Mandatory supportive comment for the algorithm. Keep scrolling...

  • @ottttoooo
    @ottttoooo 3 года назад

    thank you bro

  • @kemann3815
    @kemann3815 3 года назад

    Perfect

  • @blackpearl1066
    @blackpearl1066 2 года назад

    Hello!

  • @nawfalnjm5699
    @nawfalnjm5699 3 года назад

    awesome ! thanks

  • @ultimatelegoman1279
    @ultimatelegoman1279 3 года назад +1

    About 300 likes and 0 dislikes!!! wow

  • @PoweredByDucks
    @PoweredByDucks 2 года назад

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

  • @markjosephlargo7446
    @markjosephlargo7446 3 года назад

    can u please help,
    i want to add 4 window, what should i do.
    thanks for the help

  • @hannbebeeb
    @hannbebeeb 2 года назад

    is there a way to choose where on the screen the window will appear?

  • @sushantlama9010
    @sushantlama9010 4 года назад +1

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

  • @zari_723
    @zari_723 2 года назад

    another great vid

  • @developerjunior446
    @developerjunior446 3 года назад

    Good job Bro

  • @mssi3idbahma111
    @mssi3idbahma111 9 месяцев назад +1

    3.4🔷️💻🛰♾️🔝🎱

  • @just_some_greek_dude
    @just_some_greek_dude Год назад

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

  • @mehdiebrahimzadeh9032
    @mehdiebrahimzadeh9032 3 года назад

    tnx a lot

  • @splerix
    @splerix 3 года назад

    the like ratio is impressive lol

  • @kitsune5661
    @kitsune5661 2 года назад

    how to open the new window on the same spot as the previous window in case you drag it?

    • @matthewgarber5517
      @matthewgarber5517 2 года назад

      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

  • @eugenezuev7349
    @eugenezuev7349 7 месяцев назад

  • @sergeyb6071
    @sergeyb6071 4 года назад

    awesome!

  • @greeneggsandmushrooms9855
    @greeneggsandmushrooms9855 3 года назад

    my mother was a window

  • @angelrodriguez7647
    @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

  • @BeastGotClipped
    @BeastGotClipped 3 года назад

    TYSM

  • @alexshepel5599
    @alexshepel5599 4 года назад

    Nice, bro!

  • @omersond4891
    @omersond4891 3 года назад

    best man

  • @augischadiegils.5109
    @augischadiegils.5109 3 года назад

  • @realtimiksomg
    @realtimiksomg 2 месяца назад

    yay!! it works

  • @borscht7743
    @borscht7743 9 месяцев назад

    >if you learnt something new
    no i didnt.

  • @blastsyt
    @blastsyt 3 года назад

    It doesn’t work

  • @islamgoda4208
    @islamgoda4208 4 года назад

    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?

  • @SLURPZZZ4461
    @SLURPZZZ4461 Год назад

    comment

  • @atomik9469
    @atomik9469 3 года назад

    420 lol

  • @subs9054
    @subs9054 2 года назад

    COMMENT

  • @lorenzschwarz5877
    @lorenzschwarz5877 3 года назад

    wow 0 disslikes

  • @ServerServer-vb4oj
    @ServerServer-vb4oj 2 года назад

    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
    @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 ??

  • @mssi3idbahma111
    @mssi3idbahma111 9 месяцев назад +1

    1.00000.MAS.PASS.1.11111

  • @ajaykumar_tamilan
    @ajaykumar_tamilan 2 года назад

    Thank you bro

  • @izic339
    @izic339 Год назад

    Thanks