我正在使用JEditorPane
加载一个包含JButton
的HTML页面:
<object classid="javax.swing.JButton" value="Button"></object>
如何向JButton添加动作监听器?
我正在使用JEditorPane
加载一个包含JButton
的HTML页面:
<object classid="javax.swing.JButton" value="Button"></object>
import java.awt.event.*;
import javax.swing.JButton;
public class htmlButton extends JButton
{
public htmlButton()
{
addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent a)
{
System.out.println("HAI");
}
});
}
}
HTML部分:
<html>
<body>
<object classid="htmlButton" value="Button"></object> HAI
</body>
</html>
JEditorPane pan=new JEditorPane();
pan.setPage(new java.io.File("a.html").toURL());