Exception in thread "main" java.lang.OutOfMemoryError: Java heap space JEditor Pane
Folks i have a simple program
mport java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.event.HyperlinkListener;
import javax.swing.event.HyperlinkEvent;
import java.util.*;
public class MyPanel extends JPanel implements HyperlinkListener {
private JEditorPane J;
private JTextArea jt;
public MyPanel() {
//construct components
J = new JEditorPane ();
jt=new JTextArea(5,5);
//adjust size and set layout
setPreferredSize (new Dimension (781, 508));
setLayout (null);
//add components
add (J);
add(jt);
StringBuffer sb = new StringBuffer();
sb.append("<a href=\"/Users/amjad\">Do the foo action</a><br>");
sb.append("<a href=\"/Users/amjad/Desktop\">Do the bar
thing</a><br>");
J.setText(sb.toString());
//set component bounds (only needed by Absolute Positioning)
J.setBounds (285, 70, 155, 135);
J.setContentType("text/html");
J.addHyperlinkListener(new MyPanel());
}
public void hyperlinkUpdate(HyperlinkEvent e) {
if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
StringTokenizer st = new StringTokenizer(e.getDescription(), "
");
if (st.hasMoreTokens()) {
String s = st.nextToken();
System.err.println("token: " + s);
}
}
}
public static void main (String[] args) {
JFrame frame = new JFrame ("MyPanel");
frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
frame.getContentPane().add (new MyPanel());
frame.pack();
frame.setVisible (true);
}
}
It compiles nicely. But when i run it it gives
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
Any solution