Java JOptionPane 🛑

แชร์
ฝัง
  • เผยแพร่เมื่อ 6 ก.พ. 2025
  • Java JOptionPane joptionpane MessageDialog Swing GUI tutorial for beginners
    #Java #JOptionPane #optionpane #MessageDialog #Swing #GUI #tutorial #beginners
    import javax.swing.ImageIcon;
    import javax.swing.JOptionPane;
    public class Main{
    public static void main(String[] args) {
    //JOptionPane = pop up a standard dialog box that prompts users for a value
    // or informs them of something.
    //JOptionPane.showMessageDialog(null, "This is a message dialog box", "title", JOptionPane.PLAIN_MESSAGE);
    //JOptionPane.showMessageDialog(null, "Here is some useless info", "title", JOptionPane.INFORMATION_MESSAGE);
    //JOptionPane.showMessageDialog(null, "really?", "title", JOptionPane.QUESTION_MESSAGE);
    //JOptionPane.showMessageDialog(null, "Your computer has a VIRUS!", "title", JOptionPane.WARNING_MESSAGE);
    //JOptionPane.showMessageDialog(null, "CALL TECH SUPPORT OR ELSE!", "title", JOptionPane.ERROR_MESSAGE);

    //int answer = JOptionPane.showConfirmDialog(null, "bro, do you even code?");
    //String name = JOptionPane.showInputDialog("What is your name?: ");
    ImageIcon icon = new ImageIcon("smile.png");
    String[] responses = {"No, you are!","thank you!","*blush*"};
    int answer = JOptionPane.showOptionDialog(
    null,
    "You are the best! :D",
    "Secret message",
    JOptionPane.DEFAULT_OPTION,
    0,
    icon,
    responses,
    responses[0]);
    System.out.println(answer);
    }
    }

