In my JEditorPane I am loading an html page which has a JButton as:
<object classid="javax.swing.JButton" value="Button"></object>
How can i add an action listener to this JButton ?
Try This. first create a Custom Button as shown.
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 part:
<html>
<body>
<object classid="htmlButton" value="Button"></object> HAI
</body>
</html>
EditorPane Part
JEditorPane pan=new JEditorPane();
pan.setPage(new java.io.File("a.html").toURL());
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With