I'm having problem loading a java gui into a html page as an applet. I believe the problem is the init method. this is the first time i've had to make one and i don't think i did it right.

here is my java code:

code

package gui;

import java.awt.*;
import java.awt.event.*;

import javax.swing.*;
public class WebDesignGUI extends JFrame implements ActionListener
{
int counter=0, score1= -1, score2= -1, score3= -1;
String sScore1="0", sScore3="0", sScore2="0";
JButton enter;
JLabel inLabel = new JLabel(" Height in inches :" ) ;
//JLabel heightLabel = new JLabel("weight in inches: " );
TextField inText = new TextField( 10 );
JLabel inLabel2 = new JLabel( " weight in pounds : " ) ;
TextField inText2 = new TextField( 10 );
JLabel bfc = new JLabel( "Body fat composition :" ) ;
TextField outText3 = new TextField( 10 );


public WebDesignGUI ()
{
getContentPane().setLayout( new FlowLayout() );
getContentPane().add( inLabel ) ;
getContentPane().add( inText ) ;
getContentPane().add( inLabel2 ) ;
getContentPane().add( inText2 ) ;
getContentPane().add( bfc ) ;
getContentPane().add( outText3 ) ;
enter = new JButton("Enter");
enter.setActionCommand( "Enter" );
enter.addActionListener( this );
getContentPane().add( enter );
}

public void init(){
getContentPane().setLayout( new FlowLayout() );
getContentPane().add( inLabel ) ;
getContentPane().add( inText ) ;
getContentPane().add( inLabel2 ) ;
getContentPane().add( inText2 ) ;
getContentPane().add( bfc ) ;
getContentPane().add( outText3 ) ;
enter = new JButton("Enter");
enter.setActionCommand( "Enter" );
enter.addActionListener( this );
getContentPane().add( enter );

}

public void actionPerformed( ActionEvent evt)
{
int height, weight;
double bfc;
String stringScore= " = ";

if ( evt.getActionCommand().equals( "Enter" ) )
{
height = Integer.parseInt(inText.getText());
stringScore = inText.getText();

weight=Integer.parseInt(inText2.getText());
stringScore = inText.getText();
}


}


public static void main(String[] args)
{
WebDesignGUI echo = new WebDesignGUI();

echo.setSize( 300, 200 );
echo.setVisible( true );
echo.init();
JFrame outWindow;

Container outPane;


}
}
and here is my html:

<applet code="WebDesignGUI.class" width="32" height="32">
</applet>

PS... I know the gui doesn't do anything yet, i haven't inserted the math algorithms yet

Applets extend JApplet not JFrame ;)

oh yeah, thanx for the input server_crash... this is the first time ive made a gui for a webpage.... so fixed that problem; however i was still getting the notinited error... did some more research and found out i needed to include a jar file in the html code... added archive = JAMA.jar in the applet tags... works fine now.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.