I have completed my applet code and it compiles fine - when I try to open it in explorer I get my welcome message but the applet does not fully open - all I get is the little box with the red X in top left corner. Help!
Here is code for both:

Applet:

import java.awt.event.*;
import java.applet.Applet;
import javax.swing.*;
import java.awt.*;
import java.awt.*;

public class JPartyPlanner extends JApplet implements ActionListener
{
JLabel companyName = new JLabel("Give A Hand Event Planning");
Font bigFont = new Font("Teen", Font.BOLD, 30);
JLabel firstLabel = new JLabel ("How many people will be attending?");
JTextField answer = new JTextField(10);
JButton calcButton1 = new JButton("Calculate per person");
JButton calcButton2 = new JButton("Calculate event cost");
JLabel perPersonResult = new JLabel(" ");
JLabel totalResult = new JLabel(" ");
FlowLayout flow = new FlowLayout();
ImageIcon image = new ImageIcon("birthday.jpeg");
private int width, height;
int y = 300;
int x = 300;

public void init()
{
Container con = getContentPane();
con.setLayout(new FlowLayout());
companyName.setFont(bigFont);
con.setBackground(Color.ORANGE);
con.add(companyName);
con.add(firstLabel);
con.add(answer);
con.add(calcButton1);
con.add(calcButton2);
calcButton1.addActionListener(this);
calcButton2.addActionListener(this);
con.add(perPersonResult);
con.add(totalResult);

height = image.getIconHeight();

}

public void paint(Graphics g)

{
super.paint(g);
g.drawString("IT'S PARTY TIME!", x, y);
g.drawImage(image.getImage(), x, y + 20,width, height, this);
}

public void start()
{
perPersonResult.setText("Per person Cost is ");
totalResult.setText("Event cost is ");
repaint();
}

public void actionPerformed(ActionEvent e)
{
Object source = e.getSource();

{
String response = answer.getText ();
int[] guestLimit = {0, 25, 50, 100, 200, 500, 1000};
int[] ratePerGuest = {27, 25, 22, 19, 17, 14, 11};
int guests = Integer.parseInt(response);
int individualFee = 0, eventFee = 0;
int x = 0, a = 0;

for(x = 6; x >= 0; --x)
if(guests >= guestLimit[x])
{
individualFee = ratePerGuest[x];
eventFee = guests * individualFee;
x = 0;
}

perPersonResult.setText("Per person cost is $" + individualFee);
totalResult.setText("Event cost is $" + eventFee);


}
}

}


HTML file:

<html>
<applet code ="JPartyPlanner.class" width = 600 height =300>
<PARAM NAME=TEXT VALUE="Welcome">
<P>Welcome!<P>

</applet>
</html>

Any help is gresatly appreciated

seems you need

con.setVisible(true);

I usually work with frames, and after creating and adding controls/layout, you have to use setVisible, but i googled container and it does inherit setVisible from java.awt.component.

Mike

Edited 6 Years Ago by adams161: n/a

Is there an error message in the browser's Java console?
Please copy and paste it here.
How are you executing the applet? Locally from a disk file or from a server?

Thanks Guys but I figured it out - it was an issue with Vista works fine in 07.

This question has already been answered. Start a new discussion instead.