Im trying to make a simple scala applet from the following code:
import javax.swing._
object ScalaAppletMain extends JApplet{
val sa = new App
override def init(){
val pane = getContentPane()
pane.add("Center",sa)
}
override def start(){}
override def stop(){}
}
(please note that this code is heavily relaying on web examples and im only trying to learn how to do it) and the app class:
import javax.swing._
import java.awt._
class App extends JPanel {
var number = 2229999
initialize()
private def initialize() {
var text = new JLabel(number.toString)
v开发者_运维百科ar panel = new JPanel()
panel.setLayout(new BorderLayout(1,1))
panel.add(text)
add(panel)
}}
and the code for my html file:
<applet>
archive="ScalaAppletMain.class,app.class,scala-library.jar"
width="660"
height="500"
</applet>
however it doesnt work, any help please?
For a start the applet element should have the attributes inside the opening tag not the body.
<applet
archive="ScalaAppletMain.class,app.class,scala-library.jar"
width="660"
height="500">
</applet>
Then, to find any other issues, you're going to have to find the console output for your Java applet environment and look to see if it is logging any errors - they should give you a clue.
For example on the Mac, the Java Preferences app has an (Advanced) option to show the console when an Applet is loaded.
精彩评论