Java Eclipse GUI Tutorial 2 # Creating A Simple Calculator Using JFrame

Поділитися
Вставка
  • Опубліковано 19 вер 2024
  • ★★★Top Online Courses From ProgrammingKnowledge ★★★
    Python Programming Course ➡️ bit.ly/2vsuMaS ⚫️ bit.ly/2GOaeQB
    Java Programming Course ➡️ bit.ly/2GEfQMf ⚫️ bit.ly/2Vvjy4a
    Bash Shell Scripting Course ➡️ bit.ly/2DBVF0C ⚫️ bit.ly/2UM06vF
    Linux Command Line Tutorials ➡️ bit.ly/2IXuil0 ⚫️ bit.ly/2IXukt8
    C Programming Course ➡️ bit.ly/2GQCiD1 ⚫️ bit.ly/2ZGN6ej
    C++ Programming Course ➡️ bit.ly/2V4oEVJ ⚫️ bit.ly/2XMvqMs
    PHP Programming Course ➡️ bit.ly/2XP71WH ⚫️ bit.ly/2vs3od6
    Android Development Course ➡️ bit.ly/2UHih5H ⚫️ bit.ly/2IMhVci
    C# Programming Course ➡️ bit.ly/2Vr7HEl ⚫️ bit.ly/2W6RXTU
    JavaFx Programming Course ➡️ bit.ly/2XMvZWA ⚫️ bit.ly/2V2CoAi
    NodeJs Programming Course ➡️ bit.ly/2GPg7gA ⚫️ bit.ly/2GQYTQ2
    Jenkins Course For Developers and DevOps ➡️ bit.ly/2Wd4l4W ⚫️ bit.ly/2J1B1ug
    Scala Programming Tutorial Course ➡️ bit.ly/2PysyA4 ⚫️ bit.ly/2PCaVj2
    Bootstrap Responsive Web Design Tutorial ➡️ bit.ly/2DFQ2yC ⚫️ bit.ly/2VoJWwH
    MongoDB Tutorial Course ➡️ bit.ly/2LaCJfP ⚫️ bit.ly/2WaI7Ap
    QT C++ GUI Tutorial For Beginners ➡️ bit.ly/2vwqHSZ
    ★★★ Online Courses to learn ★★★
    Get 2 FREE Months of Unlimited Classes from skillshare - skillshare.eqc...
    Data Science - bit.ly/2lD9h5L | bit.ly/2lI8wIl
    Machine Learning - bit.ly/2WGGQpb | bit.ly/2GghLXX
    Artificial Intelligence - bit.ly/2lYqaYx | bit.ly/2NmaPya
    MERN Stack E-Degree Program - bit.ly/2kx2NFe | bit.ly/2lWj4no
    DevOps E-degree - bit.ly/2k1PwUQ | bit.ly/2k8Ypfy
    Data Analytics with R - bit.ly/2lBKqz8 | bit.ly/2lAjos3
    AWS Certification Training - bit.ly/2kmLtTu | bit.ly/2lAkQL1
    Projects in Java - bit.ly/2kzn25d | bit.ly/2lBMffs
    Machine Learning With TensorFlow - bit.ly/2m1z3AF | bit.ly/2lBMhnA
    Angular 8 - Complete Essential Guide - bit.ly/2lYvYRP
    Kotlin Android Development Masterclass - bit.ly/2GcblsI
    Learn iOS Programming Building Advance Projects - bit.ly/2kyX7ue
    ★★★ Follow ★★★
    My Website - www.codebind.com
    DISCLAIMER: This video and description contains affiliate links, which means that if you click on one of the product links, I’ll receive a small commission. This help support the channel and allows us to continue to make videos like this. Thank you for the support!
    java program to create a simple calculator
    simple calculator program in java
    how to make a simple calculator
    Java Programming | Creating a Simple Calculator
    how to make simple calculator in java
    how to create a simple calculator in java
    Simple Calculator Example Program - Java
    Basic Calculator Using OOP - Java
    Need To Create Simple Calculator Using Do While
    Simple Calculator Code In Java - Need Help Please
    Creating A GUI Calculator In Java - Java