ความคิดเห็น • 115

  • @BroCodez
    @BroCodez  4 ปีที่แล้ว +56

    import javax.swing.ImageIcon;
    import javax.swing.JOptionPane;
    public class Main{
    public static void main(String[] args) {

    //JOptionPane = pop up a standard dialog box that prompts users for a value
    // or informs them of something.

    //JOptionPane.showMessageDialog(null, "This is a message dialog box", "title", JOptionPane.PLAIN_MESSAGE);
    //JOptionPane.showMessageDialog(null, "Here is some useless info", "title", JOptionPane.INFORMATION_MESSAGE);
    //JOptionPane.showMessageDialog(null, "really?", "title", JOptionPane.QUESTION_MESSAGE);
    //JOptionPane.showMessageDialog(null, "Your computer has a VIRUS!", "title", JOptionPane.WARNING_MESSAGE);
    //JOptionPane.showMessageDialog(null, "CALL TECH SUPPORT OR ELSE!", "title", JOptionPane.ERROR_MESSAGE);


    //int answer = JOptionPane.showConfirmDialog(null, "bro, do you even code?");
    //String name = JOptionPane.showInputDialog("What is your name?: ");

    ImageIcon icon = new ImageIcon("smile.png");
    String[] responses = {"No, you are!","thank you!","*blush*"};
    int answer = JOptionPane.showOptionDialog(
    null,
    "You are the best! :D",
    "Secret message",
    JOptionPane.DEFAULT_OPTION,
    0,
    icon,
    responses,
    responses[0]);
    System.out.println(answer);

    }
    }

    • @carsanovadidrifto800
      @carsanovadidrifto800 2 ปีที่แล้ว

      Hey fam, I hope that you and your loved ones are well. I would like to ask you the most important question ever asked:
      Who is Jesus? Not who is He to you. Rather, who is He really?
      Jesus is the Son of God, who came to the world as a man. He lived a perfect and sinless life . Even though He was perfect and sinless, on the cross of Calvary God wrathfully punished Him for the sins of the world. 3 days later He rose from death. Now He is seated at the right hand of God, ruling as King over Heaven and Earth.
      On the judgment day He will judge you, me and every human being that has ever lived. Those who believed in Him will enter eternal joy with Him, but those who did not believe in Jesus will be sent to eternal condemnation.
      So turn from your sins and believe in the Jesus, that you can be forgiven for all your sins, because of His death and resurrection.
      Acts 15:11
      ”On the contrary, we believe it is through the grace of the Lord Jesus that we are saved, just as they are."
      Ephesians 1:7
      ”In Him, we have redemption through His blood, the forgiveness of our trespasses, according to the riches of His grace"
      Ephesians 2:8
      ”For it is by grace you have been saved through faith, and this not from yourselves; it is the gift of God,”
      John 11:25-26: "Jesus said to her, 'I am the resurrection and the life. The one who believes in me will live, even though they die; and whoever lives by believing in me will never die. Do you believe this?'
      1 Corinthians 6:14: "And God raised the Lord and will also raise us up by his power."
      Romans 6:9: "We know that Christ, being raised from the dead, will never die again; death no longer has dominion over him."

    • @oscarjosefsson9300
      @oscarjosefsson9300 2 ปีที่แล้ว

      When you insert the showConfirmDialog method it looks like Eclipse creates placeholder arguments that shows what type of arguments you should give.
      When I insert showConfirmDialog I get: "null, args, null, 0".
      Is there an option to switch between these behaviours?

  • @subhadeepdas9814
    @subhadeepdas9814 3 ปีที่แล้ว +22

    Had zero idea about JOptionPane, came here, spent 12 mins, can code custom dialog boxes like a Pro now!!!. Thanks a lot

  • @pavelkvasnicka6856
    @pavelkvasnicka6856 ปีที่แล้ว +6

    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

  • @jaywest1593
    @jaywest1593 6 หลายเดือนก่อน

    Had a vague understanding of this after a 2 hour class lecture. This video really helped clarify and I was able to make some boxes. Keep em' coming bro!

  • @elionayzuridasilveira4140
    @elionayzuridasilveira4140 7 หลายเดือนก่อน +1

    You're awesome, teacher!

  • @wollyber1121
    @wollyber1121 2 ปีที่แล้ว +4

    Increíble. Que genial es esta forma de mostrar mensajes en Java :D

  • @johnchristianmakalintal568
    @johnchristianmakalintal568 4 ปีที่แล้ว +8

    just shared your channel on facebook ;) Great tuts :D

    • @BroCodez
      @BroCodez  4 ปีที่แล้ว +9

      Thanks bro! I hate to admit it, but I could use all the help I can get. Thanks again

  • @howcanidoit
    @howcanidoit 4 ปีที่แล้ว +8

    Great video, straight to the point! Thanks!

  • @youssefalaaeldin6707
    @youssefalaaeldin6707 3 ปีที่แล้ว +2

    A man with zero dislikes

  • @ValderhaugChindia
    @ValderhaugChindia ปีที่แล้ว +3

    God Bless You Man!!!🙌

  • @tarunchaudhary8543
    @tarunchaudhary8543 ปีที่แล้ว

    Very informative video bro.. And you are awesome 👍

  • @deepdaddy1208
    @deepdaddy1208 4 ปีที่แล้ว +8

    great vid bro, as always

  • @DanielOttergren
    @DanielOttergren 2 ปีที่แล้ว

    cool tutorial now i know more about joptionpane would recommend

  • @lateve6243
    @lateve6243 11 หลายเดือนก่อน

    Yo bro, you just help me study last minute for a midterm in one hour! thanks!

  • @onoKAUTA
    @onoKAUTA 10 หลายเดือนก่อน

    We need teachers like you Bro😂❤

  • @speklex779
    @speklex779 ปีที่แล้ว

    nice video

  • @mr.snowbear
    @mr.snowbear ปีที่แล้ว

    Verry helpful

  • @nagumulifrancis5057
    @nagumulifrancis5057 ปีที่แล้ว

    You're awesome indeed😊😊

  • @fredericoamigo
    @fredericoamigo ปีที่แล้ว

    Once again, awesome content bro! Thank you so much for this! Keep up the good work!

  • @lisak.j7090
    @lisak.j7090 2 ปีที่แล้ว

    Amazing

  • @givoxx4970
    @givoxx4970 2 วันที่ผ่านมา

    That's amazing!

  • @felixnyamongo
    @felixnyamongo 2 ปีที่แล้ว

    You are awesome. No.. You are very awesome

  • @developerjunior446
    @developerjunior446 3 ปีที่แล้ว

    Super

  • @lukashenrique4295
    @lukashenrique4295 ปีที่แล้ว

    lets defeat the algorithm! 😂and thank you for the video

  • @kemann3815
    @kemann3815 3 ปีที่แล้ว

    Awesome

  • @quyo6777
    @quyo6777 10 หลายเดือนก่อน

    awesome

  • @justinbanza4751
    @justinbanza4751 3 ปีที่แล้ว +1

    Thank you for this video.
    very useful

  • @asteroid_destroyer-e6x
    @asteroid_destroyer-e6x หลายเดือนก่อน

    best bro

  • @Aro3o6
    @Aro3o6 3 ปีที่แล้ว +3

    7:55 never before have I laughed at a code output. lmao

  • @Alpine385
    @Alpine385 ปีที่แล้ว

    Bro, you are wow

  • @ВенциТенев
    @ВенциТенев 3 หลายเดือนก่อน

    so cool

  • @omersond4891
    @omersond4891 4 ปีที่แล้ว

    best guy#

  • @cuz_it_me648
    @cuz_it_me648 4 ปีที่แล้ว +1

    You are awesome bro !!!!
    Thankx

  • @santanukumarpandapanda7588
    @santanukumarpandapanda7588 ปีที่แล้ว

    Thank you sir

  • @winterSweet-k4m
    @winterSweet-k4m 4 ปีที่แล้ว +4

    *random comment for youtube's algorithm*

  • @bharathpavurala7817
    @bharathpavurala7817 2 ปีที่แล้ว

    Made it so easy

  • @mehdiebrahimzadeh9032
    @mehdiebrahimzadeh9032 3 ปีที่แล้ว

    great , tnx bro

  • @henriquefelinimena3693
    @henriquefelinimena3693 3 ปีที่แล้ว

    thank you for the content

  • @NBF_27
    @NBF_27 3 หลายเดือนก่อน

    🎉❤

  • @zahrapashayeva2458
    @zahrapashayeva2458 ปีที่แล้ว

    ❤❤

  • @DreamQuestGamer
    @DreamQuestGamer 3 ปีที่แล้ว +7

    Bro code can u tell me the settings of eclipse so that i can also get the name of the parameters as a hint ? something like below??
    JOptionPane.showMessageDialog(parentcomponent, message, title , messageType);

  • @majid1885
    @majid1885 3 ปีที่แล้ว

    awesome bro, thanks

  • @saweranabi7786
    @saweranabi7786 2 ปีที่แล้ว

    💯👍

  • @_aaaadam
    @_aaaadam 2 ปีที่แล้ว

    thx awesome lesson

  • @ultimatelegoman1279
    @ultimatelegoman1279 3 ปีที่แล้ว

    Beautiful!

  • @infinitepossibilities2614
    @infinitepossibilities2614 3 ปีที่แล้ว +3

    Bro can you provide a link or a way to get those pngs as well?
    Videos are really awesome...

  • @ajaykumar_tamilan
    @ajaykumar_tamilan 2 ปีที่แล้ว

    thank you bro

  • @Mr.-Toad
    @Mr.-Toad ปีที่แล้ว +2

    hey is there an an alternative to JOptionPane? It seems to have been removed in Java SE 20.
    😑

  • @MrLoser-ks2xn
    @MrLoser-ks2xn 2 ปีที่แล้ว

    Thanks

  • @ibrahimylmaz8378
    @ibrahimylmaz8378 2 ปีที่แล้ว

    thanks bro

  • @rachelgreen9754
    @rachelgreen9754 ปีที่แล้ว

    At 11:42 how can we print that option on the terminal ???

  • @angelcastineira2561
    @angelcastineira2561 2 ปีที่แล้ว

    Thanks!

  • @Elias___
    @Elias___ ปีที่แล้ว

    How did you make the sub button go rainbow when you mentioned subscriptions

  • @seahawks8801
    @seahawks8801 3 ปีที่แล้ว

    Thanks man !

  • @crypticsios2254
    @crypticsios2254 หลายเดือนก่อน

    what is the real life application of JAVA panels, frames? the features are useful but i dont get how it can be implemented

  • @danijelmomcilovic3794
    @danijelmomcilovic3794 3 ปีที่แล้ว

    if u want play again option u can add this code in xWins and oWins, dont need to run program again :D
    int option=JOptionPane.showConfirmDialog(null, "Wanna play again?","Tic-Tac-Toe", JOptionPane.YES_NO_CANCEL_OPTION);
    if (option==JOptionPane.YES_OPTION) {
    frame.dispose();
    new Game();
    }
    if (option==JOptionPane.NO_OPTION || option==JOptionPane.CANCEL_OPTION) {
    System.exit(0);
    }

  • @TrueBlueCams
    @TrueBlueCams ปีที่แล้ว

    thanks

  • @nawfalnjm5699
    @nawfalnjm5699 3 ปีที่แล้ว

    thank you

  • @joelmarkjmj
    @joelmarkjmj 2 ปีที่แล้ว

    TQ

  • @puppylili
    @puppylili 3 ปีที่แล้ว +1

    How do you get rid of the focus on the buttons in JOptionPanes? that rectangular box around the text is very annoying, thanks.

    • @andreaderito7871
      @andreaderito7871 3 ปีที่แล้ว +3

      For example you can create an array of JButtons instead of an array of Strings and you can use the setFocusable(false) method for each button. Finally, remember to pass null to the last parameter of the showOptionDialog.

  • @mcflurry324
    @mcflurry324 2 ปีที่แล้ว

    thankss

  • @runeknight2842
    @runeknight2842 8 หลายเดือนก่อน

    How can display or have a showMessageDialog respond to my input, however, i also want it to continuously accept input and showinputdialog again, a while loop until i put “stop”

  • @VersatileMC
    @VersatileMC ปีที่แล้ว

    What is the size of that smile icon?

  • @rachelgreen9754
    @rachelgreen9754 ปีที่แล้ว

    At 6:48 , instead of printing a integer on the terminal, how can we print the selected option like string " yes "
    @BroCode

    • @naomicolombiaamayalovett4744
      @naomicolombiaamayalovett4744 ปีที่แล้ว

      no this has never been attempted before. Good luck

    • @fax6720
      @fax6720 ปีที่แล้ว

      Below int answer = JOptionPane.showConfirmDialog ,
      you can use if else condition instead like this:
      if (answer == 0) {
      System.out.println("Yes");
      } else if (answer == 1) {
      System.out.println("No");
      } else if (answer == 2) {
      System.out.println("Cancel");
      }

    • @axilprashunsrivastava3649
      @axilprashunsrivastava3649 11 หลายเดือนก่อน

      this can be done by using if else statement

  • @Abyss_Enjoyer
    @Abyss_Enjoyer 4 หลายเดือนก่อน

    I can't use JOptionPane despite having downloaded jdk 22 and included it in my project, can someone tell me what might have been the problem? Thank you!

  • @jeevithabhoomireddy7261
    @jeevithabhoomireddy7261 3 ปีที่แล้ว

    Hi, I deployed application in one server and trying to access application in another server(through diff machine) .What i observed is dialog box is showing in the same server where i deployed not in the testing server

  • @spongybfdi8876
    @spongybfdi8876 4 หลายเดือนก่อน

    👽🐸

  • @alexshepel5599
    @alexshepel5599 4 ปีที่แล้ว

    Nice, bro?

  • @duplaTraquina
    @duplaTraquina ปีที่แล้ว

    where do you find the icons you use?

  • @sandramaesantos23
    @sandramaesantos23 3 ปีที่แล้ว +1

    What eclipse do you use? I tried to download it and it just gave me a lot to choose from and I don't know which is which.

  • @toughraf8400
    @toughraf8400 3 ปีที่แล้ว +1

    Bro how do you get out of that while loop? I am stuck.

    • @u0_a647
      @u0_a647 3 ปีที่แล้ว +2

      stop the java program from your ide

  • @joaquingutierrez7296
    @joaquingutierrez7296 3 ปีที่แล้ว +1

    How can i custom font style of JOptionPane Title?

    • @sushantpatil7950
      @sushantpatil7950 3 ปีที่แล้ว +1

      Yes I also want to know ?? Does anyone know ??

  • @adekunleibrahim8400
    @adekunleibrahim8400 ปีที่แล้ว

    The image icon covered all my screen when I ran the code

  • @varunpatel8789
    @varunpatel8789 4 ปีที่แล้ว

    how do u get small icons i can not find them anywhere

  • @nocontextvic6195
    @nocontextvic6195 3 ปีที่แล้ว

    How did you get this icon? I tried to do the same thing on Intellij, but the icon doesn't show up

    • @ssrot4352
      @ssrot4352 3 ปีที่แล้ว

      you need to copy paste the icon folder into your intellij source folder

    • @briman113
      @briman113 2 ปีที่แล้ว

      Try this:
      ImageIcon icon = new ImageIcon(myClassName.class.getResource("/smiley.png"));

  • @Abhi-go7vg
    @Abhi-go7vg 3 ปีที่แล้ว

    Bro how to change the size ?

  • @Kaleullo
    @Kaleullo ปีที่แล้ว

    Bro!

  • @sharalnaja9437
    @sharalnaja9437 4 ปีที่แล้ว +1

    eclipse: u r awesome!
    bro: no
    eclipse: :(
    me: he is not awesome. he is a lifesaviourforabeginnerprogrammerlikemeandiwatchhisvideosformyeducationpurposesanditisgreat

  • @SlothfulSage285
    @SlothfulSage285 ปีที่แล้ว

    Drop a comment

  • @lroadzl1288
    @lroadzl1288 2 ปีที่แล้ว

    trolling my friends with this lol

  • @sandeepjadli3941
    @sandeepjadli3941 4 ปีที่แล้ว +1

    hey bro can I get code, just for academic purpose.

    • @BroCodez
      @BroCodez  4 ปีที่แล้ว

      //whoops! I forgot to post the code lol
      import javax.swing.ImageIcon;
      import javax.swing.JOptionPane;
      public class Main{
      public static void main(String[] args) {

      //JOptionPane = pop up a standard dialog box that prompts users for a value
      // or informs them of something.

      //JOptionPane.showMessageDialog(null, "This is a message dialog box", "title", JOptionPane.PLAIN_MESSAGE);
      //JOptionPane.showMessageDialog(null, "Here is some useless info", "title", JOptionPane.INFORMATION_MESSAGE);
      //JOptionPane.showMessageDialog(null, "really?", "title", JOptionPane.QUESTION_MESSAGE);
      //JOptionPane.showMessageDialog(null, "Your computer has a VIRUS!", "title", JOptionPane.WARNING_MESSAGE);
      //JOptionPane.showMessageDialog(null, "CALL TECH SUPPORT OR ELSE!", "title", JOptionPane.ERROR_MESSAGE);


      //int answer = JOptionPane.showConfirmDialog(null, "bro, do you even code?");
      //String name = JOptionPane.showInputDialog("What is your name?: ");

      ImageIcon icon = new ImageIcon("smile.png");
      String[] responses = {"No, you are!","thank you!","*blush*"};
      int answer = JOptionPane.showOptionDialog(
      null,
      "You are the best! :D",
      "Secret message",
      JOptionPane.DEFAULT_OPTION,
      0,
      icon,
      responses,
      responses[0]);
      System.out.println(answer);

      }
      }

    • @u0_a647
      @u0_a647 3 ปีที่แล้ว

      @@BroCodez you forgor

  • @Table_y
    @Table_y ปีที่แล้ว

    Bro

  • @nqobamkhaliphi503
    @nqobamkhaliphi503 2 ปีที่แล้ว

    Broooo

  • @greeneggsandmushrooms9855
    @greeneggsandmushrooms9855 3 ปีที่แล้ว

    too many options can be a pane

  • @veeqqa
    @veeqqa ปีที่แล้ว

    Exception in thread "main" java.lang.Error: Unresolved compilation problem:
    at myfirstprogram.Main.main
    (why????)

  • @soumelee5661
    @soumelee5661 2 ปีที่แล้ว

  • @eugenezuev7349
    @eugenezuev7349 8 หลายเดือนก่อน

  • @الدينمحيىالشرف
    @الدينمحيىالشرف 2 ปีที่แล้ว +1

    Thank you

  • @mXdcloud-kt9qo
    @mXdcloud-kt9qo 10 หลายเดือนก่อน

    thanks bro

  • @abhayshaji3744
    @abhayshaji3744 3 ปีที่แล้ว

    Thanks man !

  • @Monsta1291
    @Monsta1291 2 ปีที่แล้ว

    random comment for youtube's algorithm

  • @SLURPZZZ4461
    @SLURPZZZ4461 ปีที่แล้ว