Java login system 👨‍💻

Sdílet
Vložit

Komentáře • 269

  • @BroCodez
    @BroCodez  Před 4 lety +224

    //****************************************************
    public class Main {
    public static void main(String[] args) {

    IDandPasswords idandPasswords = new IDandPasswords();

    LoginPage loginPage = new LoginPage(idandPasswords.getLoginInfo());
    }
    }
    //****************************************************
    public class IDandPasswords {
    HashMap logininfo = new HashMap();

    IDandPasswords(){

    logininfo.put("Bro","pizza");
    logininfo.put("Brometheus","PASSWORD");
    logininfo.put("BroCode","abc123");
    }

    public HashMap getLoginInfo(){
    return logininfo;
    }
    }
    //****************************************************
    import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    import javax.swing.*;
    public class LoginPage implements ActionListener{

    JFrame frame = new JFrame();
    JButton loginButton = new JButton("Login");
    JButton resetButton = new JButton("Reset");
    JTextField userIDField = new JTextField();
    JPasswordField userPasswordField = new JPasswordField();
    JLabel userIDLabel = new JLabel("userID:");
    JLabel userPasswordLabel = new JLabel("password:");
    JLabel messageLabel = new JLabel();
    HashMap logininfo = new HashMap();

    LoginPage(HashMap loginInfoOriginal){

    logininfo = loginInfoOriginal;

    userIDLabel.setBounds(50,100,75,25);
    userPasswordLabel.setBounds(50,150,75,25);

    messageLabel.setBounds(125,250,250,35);
    messageLabel.setFont(new Font(null,Font.ITALIC,25));

    userIDField.setBounds(125,100,200,25);
    userPasswordField.setBounds(125,150,200,25);

    loginButton.setBounds(125,200,100,25);
    loginButton.setFocusable(false);
    loginButton.addActionListener(this);

    resetButton.setBounds(225,200,100,25);
    resetButton.setFocusable(false);
    resetButton.addActionListener(this);

    frame.add(userIDLabel);
    frame.add(userPasswordLabel);
    frame.add(messageLabel);
    frame.add(userIDField);
    frame.add(userPasswordField);
    frame.add(loginButton);
    frame.add(resetButton);
    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()==resetButton) {
    userIDField.setText("");
    userPasswordField.setText("");
    }

    if(e.getSource()==loginButton) {

    String userID = userIDField.getText();
    String password = String.valueOf(userPasswordField.getPassword());

    if(logininfo.containsKey(userID)) {
    if(logininfo.get(userID).equals(password)) {
    messageLabel.setForeground(Color.green);
    messageLabel.setText("Login successful");
    frame.dispose();
    WelcomePage welcomePage = new WelcomePage(userID);
    }
    else {
    messageLabel.setForeground(Color.red);
    messageLabel.setText("Wrong password");
    }
    }
    else {
    messageLabel.setForeground(Color.red);
    messageLabel.setText("username not found");
    }
    }
    }
    }
    //****************************************************
    import java.awt.*;
    import javax.swing.*;
    public class WelcomePage {
    JFrame frame = new JFrame();
    JLabel welcomeLabel = new JLabel("Hello!");

    WelcomePage(String userID){

    welcomeLabel.setBounds(0,0,200,35);
    welcomeLabel.setFont(new Font(null,Font.PLAIN,25));
    welcomeLabel.setText("Hello "+userID);

    frame.add(welcomeLabel);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setSize(420, 420);
    frame.setLayout(null);
    frame.setVisible(true);
    }
    }
    //****************************************************

    • @samaltoveros4231
      @samaltoveros4231 Před 3 lety +2

      How did you make the pasword like only dots?

    • @jalen744
      @jalen744 Před 3 lety +4

      @@samaltoveros4231it's JPasswordField. it does that

    • @ZbumDemon
      @ZbumDemon Před 2 lety +2

      Missing in "IDandPasswords" in top " import java.until.HashMap; "

    • @joyceasante8292
      @joyceasante8292 Před rokem

      Practicing(no copying and pasting)
      public class Main
      {
      public static void main (String[]args)
      {
      IDandPasswords idandPasswords = new IDandPasswords ();
      LoginPage loginPage = new LoginPage (idandPasswords.getLoginInfo ());
      }
      }
      *******************
      import java.util.HashMap;
      public class IDandPasswords
      {
      HashMap < String, String > logininfo = new HashMap < String, String > ();
      IDandPasswords ()
      {
      logininfo.put ("GlamorousCoder", "spicy");
      logininfo.put ("Faya", "POPPING");
      logininfo.put ("Ras", "berry809");
      }
      protected HashMap getLoginInfo ()
      {
      return logininfo;
      }
      }
      **********************
      import java.awt.*;
      import java.awt.event.*;
      import java.util.HashMap;
      import javax.swing.*;
      public class LoginPage implements ActionListener
      {
      JFrame frame = new JFrame ();
      JButton loginButton = new JButton ("Login");
      JButton resetButton = new JButton ("Reset");
      JTextField userIDField = new JTextField ();
      JPasswordField userPasswordField = new JPasswordField ();
      JLabel userIDLabel = new JLabel ("userID: ");
      JLabel userPasswordLabel = new JLabel ("password: ");
      JLabel messageLabel = new JLabel (" ");
      HashMap < String, String > logininfo = new HashMap < String, String > ();
      LoginPage (HashMap < String, String > loginInfoOriginal)
      {
      logininfo = loginInfoOriginal;
      userIDLabel.setBounds (50, 100, 75, 25);
      userPasswordLabel.setBounds (50, 150, 75, 25);
      messageLabel.setBounds (125, 250, 250, 35);
      messageLabel.setFont (new Font (null, Font.PLAIN, 12));
      userIDField.setBounds (125, 100, 200, 25);
      userPasswordField.setBounds (125, 150, 200, 25);
      loginButton.setBounds (125, 200, 100, 25);
      loginButton.setFocusable (false);
      loginButton.addActionListener (this);
      resetButton.setBounds (225, 200, 100, 25);
      resetButton.setFocusable (false);
      resetButton.addActionListener (this);
      frame.add (userIDLabel);
      frame.add (userPasswordLabel);
      frame.add (messageLabel);
      frame.add (userIDField);
      frame.add (userPasswordField);
      frame.add (loginButton);
      frame.add (resetButton);
      frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
      frame.setSize (380, 380);
      frame.setLayout (null);
      frame.setVisible (true);
      }
      @Override public void actionPerformed (ActionEvent e)
      {
      if (e.getSource () == resetButton)
      {
      userIDField.setText ("");
      userPasswordField.setText ("");
      }
      if (e.getSource () == loginButton)
      {
      String userID = userIDField.getText ();
      String password = String.valueOf (userPasswordField.getPassword ());
      if (logininfo.containsKey (userID))
      {
      if (logininfo.get (userID).equals (password))
      {
      messageLabel.setForeground (Color.green);
      messageLabel.setText ("login successful");
      frame.dispose ();
      WelcomePage welcomePage = new WelcomePage ("Welcome!");
      }
      else
      {
      messageLabel.setForeground (Color.blue);
      messageLabel.setText ("Wrong password");
      }
      }
      else
      {
      messageLabel.setForeground (Color.blue);
      messageLabel.setText ("username not found");
      }
      }
      }
      }
      *****************
      import java.awt.*;
      import javax.swing.*;
      public class WelcomePage
      {
      JFrame frame = new JFrame ();
      JLabel welcomeLabel = new JLabel ("Welcome!");
      WelcomePage (String userID)
      {
      welcomeLabel.setBounds (0, 0, 200, 35);
      welcomeLabel.setFont (new Font (null, Font.BOLD, 18));
      welcomeLabel.setText ("Welcome" + userID);
      frame.add (welcomeLabel);
      frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
      frame.setSize (380, 380);
      frame.setLayout (null);
      frame.setVisible (true);
      }
      }

    • @akhilmasanam1692
      @akhilmasanam1692 Před 11 měsíci +1

      protected to public

  • @michaeledie8474
    @michaeledie8474 Před 2 lety +51

    you are more useful than any of my university professors

  • @petermwajinje6417
    @petermwajinje6417 Před 2 lety +48

    It's a great video well and clearly explained. As a Java beginner, it has saved me time and the headache I could have gone through in class. Thank a lot. I wish if you could do a video of the same but with a connection to MySQL database where the IDs and passwords would be store in the database.

  • @Re9sTwitch
    @Re9sTwitch Před 3 lety +20

    Another great vid, very clear, well explained. Would be great to learn how you develop this code from scratch.
    Thanks again, keep up the great work!

  • @damiaofernandes9776
    @damiaofernandes9776 Před 2 lety +1

    Muito bom que conteúdo Exemplar, que bacana e leve o jeito de fazer e explicar embora não entenda nada do que diz . Tá de parabéns Obrigado por compartilhar o seu conhecimento 👏

  • @angelcastineira2561
    @angelcastineira2561 Před 4 lety +4

    your videos are getting better and better, this one helped me understand a lot better some previous concepts. thanks!

  • @antoniolima1456
    @antoniolima1456 Před 2 lety +11

    O cara é magnifico, um vídeo bem explicativo e muito bem feito.
    Thanks

  • @amandatimmons5915
    @amandatimmons5915 Před 2 lety +6

    I watched this video a thousand times this weekend and it helped me do and understand my homework assignment. thank you so much for such a good step by step video with explanations that are clear and easier to understand.

    • @dcwavie
      @dcwavie Před rokem

      yall doing this for assignments lol tuff imagine doing it in class and mispellng HashMap by mistake.

  • @primeoptumas8435
    @primeoptumas8435 Před 3 lety

    Thanks for such a wonderful video lecture😍.

  • @adibkhan8332
    @adibkhan8332 Před 3 lety +2

    My recent favorite CZcamsr... Love from🇧🇩

  • @WhoBeSilly
    @WhoBeSilly Před 7 měsíci

    Thanks bud, it brings me back to my CSc labs in college!

  • @gabrielantoniosaavedramart8109

    Amazing explain and session of coding

  • @mrCetus
    @mrCetus Před 2 lety +1

    Hey Bro Code, thank You so much for dedicating the time to put this video together. It truly helped me to understand this new concept of Java for me.

  • @lalitpal6797
    @lalitpal6797 Před rokem +1

    Awesome I like the explanation

  • @hariom6910
    @hariom6910 Před 3 lety

    Please do as many projects as possible sir..Loved Your Concept..❤️ from india

  • @andromydous
    @andromydous Před 2 lety +7

    First, I'm so glad that I found your channel. I started messing with Java because I understand it better than my wife and she's leaning on me to help her with her college class. She's sitting at a B, because she suffers test anxiety and doesn't really put in the work. Her final project is using 2D arrays and it bugs me because her class is so slow. I learned so much more by watching your videos and I've only been learning for less than a month.
    Second, I created a rudimentary RPG text based console game (complete with main menu, shop menu, inventory for shop and player, player classes, enemies, and enemy classes, combat engine, and combat menu). What I learned from you helped tremendously. I mostly did it on my own, but there were a few times that I had to google something. While googling, I ran into 2 scenarios that irked me. Which leads me to number 3 (last one).
    Third, I ran into lazy people basically expecting others to do their work for them (almost like my wife) and elitist MF's. The lazy people only bothered me a little. In the end, they're only hurting themselves. Elitists, though. Those people piss me off. Nobody is born with all the knowledge and all the skills. No one is born at the top of their field. Everyone starts at the bottom/beginning at some point. Elitist either forget that, or they like to pretend that they skipped that part and became a god at whatever it is that they're doing. This mentality hurts other people and can even turn them away.
    Plus they seem that everyone can read the docs (or man pages) and automatically understand it. However, everybody learns differently. Me, I learn by doing. I can read stuff all day long, or listen to someone all day long, and I'll never understand it. I have to do it for it to stick in my mind. Sorry for being long winded. Thanks, again, for doing these awesome videos.

    • @makramziani2507
      @makramziani2507 Před 2 lety +4

      bro i would hate to be your wife u bad mouth her way too much if it bothers u that she is lazy why did u marry her love her for who she is or dont waste her time

    • @andromydous
      @andromydous Před 2 lety

      @@makramziani2507 Where did you learn to read? The only "negative" thing I said is that instead of her practicing, she looks to me to do it for her. If you're in school to learn something, especially if it relates to your chosen field, you should put the work in. That's not being negative. That's just facts. Besides, I could care less what you think.

    • @makramziani2507
      @makramziani2507 Před 2 lety +3

      @@andromydous ok habibi it might be facts that should be kept between you and her you can’t just go running around telling ppl how lazy your wife you might actually be one of the reasons she is lazy because you keep criticizing her you gotta be more supportive I am not tryna judge you or bad mouth you just an advice if you hate hearing this imagine her hating you hear she is lazy from you 🙄

    • @andromydous
      @andromydous Před 2 lety

      @@makramziani2507 Whatever, dude. Her and I have been married 22 years. I don't have to explain myself to you. If you can't read, then go get some help.

    • @sacmarv8997
      @sacmarv8997 Před 2 lety

      @@andromydous you r married for 22yrs and ur wife is still in college 😟

  • @amedeekreuzer9190
    @amedeekreuzer9190 Před rokem +1

    Thank you Bro Code, it all went very well and I could understand most of the code lines that you ecplained logically. Thank you very much!

  • @justinbanza4751
    @justinbanza4751 Před 2 lety

    very clear and helpful.
    Thank you for that video

  • @y.bgamesplayer
    @y.bgamesplayer Před 3 lety +2

    Wow I got some idea from your work Thank you

  • @radosmirkovic8371
    @radosmirkovic8371 Před 7 měsíci

    Great tutorial. Keep on with the good work.

  • @elsaeelias8159
    @elsaeelias8159 Před 2 lety

    It is very interesting to learn to catch concept of develop design; I expect another better video from you,thank you so much.

  • @FilipeProKiller
    @FilipeProKiller Před 2 lety

    Thank you so much for this man, easy to follow and undestand

  • @developerjunior446
    @developerjunior446 Před 3 lety +2

    Super,simple,interesting

  • @chitandaiscurious4597
    @chitandaiscurious4597 Před 2 lety

    this is so much helpful

  • @joshuaraymond4996
    @joshuaraymond4996 Před 2 lety

    Thank you for this amazin class

  • @Bianchi77
    @Bianchi77 Před rokem

    Nice video, well done, thank you for sharing it :)

  • @rorydaines3176
    @rorydaines3176 Před 3 lety +4

    Please do one where you mentioned, grabbing user login info from a file that was stored on a db, that would be dope my bro.

  • @azro7717
    @azro7717 Před 2 lety +1

    As Java beginner, I've finished this after days of trying to understand 😁

  • @DC-xj2fe
    @DC-xj2fe Před 2 lety

    Very helpful for Revature's Java course week 3 project 1 work.

  • @user-mi1rw3lb1z
    @user-mi1rw3lb1z Před 4 měsíci

    Thank you very much ! Simple & easy and solved my pin point problems.

  • @stealthseeker18
    @stealthseeker18 Před 4 lety +5

    I hope you will create a tutorial about JavaDesignPattern or Android in your next video. Than you! :)

  • @lahikahmed9253
    @lahikahmed9253 Před 10 měsíci

    Thanks for your awesome content ❤

  • @LuisFernando-qm5cs
    @LuisFernando-qm5cs Před 2 lety

    bro, thanks a lot, you showed an easier way to make the same thing comparing to the way that i was doing

  • @Lileminem93
    @Lileminem93 Před 2 lety

    Awesome tutorial!
    Thank you Bro!

  • @365motivation.9
    @365motivation.9 Před rokem

    Hello Bro
    I learned alot from your tutorials.

  • @hakanloyan3483
    @hakanloyan3483 Před 4 měsíci

    i added the back and exit buttons to welcome page easily, thx for video

  • @enricoarcilla1095
    @enricoarcilla1095 Před 2 lety

    very helpful for a beginners.

  • @KangOdy
    @KangOdy Před rokem

    thank you so much, after watching your videos I more interesting to practice Java .... Cheers

  • @milanincana6395
    @milanincana6395 Před 2 lety

    This was most of my school assignment, thanks.

  • @naguboyinachaitanya234
    @naguboyinachaitanya234 Před 8 měsíci +1

    Great Explanation BRo

  • @canberkarslan998
    @canberkarslan998 Před 3 lety +3

    İt is very helpful. Thank you so much!

  • @yourtimepass1671
    @yourtimepass1671 Před rokem

    All time best coding video Ever 🌟

  • @user-zv2iw1lw4m
    @user-zv2iw1lw4m Před 2 lety

    Bro Code, you are such a genius!

  • @mosomiliardaru
    @mosomiliardaru Před rokem

    this is a real chad. I hope to meet you one day, mr. bro

  • @gurkan8843
    @gurkan8843 Před rokem

    i love your videos brooo
    your videos are so clear and short, essential

  • @Una_Eeu
    @Una_Eeu Před rokem

    This video is so helpful. Thank you.

  • @hasirakoswatta386
    @hasirakoswatta386 Před 3 lety

    Thank You BroCode. Helped me alot!

  • @abuhamza6817
    @abuhamza6817 Před 5 měsíci

    Thanks bro, this is so informative

  • @smp2k252
    @smp2k252 Před 2 lety

    your videos are soo helpful love from pakistan

  • @sergeyb6071
    @sergeyb6071 Před 4 lety +2

    great stuff!

  • @andrasfejes8988
    @andrasfejes8988 Před rokem

    Thank you! Simply but awesome!

  • @iwandamiri1002
    @iwandamiri1002 Před 3 lety

    Thank you, this is helping me a lot

  • @Isotope-15
    @Isotope-15 Před 29 dny

    Thank you so much. This video helped solidify a lot of loose knowledge I had in Java. Keep it up

  • @tuba_codes
    @tuba_codes Před 2 lety

    That's true.. I enjoyed so much while wathcing this video. You expalained so well that I got it all ... Thankssssssss 🙃

  • @augischadiegils.5109
    @augischadiegils.5109 Před 3 lety +3

    Make more tutorial bro thanks! :)

  • @eason6522
    @eason6522 Před 8 měsíci

    Thank you so much, you saved my life, by the way I love that there is a D&D file just chilling there

  • @CarlosHernandez-zy9fq
    @CarlosHernandez-zy9fq Před 2 lety

    Thank you so much, this video is great!

  • @marxLz
    @marxLz Před 2 lety +2

    Do you also have idea in using oracle database? Please release a tutorial for that too. 😊

  • @charan8254
    @charan8254 Před rokem

    You are uploading videos are more useful for me 'Thanks Bro'
    can you upload how to connect with server our application videos

  • @sam_nov
    @sam_nov Před rokem

    Broo, thank you very much, this is exactly what I needed.

  • @samlaliag
    @samlaliag Před 2 měsíci

    Thank you so much for making this Video!!!!

  • @NHCS_AMOGH_PATIL
    @NHCS_AMOGH_PATIL Před 2 lety

    Bro Code You are really a great man
    Thank you

  • @dmitry_belonozhko
    @dmitry_belonozhko Před 2 lety

    Very nice. Thank you

  • @zeshrecords8630
    @zeshrecords8630 Před 2 lety

    Thanks Man it really helps me

  • @dhruvkaith3160
    @dhruvkaith3160 Před 3 lety

    Thanks really helped me out

  • @parthsuryavanshi2425
    @parthsuryavanshi2425 Před 2 lety

    Just here to complete the 2nd step you mentioned at the end

  • @ricardoreis4172
    @ricardoreis4172 Před 2 lety

    Excelent Bro

  • @ludovicbocquet9783
    @ludovicbocquet9783 Před 10 měsíci

    Really really good job, thank you !

  • @juliusmutegi5530
    @juliusmutegi5530 Před 2 lety

    great tutorial, thank you

  • @GenjaOrigins
    @GenjaOrigins Před 2 lety

    I wish i would know your channel much sooner. Damn youtube algorithm

  • @whitefang20
    @whitefang20 Před 2 lety

    Thankyou for the video!

  • @sheldor58
    @sheldor58 Před 3 lety +1

    could you make a continue. How to create a account in this system? thanks for the nice tutorial

  • @OnePieceDose
    @OnePieceDose Před 3 lety

    Thank you, helped me a lot. You saved my grades. hahah

  • @user-a554
    @user-a554 Před 2 lety

    just what I needed, and it worked. thanks bro!!

  • @mohamedalaa5270
    @mohamedalaa5270 Před 3 lety +1

    awesome

  • @uclong1176
    @uclong1176 Před 2 lety

    I love your video

  • @eliwolford08
    @eliwolford08 Před 3 lety +2

    I was typing along with you till I realized you had the code below! LOL Thank you so much!

    • @manjulgautam7040
      @manjulgautam7040 Před 2 lety

      so read the comment first LOL!

    • @stephanieezat-panah7750
      @stephanieezat-panah7750 Před 2 lety

      Actually, Elizabeth, you did the right thing. typing code sets it in your head, and that is the important thing

  • @acknowledgeme4510
    @acknowledgeme4510 Před 4 lety +7

    rly interesting thank you.
    it would be nice to do it with a database (could you do it ?)

    • @BroCodez
      @BroCodez  Před 4 lety +13

      Yeah maybe for a future video. It gets complex

  • @u12blue
    @u12blue Před 2 lety

    Wouldve loved it if you included user creation instead of it being already stated inside the code. But still great vid!

  • @mohamedmire8646
    @mohamedmire8646 Před 2 lety

    Amazing

  • @chiyuzhang3089
    @chiyuzhang3089 Před rokem

    thanks Bro! it really helps me a lot!

  • @omkarpatil9886
    @omkarpatil9886 Před 3 lety +2

    Your voice is gooood❤️

  • @crackrokmccaib
    @crackrokmccaib Před 2 lety

    I have to know, when you make these videos for practical applications, do you just do them on the fly, or do you make them ahead of time, then troubleshoot them and get them perfected before making the tutorials?

  • @kemann3815
    @kemann3815 Před 2 lety

    Awesome

  • @ITATheshark
    @ITATheshark Před 3 lety

    gggoood job man

  • @otabektillavayev3309
    @otabektillavayev3309 Před 2 lety

    You very good person

  • @meryameddaif4951
    @meryameddaif4951 Před rokem +1

    i just love you Bro 💖💖

  • @nehalayaaz9406
    @nehalayaaz9406 Před 4 lety +1

    Thanks 😊

  • @Jayakrishnan-wg6pp
    @Jayakrishnan-wg6pp Před rokem +1

    Nicee

  • @ssela
    @ssela Před 3 lety +1

    If you can put source code on Github or somewhere it will be great... It look so messy on CZcams comment. 😆 Thanks you for tutorial it really help me a lot.

  • @mjc7172
    @mjc7172 Před 3 lety

    youre the best

  • @dawidkaczka3606
    @dawidkaczka3606 Před 11 měsíci

    Very nice :D

  • @khadijakennou8064
    @khadijakennou8064 Před měsícem

    the best bro ever

  • @mdabdurrakib6965
    @mdabdurrakib6965 Před 2 lety

    Thank you dear sir

  • @veramay9035
    @veramay9035 Před 8 měsíci

    amazing!

  • @janaafc3120
    @janaafc3120 Před 2 lety +1

    super

  • @gRIZZly2003
    @gRIZZly2003 Před rokem

    THANksss again bro!!!!

  • @lubaeremenko6019
    @lubaeremenko6019 Před 3 lety

    Thanks a million, bro

  • @scieropia
    @scieropia Před 3 lety

    Thanks a lot Bro

  • @malakjaber1692
    @malakjaber1692 Před 2 lety

    Thanks a lot could you do it again but with a database