Re: Please thiHelp
From: Lars-Inge Tønnessen (http://emailme.larsinge.com)
Date: 06/07/04
- Next message: Mary: "Re: Please thiHelp"
- Previous message: Alex K. Angelopoulos [MVP]: "Re: /target is 'exe' but no suitable main method was found in compilation"
- In reply to: Mary: "Re: Please thiHelp"
- Next in thread: Mary: "Re: Please thiHelp"
- Reply: Mary: "Re: Please thiHelp"
- Reply: Mary: "Re: Please thiHelp"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 7 Jun 2004 23:06:04 +0200
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: Mary: "Re: Please thiHelp"
- Previous message: Alex K. Angelopoulos [MVP]: "Re: /target is 'exe' but no suitable main method was found in compilation"
- In reply to: Mary: "Re: Please thiHelp"
- Next in thread: Mary: "Re: Please thiHelp"
- Reply: Mary: "Re: Please thiHelp"
- Reply: Mary: "Re: Please thiHelp"
- Messages sorted by: [ date ] [ thread ]