How can i use this as an applet ?
i have this applet :
import java.applet.*;
import java.io.*;
public class calculator2 extends Applet {
/*<Applet code=calculator2.class width=500 height=500></applet>*/
/*the above comment has to be there for applet view to work. Type in at the promt "appletviewer calculator2.java"*/
public void init() {
int num1,num2,num3,num4,num5,num6,sum;
num1 = num2 = num3 = num4 = num5 = num6 = sum = 0;
/*Program statemants start here*/
BufferedReader br = null;
try {
br = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Input Rent");
num1 = Integer.parseInt(br.readLine());
System.out.println("Input Utility bills");
num2 = Integer.parseInt(br.readLine());
System.out.println("Input mobile bills");
num3 = Integer.parseInt(br.readLine());
System.out.println("Input food");
num4 = Integer.parseInt(br.readLine());
System.out.println("Input soialising");
num5 = Integer.parseInt(br.readLine());
System.out.println("Input savings");
num6 = Integer.parseInt(br.readLine());
sum=num1+num2+num3+num4+num5+num6;
System.out.println("Enter your income: ");
int income = Integer.parseInt(br.readLine());
income -= sum;System.out.println(income);
} catch (IOException ioe) {
} catch (NumberFormatException nfe) {
System.out.println("That wasn't a valid number!");
System.out.println("Someone else did my homework for me! ");
but when i run it i still need to write my answers in the comand prompt window not the applet its self,
i know i need to do something like this but i don't know how
add the line import java.awt; Instead of using System.out.println you can
a)Paint the characters using paint
public void paint(Graphics g){
g.drawString(x, y, "" + yourVariableName); //use this for each System.out.println
b)store the variables in a label and add
Label yourName = newLabel("")// do this for each thing you want to print.
yourName.setText("" + yourVariableName); //replace all sytem.out.println with this.
anyone offer any advice ??
thanking you in advance
Anthony
You seem to be asking an awful lot of questions that could be found in any basic Java textbook. Won't make you too popular on here!
This should get you started anyway
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class calculator2 extends Applet implements ActionListener
int total;
Label label1, label2;
TextField text1, text2;
Button clicker;
public void init()
label1 = new Label ("Input Rent");
label2 = new Label ("Input Bills");
text1 = new TextField (5);
text2 = new TextField (5);
clicker = new Button("Calculate");
add(label1);
add(text1);
add(label2);
add(text2);
add(clicker);
clicker.addActionListener(this);
} // end init
public void paint (Graphics g)
g.drawString ("The total is " + total, 50,100);
} // end paint
public void actionPerformed (ActionEvent e)
total = Integer.parseInt(text1.getText()) +Integer.parseInt(text2.getText());
repaint();
} // end actionPerformed
} // end class
Similar Messages
-
I bought used iPhone and on this iPhone I'm not able to make new account on i Cloud'. How can I use this iCloud's on used iPhone Please help me
When I logging there it told me that maximum no of iCloud's Account already activated on this iPhone.
Please help me how can I open new iCloud's account on this iPhone
Regard
Faiz khanSet up the account using a desktop or laptop, then sign
into that account on your iPhone.
I am not aware of any method around the restriction once
the maximum has been created on any individual iPhne. -
I have a limited storage in iPhone so i bought 20g iCloud. how can i use this iCloud storage in my device to store music and photos?
Welcome to the Apple Community.
You could sign up for iTunes match and use iCloud photo library with optimisation enabled. The later will keep optimised photos on your device and iTunes match will let you access your whole collection and make room for newer content by removing older unplayed items. -
How can i use this function module
Hai
How can i use this function module /SAPHT/SALES_ORDER_READ, already apply the some parameters in this function module, but it shows the error , please tell me, how to declare the parameters in this function module ,
thanks
neelimaHi
For a particular sales order,you have to pass the order number and the item number in the sales order.
It will display the rest of the values which u can capture them using internal tables.
Regards,
Vishwa. -
i have a iphone 4,4.3.5 bought from uk i used this phone in uk,now i am in india how can i use this in another networks without jailbreak such type of softwares
Where did the phone come from as most of the UK carriers unlock phones, but the fact that you are now abroad may be a problem.
-
I purchased a iphone i USA. How can i use this iphone in india with vodafone.
I Purchased a iPhone 5s in USA. How can I use this phone in India with Vodafone.
<Edited By Host>First, the iPhone would need to be unlocked. That would depend on where you bought it. Next, the North American phone would not work with all of the networks outside of the US. Also, the warranty for the device is only good in the US, so if you have a problem with the phone, you would need to bring it back to the US to an Apple Store. Where did you purchase the phone?
-
I purchased Adobe Illustrator CS2 on CD many years ago and now i have bought a new iMac computer it won't let me install from the CD's. How can i use this product on iMac ?
Because the Nano was previous synced to another comuter/iTunes library.
See the following:
Syncing to a "New" Computer or replacing a "crashed" Hard Drive: Apple Support Communities -
How can i use this sript and loade another movie?
Hi there, i used the following script to load a movie from the server;
var request:URLRequest = new URLRequest("url string");
var loader:Loader = new Loader()
loader.load(request);
addChild(loader);
How can i use this sript and loade another movie? Can someone help me please?
[edited by moderator]Sir, I changed it from:
var request:URLRequest = new URLRequest("http://agusandelsur.gov.ph/downloads/pdrrmo/agusan_del_sur/StaJosefa/Movies/Dir.swf");
var loader:Loader = new Loader()
loader.load(request);
addChild(loader);
to
var request:URLRequest = new URLRequest("http://agusandelsur.gov.ph/downloads/pdrrmo/agusan_del_sur/StaJosefa/Movies/Warning.swf");
var loader:Loader = new Loader()
loader.load(request);
addChild(loader);
When i expord the movie i get the following error.....
Scene 1, Layer 'Layer 3', Frame 1, Line 6 1151: A conflict exists with definition request in namespace internal. -
How can I use this forum?
Does anybody here can tell me how can i use this forum???
What do you want to do? What is your question?
Randy -
How can I use this account without specify credit cards, only for free applications ?
How can I use this account without specify credit cards, only for free applications ?
Click here and follow the instructions.
(94222) -
I have an apple 4 given to me by my cousin from japan but the phone is lock by japan sotfbank, how can i use this phone here in the Philippines network provider? thanks
Only the carrier an iPhone was sold as carrier locked with can officially unlock the iPhone. It is my understanding that Softbank in Japan does not unlock iPhones.
-
good day..i have my iphone 4 now..am here in the philippines...how can i use this unit using my smart simcard here..thank you.
Is your iphone officially unlocked?
If not, then you cannot use it there. -
What is car play ? how can i use this?
what is car play ? how can i use this?
You can use CarPlay if your new car model supports it.
http://www.apple.com/ios/carplay/ -
Hi I have itunes UK on my lap top and my daughter has been bought an Itunes USA gift card how can I use this please?
Gift cards can only be used in the country in which they are purchased - so in order to use a US gift card you would need to have a US iTunes account.
-
I am registered with itunes uk and have recieved a voucher for itunes us. How can i use this?
iTunes Gift Vouchers can Only be redeemed in their Country of Origin.
Maybe you are looking for
-
How do I get all my pins (bookmarks) to show up on maps rather than having to choose from the bookmark list? I can see my list getting very large and more cumbersome to search. In google maps, all my starred locations show up on my map.
-
I have some courses that use only slide views to track completion, because the quizzes are set as separate elements in the LMS we are using (from Oracle PeopleSoft). The LMS people are telling me they require a masteryscore of 0 to be included in th
-
Batching in sync read file adapter
Dear All, Is there any way we can do batching in sync read file adapter ? I am at SOA Server 10.1.3.4 MLR#5. Please share if any information. Best Regards Arc
-
Work Order Release Approval workflow
Hi All, I am trying to setup Work Order Release Approval workflow. I have set its AME using supervisory level as the action type. When I tried set work order status, I had to set the department as I set department attribute as its AME condition, and
-
How to display with outputText?
Hi! I wonder if anyone can tell me how to display to produce more space between two text elements than just one blank? Is there some escape code if I would like to use HTML tags in outputText (altough I don't find good reason to do so right now :)