Re: Please thiHelp
From: Mary (Mary_at_discussions.microsoft.com)
Date: 06/10/04
- Next message: George Birbilis [MVP J#] [9880]: "Re: Please thiHelp"
- Previous message: Mary: "Re: Please thiHelp"
- In reply to: Lars-Inge Tønnessen: "Re: Please thiHelp"
- Next in thread: George Birbilis [MVP J#] [9880]: "Re: Please thiHelp"
- Reply: George Birbilis [MVP J#] [9880]: "Re: Please thiHelp"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 9 Jun 2004 19:07:01 -0700
I tried your applet for the calculation and it worked in java sun but how do I make the calculations work
How would i get this one to work with an applet?
import java.io.*;
class savingsacct
public static void main (String[] args) throws IOException {
BufferedReader stdin = new BufferedReader
(new InputStreamReader(System.in));
// declares three integers
double num1, num2, sum, dollars; // declares a number that can
have decimals
System.out.print ("What is the amount of your Withdrawl? $");
System.out.flush();
// read a line, and then converts it to an integer
num1=Double.parseDouble(stdin.readLine());
System.out.print ("What is the amount of your Deposit? $");
System.out.flush();
num2 = Double.parseDouble(stdin.readLine());
sum = num1 - num2; // Adds the two numbers;
dollars = 1000.09 - sum;
System.out.println("Your Balance is : $" + dollars);
} // method main
}
"Lars-Inge Tønnessen" wrote:
>
> You can't put windows forms in an applet. Please must use awt and layout
> managers. Java is not as "friendly" as windows when it comes to GUI
> design. If you don't use layout managers, your applet will look funny on other
> operating systems like Macs and Unix/Linuxes.
>
> ( Did serialization (save/load) work for your desktop app? )
>
>
>
> Call this file "gui.java"
>
> import java.applet.*;
> import java.awt.*;
> import java.awt.event.*;
>
> // ActionListener is for the "caclulate" button.
> public class gui extends java.applet.Applet implements ActionListener
> {
> private Label label_header;
>
> private TextField text_deposit;
> private TextField text_withdrawl;
> private TextField text_Interest;
> private TextField text_Balance;
>
> private Label label_Deposit;
> private Label label_Withdrawl;
> private Label label_Interest;
> private Label label_Balance;
>
> private Button but_calc;
>
> public void init( )
> {
> text_deposit = new TextField();
> text_withdrawl = new TextField();
> text_Interest = new TextField();
> text_Balance = new TextField();
>
> but_calc = new Button("Calculate");
> but_calc.addActionListener( this );
>
> label_header = new Label("Status: Ready");
> label_Deposit = new Label("Deposit :");
> label_Withdrawl = new Label("Withdrawl :");
> label_Interest = new Label("Interest :");
> label_Balance = new Label("Balance :");
>
> setLayout( new GridLayout(7,1) );
> add( label_header );
>
> Panel deposit_Panel = new Panel();
> deposit_Panel.setLayout( new GridLayout(1,3) );
> deposit_Panel.add( label_Deposit );
> deposit_Panel.add( text_deposit );
> deposit_Panel.add( new Label() );
> add( deposit_Panel );
>
> Panel withdrawl_Panel = new Panel();
> withdrawl_Panel.setLayout( new GridLayout(1,3) );
> withdrawl_Panel.add( label_Withdrawl );
> withdrawl_Panel.add( text_withdrawl );
> withdrawl_Panel.add( new Label() );
> add( withdrawl_Panel );
>
> Panel button_Panel = new Panel();
> button_Panel.setLayout( new GridLayout(1,3) );
> button_Panel.add( new Label("") );
> button_Panel.add( but_calc );
> button_Panel.add( new Label("") );
> add( button_Panel );
>
> Panel interest_Panel = new Panel();
> interest_Panel.setLayout( new GridLayout(1,3) );
> interest_Panel.add( label_Interest );
> interest_Panel.add( text_Interest );
> interest_Panel.add( new Label() );
> add( interest_Panel );
>
> Panel balance_Panel = new Panel();
> balance_Panel.setLayout( new GridLayout(1,3) );
> balance_Panel.add( label_Balance );
> balance_Panel.add( text_Balance );
> balance_Panel.add( new Label() );
> add( balance_Panel );
>
> }
>
>
> // The calculate button was pushed....
> public void actionPerformed( java.awt.event.ActionEvent event )
> {
> Button source = (Button)event.getSource();
>
> if ( source == but_calc )
> {
> label_header.setText("Calc button!!!");
> }
> }
>
>
> }
>
>
>
> <HTML>
> <BODY>
> <center>Banking</center>
> <BR>
> </BR>
> <CENTER>
> <APPLET CODE="gui.class" WIDTH="200" HEIGHT="150" VIEWASTEXT>Error! Please enable
> Java </APPLET>
> </CENTER>
> </BODY>
> </HTML>
>
>
>
>
> Regards,
> Lars-Inge Tønnessen
>
>
>
- Next message: George Birbilis [MVP J#] [9880]: "Re: Please thiHelp"
- Previous message: Mary: "Re: Please thiHelp"
- In reply to: Lars-Inge Tønnessen: "Re: Please thiHelp"
- Next in thread: George Birbilis [MVP J#] [9880]: "Re: Please thiHelp"
- Reply: George Birbilis [MVP J#] [9880]: "Re: Please thiHelp"
- Messages sorted by: [ date ] [ thread ]