Browser cant load my applet, in Eclipse its all ok
843805Jan 29 2007 — edited Feb 5 2007Error from IE Java Consolest:
java.lang.ClassCastException: oo6 cannot be cast to java.applet.Applet
at sun.applet.AppletPanel.createApplet(Unknown Source)
at sun.plugin.AppletViewer.createApplet(Unknown Source)
at sun.applet.AppletPanel.runLoader(Unknown Source)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Code:
import java.awt.*;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class oo9 extends JFrame implements ActionListener {
String kuva;
JTextArea ta1 = new JTextArea();
JTextArea ta2 = new JTextArea();
JButton b1 = new JButton("Kontrolli");
// <<<<<<<<<<<<<<<<<<<<<<<<<<<
// <<<<< oo9 konstruktor <<<<<
public oo9() {
ta1.setText("aaaa");
Font font = new Font("Bitstream Vera Sans", Font.BOLD, 12);
JScrollPane scroll1 = new JScrollPane(ta1);
JScrollPane scroll2 = new JScrollPane(ta2);
//... Get the content pane, set layout, add to center
JPanel content = new JPanel();
content.setLayout(new BorderLayout());
content.add(scroll1, BorderLayout.WEST);
content.add(scroll2, BorderLayout.EAST);
content.add(b1);
// button b1 seaded
b1.addActionListener(this);
b1.setLocation(1, 5);
b1.setSize(2, 3);
// JTextArea ta1 seaded (vasak tekstiv2li)
ta1.setLocation(0, 0);
ta1.setSize(300, 200);
ta1.setLineWrap(true);
ta1.setFont(font);
// JTextArea ta2 seaded (parem tekstiv2li)
ta2.setLocation(55, 55);
ta2.setSize(300, 200);
ta2.setLineWrap(true);
ta2.setFont(font);
//... Set window characteristics.
this.setContentPane(content);
this.setTitle("Eesti keele korrigeerija");
//this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.pack();
}
public void actionPerformed(ActionEvent e) {
System.out.println("Vajutati");
String tekst = "";
tekst = ta1.gettext();
kuva = tekst;
ta2.setText(kuva);
} // End of actionPerformed
// <<<<<<<<<<<<<<<<
// <<<<< MAIN <<<<<
public static void main(String[] args) {
JFrame win = new oo9();
win.setVisible(true);
win.setLocation(0, 0);
win.setSize(700, 300);
} // End of main
} // End of file
I have seen many samples with same construction, but they dont work in browsers (I have uploaded them to my webspace). Please tell me if you know how to fix that problem.
EDIT:
I got the answer, I will soon post it here
Message was edited by:
Arvutis6ber