Aymen++
04-08-2004, 05:06 AM
i have this applet:
import java.awt.*;
import java.applet.*;
import java.awt.*;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.*;
import javax.swing.border.*;
public class MultiplyApplet extends JApplet implements ActionListener {
private JTextField jtxtResult = new JTextField(10);
private JTextField jtxtFirst = new JTextField(10);
private JTextField jtxtSecond = new JTextField(10);
public void init() {
JLabel jlbFirst = new JLabel("Enter the first number:");
JLabel jlbSecond = new JLabel("Enter the second number:");
JLabel jlbResult = new JLabel("The result is:");
jtxtResult.setEditable(false);
//TitledBorder titleBorder = new Border("Enter two numbers to be multiplied");
JPanel jpMultiply = new JPanel();
jpMultiply.setLayout(new GridLayout(3, 2));
jpMultiply.add(jlbFirst);
jpMultiply.add(jtxtFirst);
jpMultiply.add(jlbSecond);
jpMultiply.add(jtxtSecond);
jpMultiply.add(jlbResult);
jpMultiply.add(jtxtResult);
//jpMultiply.setBorder(titleBorder);
getContentPane().setLayout(new BorderLayout());
getContentPane().add(jpMultiply, BorderLayout.NORTH);
JButton jbMultiply = new JButton("Multiply");
getContentPane().add(jbMultiply, BorderLayout.SOUTH);
jbMultiply.addActionListener(this);
}
public void actionPerformed(ActionEvent e) {
int f, s, r;
f = Integer.parseInt(jtxtFirst.getText());
s = Integer.parseInt(jtxtSecond.getText());
r = f * s;
jtxtResult.setText(Integer.toString(r));
}
}
and i have this htm file:
<HTML>
<HEAD>
</HEAD>
<BODY BGCOLOR="000000">
<CENTER>
<APPLET
code = "MultiplyApplet.class"
width = "500"
height = "300"
alt="You must have a Java 2-enabled browser to view the applet"
>
</APPLET>
</CENTER>
</BODY>
</HTML>
in the same directory when i try to open the htm file it tells me on the status bar of the internet explorer that the class MultiplyApplet not found.
i have JCreator, and as you know the JCreator creates the class file and the htm file in the same directory automatically. so it makes me confused, which file i must put it in the same directory? is it the .class file or the .java file?
import java.awt.*;
import java.applet.*;
import java.awt.*;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.*;
import javax.swing.border.*;
public class MultiplyApplet extends JApplet implements ActionListener {
private JTextField jtxtResult = new JTextField(10);
private JTextField jtxtFirst = new JTextField(10);
private JTextField jtxtSecond = new JTextField(10);
public void init() {
JLabel jlbFirst = new JLabel("Enter the first number:");
JLabel jlbSecond = new JLabel("Enter the second number:");
JLabel jlbResult = new JLabel("The result is:");
jtxtResult.setEditable(false);
//TitledBorder titleBorder = new Border("Enter two numbers to be multiplied");
JPanel jpMultiply = new JPanel();
jpMultiply.setLayout(new GridLayout(3, 2));
jpMultiply.add(jlbFirst);
jpMultiply.add(jtxtFirst);
jpMultiply.add(jlbSecond);
jpMultiply.add(jtxtSecond);
jpMultiply.add(jlbResult);
jpMultiply.add(jtxtResult);
//jpMultiply.setBorder(titleBorder);
getContentPane().setLayout(new BorderLayout());
getContentPane().add(jpMultiply, BorderLayout.NORTH);
JButton jbMultiply = new JButton("Multiply");
getContentPane().add(jbMultiply, BorderLayout.SOUTH);
jbMultiply.addActionListener(this);
}
public void actionPerformed(ActionEvent e) {
int f, s, r;
f = Integer.parseInt(jtxtFirst.getText());
s = Integer.parseInt(jtxtSecond.getText());
r = f * s;
jtxtResult.setText(Integer.toString(r));
}
}
and i have this htm file:
<HTML>
<HEAD>
</HEAD>
<BODY BGCOLOR="000000">
<CENTER>
<APPLET
code = "MultiplyApplet.class"
width = "500"
height = "300"
alt="You must have a Java 2-enabled browser to view the applet"
>
</APPLET>
</CENTER>
</BODY>
</HTML>
in the same directory when i try to open the htm file it tells me on the status bar of the internet explorer that the class MultiplyApplet not found.
i have JCreator, and as you know the JCreator creates the class file and the htm file in the same directory automatically. so it makes me confused, which file i must put it in the same directory? is it the .class file or the .java file?