Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / NewStats: 3,195,565 members, 7,958,748 topics. Date: Wednesday, 25 September 2024 at 10:22 PM |
Nairaland Forum / Science/Technology / Programming / Simple Java Calculator Code. (1397 Views)
Ceemate (for All Undergraduates ) CGPA calculator / My C++ CGPA Calculator Program / How To Create A Simple Calculator (using Javascript ) (2) (3) (4)
Simple Java Calculator Code. by jimklef(m): 9:29am On Sep 08, 2016 |
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.*;
public class SmallCalculator extends JFrame
{
private JLabel firstJLabel, secondJLabel,
resultJLabel, designJLabel, groupJLabel,
actJLabel, assignmentJLabel;
private JTextField
firstJTextField,secondJTextField,
resultJTextField;
private JButton addJButton, subJButton,
divJButton, mulJButton, remJButton;
public SmallCalculator()
{
createUserInterface();
}
public void createUserInterface()
{
Container con=getContentPane();
con.setLayout(null);
firstJLabel=new JLabel("Enter First Number"
firstJLabel.setBounds(16, 16, 120, 26);
con.add(firstJLabel);
firstJTextField=new JTextField();
firstJTextField.setBounds(145, 16, 196, 26);
firstJTextField.setHorizontalAlignment
(JTextField.RIGHT);
con.add(firstJTextField);
firstJTextField.addKeyListener(
new KeyAdapter()
{
public void keyPressed(KeyEvent ev)
{
resultJTextField.setText(""
}
}
);
secondJLabel=new JLabel("Enter Second
Number"
secondJLabel.setBounds(16, 48, 124, 58);
con.add(secondJLabel);
secondJTextField=new JTextField();
secondJTextField.setBounds(145, 64, 196,
26);
secondJTextField.setHorizontalAlignment
(JTextField.RIGHT);
con.add(secondJTextField);
secondJTextField.addKeyListener(
new KeyAdapter()
{
public void keyPressed(KeyEvent ev)
{
resultJTextField.setText(""
}
} save the code as SmallCalculator.java and compile it. For more source code email me at jimklefmomoh@gmail.com |
Re: Simple Java Calculator Code. by Nobody: 2:17pm On Sep 08, 2016 |
Bros what you just typed here shows you are not a neat programmer. Your codes must be well indented so that you''ll give the audience the benefits of grasping your codes at a glance. Well done though but complete the code with the main method and the instantiation of all your variables. That way you'll get credibility and you'll be reckoned with as a good programmer. Then I also observed there are no event Actors in your code. 1 Like |
Re: Simple Java Calculator Code. by jidez007: 2:37pm On Sep 08, 2016 |
^^^ neat programmer ke? I wonder if he is even a programmer at all. I have seen people just collate a lot of small programs, usually the ones they didn't write themselves. |
Re: Simple Java Calculator Code. by Nobody: 3:21pm On Sep 08, 2016 |
Lol.. . That's hilarious!!! |
Re: Simple Java Calculator Code. by MrKamar(m): 9:25am On Sep 09, 2016 |
I smell copy and paste |
Re: Simple Java Calculator Code. by cirmuell(m): 5:34pm On Sep 14, 2016 |
Please I need someone who can help with Java, I mean from scratch. |
Re: Simple Java Calculator Code. by Nobody: 10:56am On Sep 15, 2016 |
cirmuell:Check out this thread on NL from some one https://www.nairaland.com/3260102/community-service-teach-everything-know and this thread by Fulaman https://www.nairaland.com/3033543/learning-program-java-fulaman. I think you will learn a great deal from these two people. As for me I am still learning for the past 6 years and if you want a quick fix then Java is the wrong language for you sir. All the best |
Re: Simple Java Calculator Code. by cirmuell(m): 11:41am On Sep 15, 2016 |
Ayoolla:Thanks a lot bro...I appreciate. Do you have the pdf file by Ultimatex? |
(1) (Reply)
Need Someone That Can Help Code And Do Writeup For Final Year Project / Vacancy - PHP Application Developer / Who Has Books On Python Programming Hard Copy For Sale
(Go Up)
Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health religion celebs tv-movies music-radio literature webmasters programming techmarket Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 20 |