0
我创建了一个java代码(jframe),但我试图将它转换为applet,以便它可以出现在html网页上。由于我对Java编码不太熟悉,因此遇到了困难。将J帧转换为JApplet
这是迄今为止代码:
/**
* Implements a program with a pie chart
* that shows interactive polling results for three candidates
*/
import java.awt.*;
import javax.swing.*;
public class Poll extends JApplet {
public void init() {
public Poll()
{
super("Vote for Pat, Ismail, or Clair");
Container c = getContentPane();
c.setBackground(Color.WHITE);
PollDisplayPanel chart = new PollDisplayPanel("Pat", "Ismail", "Clair");
PollControlPanel controls = new PollControlPanel(chart);
c.add(chart, BorderLayout.CENTER);
c.add(controls, BorderLayout.SOUTH);
Poll w = new Poll();
}
}
}
这是原来的JFrame代码
/**
* Implements a program with a pie chart
* that shows interactive polling results for three candidates
*/
import java.awt.*;
import javax.swing.*;
public class Poll extends JFrame
{
public Poll()
{
super("Vote for Pat, Ismail, or Clair");
Container c = getContentPane();
c.setBackground(Color.WHITE);
PollDisplayPanel chart = new PollDisplayPanel("Pat", "Ismail", "Clair");
PollControlPanel controls = new PollControlPanel(chart);
c.add(chart, BorderLayout.CENTER);
c.add(controls, BorderLayout.SOUTH);
}
public static void main(String[] args)
{
Poll w = new Poll();}
w.setBounds(300, 300, 400, 400);
w.setDefaultCloseOperation(EXIT_ON_CLOSE);
w.setVisible(true);
}
}
顺便说一下,在哪里'PollDisplayPanel'和其他类? – Arvind
编码是人类为人类发明的。随之而来的是格式化的责任。因为上帝不懂代码,所以我们不能把这个留给上帝。 – randominstanceOfLivingThing
1)请参阅[不支持Java插件的支持](http://www.gizmodo.com.au/2016/01/rest-in-hell-java-plug-in/)和[转移到无插件Web] (https://blogs.oracle.com/java-platform-group/entry/moving_to_a_plugin_free)。 2)部署Java桌面应用程序的最佳方式是使用[Java Web Start](http://stackoverflow.com/tags/java-web-start/info)。 –