JApplet help please cant find symbol even imported or extends

here is my code

import java.util.Arrays;

import java.applet.Applet;

import java.awt.*;

import javax.swing.*;

import java.awt.event.*;

import se.datadosen.component.RiverLayout; <-- dont mindthis

publicclass appletguiextends JApplet

{

publicvoid init()

{

JButton clearbtn1 =new JButton("Clear");

JButton clearbtn2 =new JButton("Clear");

JButton clearbtn3 =new JButton("Clear");

final JTextField txtoddeven =new JTextField(5);

final JTextField txtcelcius =new JTextField(5);

final JTextField txtkelvin =new JTextField(5);

final JTextField txtsort1 =new JTextField(5);

final JTextArea txtsort2 =new JTextArea();

txtsort2.setEditable(false);

final JApplet window2 =new JApplet("Odd and Even");

final JApplet window3 =new JApplet("Farenheight to Celcius");

final JApplet window4 =new JApplet("Kelvin to Celcius");

final JApplet window5 =new JApplet("Array Sorting");

final JRadioButton oddeven =new JRadioButton("Odd and Even");

final JRadioButton celcius =new JRadioButton("Farenheight to Celcius");

final JRadioButton kelvin =new JRadioButton("Kelvin to Celcius");

final JRadioButton sort =new JRadioButton("Array sorting");

final JApplet window1 =new JApplet("Java");

Container content1 = window1.getContentPane();

content1.setLayout(new RiverLayout());

//window1.setResizable(false);

//window1.setDefaultCloseOperation(JApplet.EXIT_ON_CLOSE);

//window1.setLocationRelativeTo(null);

ButtonGroup group =new ButtonGroup();

group.add(oddeven);

group.add(celcius);

group.add(kelvin);

group.add(sort);

JButton ok =new JButton("Ok");

content1.add("p left", oddeven);

content1.add("tab", celcius);

content1.add("br", kelvin);

content1.add("tab", sort);

content1.add("br center",ok);

//window1.pack();

//window1.setVisible(true);

ok.addActionListener(new ActionListener()

{

publicvoid actionPerformed(ActionEvent e)

{

try

{

int hello, y;

boolean x;

x = oddeven.isSelected();

if(x ==false)

{

y = 0;

}

else

{

y = 1;

}

for(hello = 0; hello < y; hello++)

{

window2.setVisible(true);

window1.setVisible(false);

}

}

catch(Exception ex)

{

JOptionPane.showMessageDialog(null,"Invalid");

}

}

});

ok.addActionListener(new ActionListener()

{

publicvoid actionPerformed(ActionEvent e)

{

try

{

int hello, y;

boolean x;

x = celcius.isSelected();

if(x ==false)

{

y = 0;

}

else

{

y = 1;

}

for(hello = 0; hello < y; hello++)

{

window3.setVisible(true);

window1.setVisible(false);

}

}

catch(Exception ex)

{

JOptionPane.showMessageDialog(null,"Invalid");

}

}

});

ok.addActionListener(new ActionListener()

{

publicvoid actionPerformed(ActionEvent e)

{

try

{

int hello, y;

boolean x;

x = kelvin.isSelected();

if(x ==false)

{

y = 0;

}

else

{

y = 1;

}

for(hello = 0; hello < y; hello++)

{

window4.setVisible(true);

window1.setVisible(false);

}

}

catch(Exception ex)

{

JOptionPane.showMessageDialog(null,"Invalid");

}

}

});

ok.addActionListener(new ActionListener()

{

publicvoid actionPerformed(ActionEvent e)

{

try

{

int hello, y;

boolean x;

x = sort.isSelected();

if(x ==false)

{

y = 0;

}

else

{

y = 1;

}

for(hello = 0; hello < y; hello++)

{

window5.setVisible(true);

window1.setVisible(false);

}

}

catch(Exception ex)

{

JOptionPane.showMessageDialog(null,"Invalid");

}

}

});

Container content2 = window2.getContentPane();

content2.setLayout(new RiverLayout());

//window2.addWindowListener(new WindowAdapter()

//{

// public void windowClosing(WindowEvent e)

// {

//window1.setVisible(true);

//window2.setDefaultCloseOperation(window2.DISPOSE_ON_CLOSE);

// }

//});

//window2.setResizable(false);

//window2.setLocationRelativeTo(null);

JLabel lbloddeven =new JLabel("Enter a number");

JButton oddevenbtn =new JButton("Odd or Even");

content2.add("p left", lbloddeven);

content2.add("tab", txtoddeven);

content2.add("br", oddevenbtn);

content2.add("", clearbtn1);

//window2.pack();

oddevenbtn.addActionListener(new ActionListener()

{

publicvoid actionPerformed(ActionEvent e)

{

try

{

int x;

x=Integer.parseInt(txtoddeven.getText());

if(x%2==0)

{

JOptionPane.showMessageDialog(null, x +" Is even number");

}

else

{

JOptionPane.showMessageDialog(null, x +" Is odd number");

}

}

catch(Exception ex)

{

JOptionPane.showMessageDialog(null,"Invalid Input");

}

}

});

clearbtn1.addActionListener(new ActionListener()

{

publicvoid actionPerformed(ActionEvent e)

{

txtoddeven.setText("");

}

});

Container content3 = window3.getContentPane();

content3.setLayout(new RiverLayout());

//window3.setResizable(false);

//window3.addWindowListener(new WindowAdapter()

//{

//public void windowClosing(WindowEvent e)

//{

//window3.setDefaultCloseOperation(window3.DISPOSE_ON_CLOSE);

//window1.setVisible(true);

//}

//});

//window3.setLocationRelativeTo(null);

JLabel lblcelcius =new JLabel("Enter a number to convert");

JButton celciusbtn =new JButton("Convert to celcius");

JButton farenheightbtn =new JButton("Convert to farenheight");

content3.add("p left", lblcelcius);

content3.add("tab", txtcelcius);

content3.add("br", celciusbtn);

content3.add("", farenheightbtn);

content3.add("", clearbtn2);

//window3.pack(); // window pack

celciusbtn.addActionListener(new ActionListener()

{

publicvoid actionPerformed(ActionEvent e)

{

try

{

double f, c;

f = Double.parseDouble(txtcelcius.getText());

c = 5.0/9.0*f-32;

JOptionPane.showMessageDialog(null, c);

}

catch(Exception ex)

{

JOptionPane.showMessageDialog(null,"Invalid Input");

}

}

});

farenheightbtn.addActionListener(new ActionListener()// this is the action if the user click the button it will generate the output

{

publicvoid actionPerformed(ActionEvent e)

{

try

{

double f, c;

c = Double.parseDouble(txtcelcius.getText());

f = 9.0/5.0*c+32;

JOptionPane.showMessageDialog(null, f);

}

catch(Exception ex)

{

JOptionPane.showMessageDialog(null,"Invalid Input");

}

}

});

clearbtn2.addActionListener(new ActionListener()//clear the textfields

{

publicvoid actionPerformed(ActionEvent e)//event to execute the action required

{

txtcelcius.setText("");

}

});

Container content4 = window4.getContentPane();//putting the contents to the JApplet

content4.setLayout(new RiverLayout());

//window4.setResizable(false);

//window4.addWindowListener(new WindowAdapter() // closing operation should import java.awt.event.*; to work

//{

//public void windowClosing(WindowEvent e)

//{

//window4.setDefaultCloseOperation(window4.DISPOSE_ON_CLOSE);

//window1.setVisible(true);

//}

//});

//window4.setLocationRelativeTo(null); // putting the JApplet window in Center

JLabel lblkelvin =new JLabel("Enter a number to convert");

JButton kelvinbtn1 =new JButton("Convert kelvin to Celcius");

JButton kelvinbtn2 =new JButton("Convert Celcius to Kelvin");

// contents of the window frame

content4.add("p left", lblkelvin);

content4.add("tab", txtkelvin);

content4.add("br", kelvinbtn1);

content4.add("", kelvinbtn2);

content4.add("", clearbtn3);

//window4.pack();

kelvinbtn1.addActionListener(new ActionListener()// this is the action if the user click the button it will generate the output

{

publicvoid actionPerformed(ActionEvent e)

{

try

{

double k, c;

c = Double.parseDouble(txtkelvin.getText());

k = c+273;

JOptionPane.showMessageDialog(null, k);

}

catch(Exception ex)

{

JOptionPane.showMessageDialog(null,"Invalid Input");// this messagebox will pop-up if there's a invalid input by the user

}

}

});

kelvinbtn2.addActionListener(new ActionListener()

{

publicvoid actionPerformed(ActionEvent e)

{

try

{

double k, c;

k = Double.parseDouble(txtkelvin.getText());

c = k-273;

JOptionPane.showMessageDialog(null, c);

}

catch(Exception ex)

{

JOptionPane.showMessageDialog(null,"Invalid Input");// this messagebox will pop-up if there's a invalid input by the user

}

}

});

clearbtn3.addActionListener(new ActionListener()

{

publicvoid actionPerformed(ActionEvent e)

{

txtkelvin.setText("");

}

});

Container content5 = window5.getContentPane();

content5.setLayout(new RiverLayout());

//window5.setSize(200,150);

//window5.setResizable(false);

//window5.addWindowListener(new WindowAdapter()

//{

//public void windowClosing(WindowEvent e)

///{

//window5.setDefaultCloseOperation(window5.DISPOSE_ON_CLOSE);

//window1.setVisible(true);

//}

//});

//window5.setLocationRelativeTo(null);

JLabel lblsort1 =new JLabel("Sorted strings");

JButton sortbtn =new JButton("Click here to enter a string to sort");

content5.add("p left", lblsort1);

content5.add("tab hfill", txtsort2);

content5.add("br", sortbtn);

//window5.pack();

sortbtn.addActionListener(new ActionListener()

{

publicvoid actionPerformed(ActionEvent e)

{

try// catching errors

{

int x, y;

String name[] =new String[3];

txtsort2.setText("");

for(x = 0; x < 3; x++)

{

name[x]=JOptionPane.showInputDialog(null,"Enter a String");

}

Arrays.sort(name);

for(y = 0; y < 3; y++)

{

txtsort2.append("," + name[y]);

}

}

catch(Exception ex)// catching errors

{

JOptionPane.showMessageDialog(null,"Invalid");// this messagebox will pop-up if there's a invalid input by the user

}

}

});

//public void start()

//{

//System.out.print("Starting");

//}

}

}

