Java open a new GUI window 🗔

SdĂ­let
VloĆŸit
  • čas pƙidĂĄn 27. 07. 2024
  • Java new window
    #java #new #window
    // **********************************************
    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);
    }
    }
  • Věda a technologie

Komentáƙe • 104

  • @BroCodez
    @BroCodez  Pƙed 4 lety +51

    // **********************************************
    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 Pƙed 3 lety

      2 420'S?!?

    • @joyceasante8292
      @joyceasante8292 Pƙed rokem

      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 Pƙed rokem +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 Pƙed 4 lety +1

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

  • @enow0049
    @enow0049 Pƙed 2 lety

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

  • @Ashish_singh_dev
    @Ashish_singh_dev Pƙed 2 lety

    Awesome tut bro looking forward for more tuts like this 😍

  • @desmondchiemezieugwuanyi8197

    Bro, thanks a lot for your wonderful tutorials

  • @mariorossi1456
    @mariorossi1456 Pƙed 4 lety +2

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

  • @Nyancatjackson
    @Nyancatjackson Pƙed 2 lety

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

  • @jadasarchives
    @jadasarchives Pƙed 2 lety

    this was soo helpful, thank you!

  • @Joy-mf6xo
    @Joy-mf6xo Pƙed 2 lety

    You don't know how much it helped!

  • @forte2265
    @forte2265 Pƙed rokem

    this helped me a ton, thanks!

  • @kabirahmed9626
    @kabirahmed9626 Pƙed 3 lety

    Bro you helped me a LOT . Thanks man

  • @prod.xavgvst
    @prod.xavgvst Pƙed rokem

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

  • @abdulkudduskosimov4443
    @abdulkudduskosimov4443 Pƙed rokem

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

  • @kyledarylltabuzo4568
    @kyledarylltabuzo4568 Pƙed rokem +1

    Finally at tutorial that explains what happens in the process

  • @byThaxar
    @byThaxar Pƙed 2 lety +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

  • @All_In_786
    @All_In_786 Pƙed 3 lety

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

  • @grace_upon_linda
    @grace_upon_linda Pƙed 2 lety

    Thanks man, it worked!

  • @darokimagandor1671
    @darokimagandor1671 Pƙed 3 měsĂ­ci

    This is interesting and it helps, thank you

  • @charliesellsaenz1092
    @charliesellsaenz1092 Pƙed 3 lety +2

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

    • @BroCodez
      @BroCodez  Pƙed 3 lety

      awesome!! thanks for watching Charlie!

  • @minerliton2481
    @minerliton2481 Pƙed 7 měsĂ­ci

    I love how you say "button"!

  • @martontoth3578
    @martontoth3578 Pƙed 2 lety

    Helpful and compact.

  • @augischadiegils.5109
    @augischadiegils.5109 Pƙed 3 lety

    Nice tutorial bro thanks!

  • @ChristianRodriguez-tm3jg

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

  • @stanislavdimitrov1643
    @stanislavdimitrov1643 Pƙed rokem

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

  • @paulantonucci9002
    @paulantonucci9002 Pƙed rokem

    A fine tutorial !!

  • @qazijawad6451
    @qazijawad6451 Pƙed 2 lety

    You are doing great man❀

  • @henriquefelinimena3693
    @henriquefelinimena3693 Pƙed 3 lety

    Thank you for the content

  • @amadujalloh4700
    @amadujalloh4700 Pƙed 4 lety +4

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

    • @BroCodez
      @BroCodez  Pƙed 4 lety +5

      I think I might have a video on what you're looking for here:
      czcams.com/video/J4g6iuKoo_0/video.html

  • @abhayshaji3744
    @abhayshaji3744 Pƙed 2 lety

    Amazing tutorial

  • @nawfalnjm5699
    @nawfalnjm5699 Pƙed 3 lety

    awesome ! thanks

  • @new_direction_net
    @new_direction_net Pƙed rokem

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

  • @musoxoshimov4908
    @musoxoshimov4908 Pƙed 3 lety

    awesome👍

  • @speklex779
    @speklex779 Pƙed 8 měsĂ­ci

    Amazing video

  • @programmer5834
    @programmer5834 Pƙed 2 lety

    Great 👍

  • @sergeyb6071
    @sergeyb6071 Pƙed 4 lety

    awesome!

  • @huseyinsenol1769
    @huseyinsenol1769 Pƙed rokem

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

  • @ibrahimylmaz8378
    @ibrahimylmaz8378 Pƙed 2 lety +1

    thanks bro

  • @erawanthewise8227
    @erawanthewise8227 Pƙed 3 lety

    YOU'RE THE BEST CZcamsR EVER!!

  • @odaakeenya
    @odaakeenya Pƙed rokem

    You’re a legend Bro

  • @zari_723
    @zari_723 Pƙed rokem

    another great vid

  • @nehalayaaz9406
    @nehalayaaz9406 Pƙed 4 lety

    Thanks 🙏

  • @millejadecabrera4544
    @millejadecabrera4544 Pƙed 3 lety

    thanks for this...

  • @kemann3815
    @kemann3815 Pƙed 2 lety

    Perfect

  • @voidd-cp5ke
    @voidd-cp5ke Pƙed 2 lety

    Thank you bro

  • @kaushalprasadyadav9242
    @kaushalprasadyadav9242 Pƙed 2 lety

    Please make videos for mobile app development 🙏 😊

  • @Roxy377
    @Roxy377 Pƙed 2 lety +1

    our lord and savoir is here

  • @alexshepel5599
    @alexshepel5599 Pƙed 3 lety

    Nice, bro!

  • @coma5084
    @coma5084 Pƙed 2 lety

    it's so easy thanks

  • @MrLoser-ks2xn
    @MrLoser-ks2xn Pƙed 2 lety

    Thanks

  • @ottttoooo
    @ottttoooo Pƙed 3 lety

    thank you bro

  • @redahple6375
    @redahple6375 Pƙed 3 lety

    New subscriber here😌

  • @hplat-vku
    @hplat-vku Pƙed 7 měsĂ­ci

    thank broooo

  • @omersond4891
    @omersond4891 Pƙed 3 lety

    best man

  • @mehdiebrahimzadeh9032
    @mehdiebrahimzadeh9032 Pƙed 2 lety

    tnx a lot

  • @funwithalbi2425
    @funwithalbi2425 Pƙed 2 lety +5

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

  • @BeastGotClipped
    @BeastGotClipped Pƙed 2 lety

    TYSM

  • @jacksongetangita9061
    @jacksongetangita9061 Pƙed 2 lety

    the tutorial is very help full...
    how can you make the button to link with another website like "click here to access Gmail account?"

  • @yuvalv7589
    @yuvalv7589 Pƙed 3 lety

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

  • @developerjunior446
    @developerjunior446 Pƙed 3 lety

    Good job Bro

  • @dexspits7869
    @dexspits7869 Pƙed rokem

    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

  • @augischadiegils.5109
    @augischadiegils.5109 Pƙed 3 lety

  • @raen7171
    @raen7171 Pƙed rokem +1

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

  • @PoweredByDucks
    @PoweredByDucks Pƙed rokem

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

  • @markjosephlargo7446
    @markjosephlargo7446 Pƙed 3 lety

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

  • @UNLIMITEDCODER-nn1hv
    @UNLIMITEDCODER-nn1hv Pƙed 11 měsĂ­ci

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

  • @hannbebeeb
    @hannbebeeb Pƙed rokem

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

  • @blackpearl1066
    @blackpearl1066 Pƙed 2 lety

    Hello!

  • @stephanieezat-panah7750
    @stephanieezat-panah7750 Pƙed rokem

    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  Pƙed rokem +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 Pƙed rokem +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 Pƙed rokem

      @@BroCodez What language have you been using recently?

  • @ultimatelegoman1279
    @ultimatelegoman1279 Pƙed 3 lety +1

    About 300 likes and 0 dislikes!!! wow

  • @just_some_greek_dude
    @just_some_greek_dude Pƙed rokem

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

  • @splerix
    @splerix Pƙed 3 lety

    the like ratio is impressive lol

  • @eugenezuev7349
    @eugenezuev7349 Pƙed 2 měsĂ­ci

  • @angelrodriguez7647
    @angelrodriguez7647 Pƙed 2 lety

    how do I make a new window come up when a username and password is entered in and clicked on a log in button

  • @johnysimps1191
    @johnysimps1191 Pƙed 8 měsĂ­ci

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

  • @kitsune5661
    @kitsune5661 Pƙed 2 lety

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

    • @matthewgarber5517
      @matthewgarber5517 Pƙed rokem

      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

  • @greeneggsandmushrooms9855

    my mother was a window

  • @mssi3idbahma111
    @mssi3idbahma111 Pƙed 4 měsĂ­ci +1

    3.4đŸ”·ïžđŸ’»đŸ›°â™ŸïžđŸ”đŸŽ±

  • @blastsyt
    @blastsyt Pƙed 3 lety

    It doesn’t work

  • @borscht7743
    @borscht7743 Pƙed 4 měsĂ­ci

    >if you learnt something new
    no i didnt.

  • @islamgoda4208
    @islamgoda4208 Pƙed 3 lety

    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?

  • @atomik9469
    @atomik9469 Pƙed 2 lety

    420 lol

  • @SLURPZZZ4461
    @SLURPZZZ4461 Pƙed rokem

    comment

  • @lorenzschwarz5877
    @lorenzschwarz5877 Pƙed 3 lety

    wow 0 disslikes

  • @subs9054
    @subs9054 Pƙed rokem

    COMMENT

  • @sushantlama9010
    @sushantlama9010 Pƙed 3 lety +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);
    }
    }
    }

  • @ServerServer-vb4oj
    @ServerServer-vb4oj Pƙed rokem

    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 Pƙed 2 lety

    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 Pƙed 4 měsĂ­ci +1

    1.00000.MAS.PASS.1.11111

  • @ajaykumar_tamilan
    @ajaykumar_tamilan Pƙed rokem

    Thank you bro

  • @izic339
    @izic339 Pƙed rokem

    Thanks