КОМЕНТАРІ • 115

  • @sturanovicms
    @sturanovicms 4 роки тому +11

    Simple tasks but you go through everything! Thank you, you've explained it better than my university professor.

  • @owlman7053
    @owlman7053 9 років тому +5

    Thank You, Simple yet complete description.
    I implemented multiply and division by learning basics from video.

  • @CarsonCameronClark
    @CarsonCameronClark 9 років тому +13

    Awesome tutorials man, seriously great work. They are very clear and easy to follow but my one recommendation would be for you to speed things up a little. These videos do feel a little slow which makes it hard to stay focused. This 13 minute video could have been nearly cut in half, but regardless.. thank you for your efforts.

    • @pwings01
      @pwings01 9 років тому +2

      +Carson Clark you can also speed up video

    • @gamereplayhq
      @gamereplayhq 8 років тому

      +Julio M LoL yea seriously, i watch this video at 1.5 X Speed, and its quite fine the way he explains each detail

    • @ukasztaraa2585
      @ukasztaraa2585 8 років тому

      +Carson Clark now the speed is now a problem as UA-cam has an "accelerate" function :D

  • @justinvaughn8166
    @justinvaughn8166 9 років тому

    I was a little skeptical about the "design" part of your GUI. I wish it would have been coded instead. However, you really helped me out and the coding side so it all worked out! Good video. +1

  • @ProgrammingKnowledge
    @ProgrammingKnowledge  10 років тому +3

  • @pasadena195
    @pasadena195 2 роки тому

    love u bro i managed to do my uni homework thanks to u!!!

  • @CB-xk4oz
    @CB-xk4oz 4 роки тому

    Thank you once again for making such a user friendly , easy to understand video. I was able to make my program work well with your tips.

  • @genedy9233
    @genedy9233 8 років тому +1

    Watching this video on 1.5x speed isn't enough. Also you can simply change integer to string by writing ""+ans. thanks for ur effort

  • @computerbolter4079
    @computerbolter4079 6 років тому

    Thanks Sir, I'm Following You Since A Month And You Have Helped Me Very Much.

  • @mjkong7094
    @mjkong7094 9 років тому +2

    it‘s a good example for us new learners.

  • @violeta4558
    @violeta4558 5 років тому +1

    Exelent tutorial. But how we can create executable file which will be set to another computer and so will functional?

  • @qaziaziz197
    @qaziaziz197 7 років тому

    Great step by step, easy for beginners.

  • @alankuo2316
    @alankuo2316 5 років тому

    11:50 the line 93 show error not because of line 73,it is because line 85's ActionEvent already using "e" , the reason of line 73 didnt have to change is because of line 64's ActionEvent used "arg0" .btw, thx for tutorial! nice video!!

  • @radhikatikone3731
    @radhikatikone3731 3 роки тому

    Can we use window builder swing in JavaFX project?....Is this similar or two different things... please help me I'm so confused between this.

  • @josephchotard
    @josephchotard 8 років тому

    Great tutorial. Very easy to follow as well as being interesting.

  • @TheKhan9191
    @TheKhan9191 9 років тому +1

    how we make calculator by coding not in button drag ????

  • @darksithmartin
    @darksithmartin 6 років тому

    hi this is great, are you able to help me with a slightly more complicated version of what you have here. example; i need to input about 8 variables (different headcount/hours) then calculate auto or by button the total capability to pick cartons depending on the KPI rate and length of shift done 7 .25hrs or 7.5hrs. 3 of the variable have a different KPI rate so they have separate calculations. so the program adds all the seperate calcs then totals the possible amount and hours used.

  • @jasminelatendresse6046
    @jasminelatendresse6046 8 років тому +7

    Good tutorial! How do you save it as an "app" on your computer though?

    • @mcracehd8436
      @mcracehd8436 8 років тому +8

      +Jasmine Latendresse if you are using eclipse, you can simply right click the class and go to export. Once done, you go into the Java folder, and choose Runnable Jar File. When you are in the next window, switch the launch configuration to the class name. and click finish (After setting save destination.) and then you will have a runnable java file where you saved it. open that, and the program runs. :)

    • @LukeNewcomb
      @LukeNewcomb 8 років тому

      What do you mean?

    • @mcracehd8436
      @mcracehd8436 8 років тому

      TheDestroyerPlays talking to me?

    • @LukeNewcomb
      @LukeNewcomb 8 років тому

      +McRaceHD It's okay never mind I got it

    • @christianhollinger2357
      @christianhollinger2357 6 років тому +3

      if you call it an "app", you don't deserve to live.

  • @EmilioLosa
    @EmilioLosa 9 років тому

    I really think your tutorial is fantastic and it can help me!!! thx.

  • @jinuit30
    @jinuit30 9 років тому

    I really appreciate all of you guys sharing your knowledge. Thanks
    Question though. Could you share how you got windows 8.1 on your VM? I wanted to do this, in order to test it before I went with it fully, but I can't find an iso.

  • @ruffryder756
    @ruffryder756 7 років тому

    Great video!! How do you add the Sqrt and POW function to it?

  • @rey6253
    @rey6253 10 років тому

    Good tutorial, but at the 12:24 sec i was not the same 'e' in different exceptions that caused the error, it was the same 'e' in ActionEvent argument and in the Exception argument...:D

  • @nabeelahmed9875
    @nabeelahmed9875 7 років тому

    i have added two more buttons of multiply and divide. now whenever i am calculating it is only giving exception and not performing the calculations. please help??

  • @rahulzirpe9284
    @rahulzirpe9284 7 років тому

    Code is executable but components of frame after executing are looking blur and not properly. please tell me the solution?

  • @drean3807
    @drean3807 6 років тому

    i have a question about JOptionPane.showMessageDialog.
    lets say there is a box and i press add while the box is empty then JOptionPane.showMessageDialog shows.
    is there a way to hide it ?

  • @sicktoaster
    @sicktoaster 8 років тому

    I notice that if I copy and paste the code from a class that has the "Source", "Design", and "Bindings" at the bottom of it those tabs do not then show up for the class I pasted it to. Is there a way to do that? To get "Source", "Design", and "Bindings" into a class that did not have them before. Besides copy/paste is there a new to create a new class that has them but is in the same package as another one that has them?
    Also now when I start a new Project and create a class in that project it does not include the tabs! The only way is to copy and paste the one I was able to make earlier. I wound up deleting one of these Projects when I realized I had made a mistake in it (don't remember the exact mistake), and the deletion seemed to go awry. There was some sort of error message. I think the gist of it was that some of it couldn't be deleted. Did I accidentally delete part of the Plug-In? The programs I already made and the ones I make by copying those programs and changing the code (directly or through the design tab) still work fine. One problem is that every single one of my copies has the same name, because I haven't figured out how to change a class's name or if it's even possible.

  • @asiyamahamoudabdi1235
    @asiyamahamoudabdi1235 5 років тому +1

    iwonna that code please send me if you can

  • @exxcus9314
    @exxcus9314 8 років тому

    Awesome information. Thankyou sir!

  • @williambryant1672
    @williambryant1672 9 років тому

    Great tutorials. Thanks

  • @geraldibra3635
    @geraldibra3635 8 років тому +6

    The Exception is "e" ?!....I don't get it...how does that work.

    • @TinniTales
      @TinniTales 8 років тому

      +Gerald 360Noscope its not important that u get exception e instead of e anything can b there...:)

    • @pavlg3944
      @pavlg3944 6 років тому

      Gerlad its the name of the exception

  • @nasywanmashud5367
    @nasywanmashud5367 7 років тому

    Good video sir!! but may i know what if my input n my answer is float? can u help me sir

  • @2mathnav282
    @2mathnav282 6 років тому

    u are really good and simple any one can understand u but man pls do it faster than that ;

  • @paavangupta3420
    @paavangupta3420 6 років тому

    Sir, can i use the java scene builder with netbeans along with your tutorials.

  • @lgx22
    @lgx22 6 років тому

    great job man. you are awesome!

  • @deaballgjati3601
    @deaballgjati3601 6 років тому

    Everytime I close eclipse, the windowbuilder gets uninstalled itself.I have to reinstall when i open the eclipse again. Can u help me please?

  • @BranislavGrbic
    @BranislavGrbic 9 років тому

    My calc is In, Out, Gross: and percentage, first calc is In-Out=Gross and that works fine, but i dont know how to wrote Gross/In*100 to get percentage. Every time i get 0.

  • @smakina1618
    @smakina1618 4 роки тому

    U ARE THE BEST THANK YOU SO MUCH REALLY

  • @ahsanchaudhary910
    @ahsanchaudhary910 4 роки тому

    I just installed eclipse and I installed a new software which is the window builder. When I tried to open the design page I get the error " Unknown GUI toolkit". Hopefully you guys can help me

  • @bluesigniter6118
    @bluesigniter6118 8 років тому

    Thanks man great tutorial

  • @monukumarmodi6551
    @monukumarmodi6551 5 років тому

    How can I convert this into an software so that I need not to open eclipse and run again and again . I just want that by double click the software should run.

  • @kevzmacalalag269
    @kevzmacalalag269 7 років тому

    what if i add both answers and output it in another jtextfield? how do i code this

  • @musicinc7851
    @musicinc7851 7 років тому +1

    i have.form files and java files. how to run those on eclipse. if you help me it will be giving new life to me

  • @computerbolter4079
    @computerbolter4079 6 років тому

    By The Way, Which Screen Recorder Do You Use???

  • @ayeshagujjar3791
    @ayeshagujjar3791 3 роки тому

    It was helpful

  • @aliengineer5458
    @aliengineer5458 8 років тому

    Thanks ..great tutorial

  • @muhammadahsaam5920
    @muhammadahsaam5920 5 років тому

    Nice video very helpfull thanks for uplooading

  • @AllmightC94
    @AllmightC94 4 роки тому

    for some reason the frame of the windows that we can see on the right side seems like if it was cut off, but whenever i play the program it seems normal, does anyone knows why is that?

  • @ousmanesangary658
    @ousmanesangary658 4 роки тому

    Did anyone notice wrong results in adding and subtracting??? I need help to this , why the answer is wrong after adding or substracting ??

  • @LeoCnoa
    @LeoCnoa 10 років тому

    Excelente tutorial

  • @yadhunandan5765
    @yadhunandan5765 7 років тому

    superb sir
    tq u saved me

  • @maheshjamdade1
    @maheshjamdade1 6 років тому

    hi what if I am creating a login system and I want the components (like text box button) to always centre the screen regardless of window size whethere fullscreen or small window always in centre How??

    • @AlexIstEinGott
      @AlexIstEinGott 6 років тому

      (windowWidth / 2) - (buttonWidth / 2)

  • @lakshmipriya8444
    @lakshmipriya8444 5 років тому

    Could you please help me to do a program with check box;

  • @anuragyadav9680
    @anuragyadav9680 Рік тому

    thanku

  • @JahidHasan-zl7om
    @JahidHasan-zl7om 5 років тому

    i got the output, but ans comes wrong, what can i do?

  • @musicandpoems4620
    @musicandpoems4620 6 років тому

    i wrote JoptionPane but it is showing an error and error is about create a class JoptionPane or a package ...and many more ..so what we can use instead of it?? please reply

    • @wizard-28
      @wizard-28 4 роки тому

      It is JOptionPane, 'O' is capital..

  • @nickmurdoch4890
    @nickmurdoch4890 6 років тому

    I keep getting an error on my (Exeption e) can anyone help me?

  • @tanayparmar3020
    @tanayparmar3020 6 років тому

    Sir mere me window builder encounter unexpected internal error aa rha he

  • @aakash4416
    @aakash4416 5 років тому

    This program are not working in netbean why?????

  • @arenlv
    @arenlv 8 років тому

    Help i cant drag the text box where i want there is only north west south and east and i cant resize the boxes too help!

    • @aname9806
      @aname9806 8 років тому

      +VisualWolf You will have to drag an absolute layout to the frame first. This way you're able to place it where you'd like. :)

    • @arenlv
      @arenlv 8 років тому

      thank you very much!

  • @patrickedwinmoran2966
    @patrickedwinmoran2966 6 років тому

    I have gone through the code and have found nothing that won't compile on the current Eclipse and Jave systems. Just in case any of you have made a typo you can't find, here is the code that works for me.
    import java.awt.EventQueue;
    import javax.swing.JFrame;
    import javax.swing.JTextField;
    import javax.swing.JButton;
    import javax.swing.JLabel;
    import javax.swing.JOptionPane;
    import java.awt.event.ActionListener;
    import java.awt.event.ActionEvent;
    public class Calc {
    private JFrame frame;
    private JTextField txtNum1;
    private JTextField txtNum2;
    private JButton btnSubtract;
    private JLabel lblAnswIs;
    private JTextField txtNum3;
    /**
    * Launch the application.
    */
    public static void main(String[] args) {
    EventQueue.invokeLater(new Runnable() {
    public void run() {
    try {
    Calc window = new Calc();
    window.frame.setVisible(true);
    } catch (Exception e) {
    e.printStackTrace();
    }
    }
    });
    }
    /**********
    * Create the application.
    **********/
    public Calc() {
    initialize();
    }
    /***********
    * Initialize the contents of the frame.
    ***********/
    private void initialize() {
    frame = new JFrame();
    frame.setBounds(100, 100, 645, 302);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.getContentPane().setLayout(null);
    txtNum1 = new JTextField();
    txtNum1.setText(""); //Don't fill anything in here so user doesn't have to erase it.
    txtNum1.setBounds(20, 21, 274, 26);
    frame.getContentPane().add(txtNum1);
    txtNum1.setColumns(10);
    txtNum2 = new JTextField();
    txtNum2.setText(""); //Don't fill anything in here so user doesn't have to erase it
    txtNum2.setBounds(318, 21, 274, 26);
    frame.getContentPane().add(txtNum2);
    txtNum2.setColumns(10);
    JButton btnAdd = new JButton("ADD");
    btnAdd.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
    int num1, num2, ans;
    try {
    num1 = Integer.parseInt(txtNum1.getText());
    num2 = Integer.parseInt(txtNum2.getText());
    ans = num1 + num2;
    txtNum3.setText(Integer.toString(ans));// Take the int called ans, turn it into a String that represents an integer
    } catch (NumberFormatException e1) {
    JOptionPane.showMessageDialog(null, "Please Enter an Integer" + e1);
    }
    }
    });
    btnAdd.setBounds(18, 98, 117, 29);
    frame.getContentPane().add(btnAdd);
    btnSubtract = new JButton("SUBTRACT");
    btnSubtract.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
    int num1, num2, ans; // These declaration need to be repeated here because they are local in both places.
    try {
    num1 = Integer.parseInt(txtNum1.getText());
    num2 = Integer.parseInt(txtNum2.getText());
    ans = num1 - num2;
    txtNum3.setText(Integer.toString(ans));// Take the int called ans, turn it into a String that represents an integer
    } catch (NumberFormatException e2) {
    JOptionPane.showMessageDialog(null, "Please Enter an Integer" + e2);
    }
    }
    });
    btnSubtract.setBounds(312, 98, 117, 29);
    frame.getContentPane().add(btnSubtract);
    lblAnswIs = new JLabel("The Answer is");
    lblAnswIs.setBounds(53, 238, 149, 16);
    frame.getContentPane().add(lblAnswIs);
    txtNum3 = new JTextField();
    txtNum3.setText(" "); //Don't fill anything in here so user doesn't have to erase it
    txtNum3.setBounds(257, 233, 130, 26);
    frame.getContentPane().add(txtNum3);
    txtNum3.setColumns(10);
    }
    }

  • @peruvianricardo5511
    @peruvianricardo5511 8 років тому

    Muchas gracias

  • @benorim
    @benorim 9 років тому +1

    perfecto!!!

  • @rahatulashekinashik
    @rahatulashekinashik 4 роки тому

    Thanks man!!!!

  • @fajarishizaki4292
    @fajarishizaki4292 6 років тому

    Thanks sir

  • @nagamallisupraja860
    @nagamallisupraja860 7 років тому

    Thanku sooo much sir

  • @karly658
    @karly658 7 років тому

    are there any software better than eclipse and net beans?

  • @itsyaboi_jaja
    @itsyaboi_jaja 2 роки тому

    Can i have the code pls

  • @enesard
    @enesard 6 років тому

    Great

  • @SkyRocket159
    @SkyRocket159 4 роки тому

    I will take this lebl

  • @blackatomic1669
    @blackatomic1669 6 років тому +4

    Well, i looked away for 20second and after I focused on the video again, everything was still the same.

    • @hieubuicong391
      @hieubuicong391 4 роки тому

      it's doesn't matter. you could adjust the speed..

  • @khaledsale7
    @khaledsale7 9 років тому

    thx

  • @nagahalomac
    @nagahalomac 7 років тому

    It doesn't work for (*) and (/) though

    • @patrickedwinmoran2966
      @patrickedwinmoran2966 6 років тому

      You could very easily fix that for yourself, no? See how he changed + into - and change = into *
      \\

  • @nejatsultan598
    @nejatsultan598 9 років тому +1

    hey sir when i drag drop text fields it is bordered like south north east west how can i remove it

  • @heenakhan2123
    @heenakhan2123 9 років тому +1

    Thank u for tutorial .. :)

  • @goldenotis9703
    @goldenotis9703 7 років тому

    i keep getting this error Access restriction: The type JFrame is not accessible due to restriction on required library C:\Program Files\Java\jre1.8.0_111\lib
    t.jar anyone knopw why?

    • @christianhollinger2357
      @christianhollinger2357 6 років тому

      its because you are gay

    • @patrickedwinmoran2966
      @patrickedwinmoran2966 6 років тому

      It looks like something in corrupted in the lib files you downloaded. You might as well do a clean installation of Java onto your computer.

  • @toastyyyyyyyy
    @toastyyyyyyyy 9 років тому

    Holy shit, I used to use that format for an intro!

  • @chadtv538
    @chadtv538 7 років тому +1

    You dont have to convert the fucking integer to a string, just do textFieldAns.setText("" + ans);
    It does the same thing bro.

  • @ZeldaZelda123123
    @ZeldaZelda123123 9 років тому +1

    Change title to: Programming for noobs that dont want to learn proper coding

    • @ZeldaZelda123123
      @ZeldaZelda123123 9 років тому

      it doesnt teach you java

    • @laurynas.k
      @laurynas.k 9 років тому

      Naive This tutorial is for developers that have little bit of experience in development process if you are real new in Java I recommend for you check out NewBoston java tutorials and later come back here. :)

  • @kernadan000
    @kernadan000 8 років тому

    thank you

  • @TheKhan9191
    @TheKhan9191 9 років тому

    the method is very difficult

  • @RA-nc6bt
    @RA-nc6bt 6 років тому

    Ur teaching very nice plz provide Bangalore location address definitely join to ur organisation plzzzzzzzzzzzzzzzzzzzzzzzzzz i am looking for ur replay

  • @akshataustin5483
    @akshataustin5483 5 років тому

    sir scientific calculator

  • @princegupta6779
    @princegupta6779 8 років тому +1

    It is a made by drag and drop application. What a waste I want to be an actual coder.

    • @mariokljucevic3481
      @mariokljucevic3481 8 років тому +3

      +Prince Gupta Hi, I would like to mention something. Being a computer programmer(coder) does not necessary mean you have to write every single line of code. What makes a good programmer? Speed and efficiency. That's where Eclipse Window Builder comes in hand, it helps you preserve time and make you finish your project much faster. So don't let this "drag & drop" actions fool you, there is a lot of other code that has to be written and this just saves time on let's call it "easy" stuff. Have a nice day :)

    • @princegupta6779
      @princegupta6779 8 років тому

      Well you're right but if someone is beginner he must do this on his own as it will teach him new methods of designing the structure of the GUI, but you are right now I'm experienced qa bit and so i understood its necessity

    • @mariokljucevic3481
      @mariokljucevic3481 8 років тому

      +Prince Gupta Glad to hear that :)

  • @Ventixo
    @Ventixo 6 років тому

    If you want it to work with decimals, change "int" and "Integer" in the coding to "Double", like this:
    Double num1, num2, ans;
    try {
    num1=Double.parseDouble(textFieldnum1.getText());
    num2=Double.parseDouble(textFieldnum2.getText());
    ans = num1 + num2;
    textFieldans.setText(Double.toString(ans));
    } catch (Exception c) {
    JOptionPane.showMessageDialog(null, "This is a calculator you idiot. Only numbers.");
    }