here is the error of my code

C:\Program Files\Java\jdk1.6.0_01\bin\MyProjects\appletgui.java:24: cannot find symbol

symbol : constructor JApplet(java.lang.String)

location:class javax.swing.JApplet

final JApplet window2 =new JApplet("Odd and Even");

^

C:\Program Files\Java\jdk1.6.0_01\bin\MyProjects\appletgui.java:25: cannot find symbol

symbol : constructor JApplet(java.lang.String)

location:class javax.swing.JApplet

final JApplet window3 =new JApplet("Farenheight to Celcius");

^

C:\Program Files\Java\jdk1.6.0_01\bin\MyProjects\appletgui.java:26: cannot find symbol

symbol : constructor JApplet(java.lang.String)

location:class javax.swing.JApplet

final JApplet window4 =new JApplet("Kelvin to Celcius");

^

C:\Program Files\Java\jdk1.6.0_01\bin\MyProjects\appletgui.java:27: cannot find symbol

symbol : constructor JApplet(java.lang.String)

location:class javax.swing.JApplet

final JApplet window5 =new JApplet("Array Sorting");

^

C:\Program Files\Java\jdk1.6.0_01\bin\MyProjects\appletgui.java:35: cannot find symbol

symbol : constructor JApplet(java.lang.String)

location:class javax.swing.JApplet

final JApplet window1 =new JApplet("Java");

^

5 errors

please help me my head is breaking thank's

[25650 byte] By [Jaywhya] at [2007-11-27 9:32:09]
# 1

JApplet does not have a constructor that takes a String. Meaning, you can't do this:

final JApplet window2 = new JApplet("Odd and Even");

Why are you creating new JApplets like that anyway? They aren't going to show unless you add them into your main applet. And even then, it's not a good idea to use JApplets as containers within an applet/application, as they are top-level containers.

bsampieria at 2007-7-12 22:48:54 > top of Java-index,Java Essentials,Java Programming...
# 2

thank's for your help because when i first run this program my code was scrumbled and i cant see any frame so i decided to use JApplet instead of JFrame but now i rewrite it and works like a charm i use JFrame im not familiar with JApplet you mean if i use JApplet i have to add my contents to it contentpane? like this

applet.add(txtsort);

is that what you mean adding to its contentpane?im familiar with application than applets thats why im confuse i just make this program to practice applet

Jaywhya at 2007-7-12 22:48:54 > top of Java-index,Java Essentials,Java Programming...