Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » (Eclipse Forms) FormText.setText() crash
(Eclipse Forms) FormText.setText() crash [message #443465] Fri, 24 September 2004 21:34 Go to next message
Jaakko Lindvall is currently offline Jaakko LindvallFriend
Messages: 9
Registered: July 2009
Junior Member
Hi,

I've been following the examples from the excellent Eclipse Forms guide
found in
http://dev.eclipse.org/viewcvs/index.cgi/~checkout~/pde-ui-h ome/working/EclipseForms/EclipseForms.html.
I've noticed that whenever I try to pass in a String that contains an URL
to FormText's setText() method, the program crashes. The same crash also
occurs if I use <form>-tags and describe the link using <a href..>.

The following test case is essentially the same as the example found in
the guide:

import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.*;
import org.eclipse.ui.forms.widgets.*;

public class FormsCrashTest
{
public static void main(String args[])
{
Display display = new Display();
Shell shell = new Shell();
shell.setLayout(new GridLayout(1, false));

FormToolkit toolkit = new FormToolkit(Display.getCurrent());
Form form = toolkit.createForm(shell);
TableWrapLayout layout = new TableWrapLayout();
form.getBody().setLayout(layout);

FormText rtext = toolkit.createFormText(form.getBody(), true);

String data = "Plain text, http://www.eclipse.org";
// String data2 = "Plain text only"; // Doesn't crash with this
rtext.setText(data, false, true); // Tag detection off, hyperlink
detection on

shell.pack();
shell.open();
while (!shell.isDisposed())
{
if (!display.readAndDispatch())
{
display.sleep();
}
}
display.dispose();
}
}

When I run this program, I get this stack trace:

java.lang.NullPointerException
at java.util.Hashtable.put(Unknown Source)
at
org.eclipse.ui.internal.forms.widgets.HyperlinkSegment.paint (HyperlinkSegment.java:45)
at
org.eclipse.ui.internal.forms.widgets.Paragraph.paint(Paragr aph.java:151)
at org.eclipse.ui.forms.widgets.FormText.paint(FormText.java:80 0)
at org.eclipse.ui.forms.widgets.FormText.access$3(FormText.java :762)
at org.eclipse.ui.forms.widgets.FormText$2.paintControl(FormTex t.java:226)
at
org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListe ner.java:82)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java :82)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:796)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:820)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:805)
at org.eclipse.swt.widgets.Composite.WM_PAINT(Composite.java:80 3)
at org.eclipse.swt.widgets.Control.windowProc(Control.java:3020 )
at org.eclipse.swt.widgets.Display.windowProc(Display.java:3338 )
at org.eclipse.swt.internal.win32.OS.UpdateWindow(Native Method)
at org.eclipse.swt.widgets.Decorations.setVisible(Decorations.j ava:1213)
at org.eclipse.swt.widgets.Shell.setVisible(Shell.java:1175)
at org.eclipse.swt.widgets.Shell.open(Shell.java:767)
at org.verkel.apps.test.swt.FormsCrashTest.main(FormsCrashTest. java:27)

My environment is Windows XP and I'm using Eclipse 3.0.


Thanks in advance,

Jaakko Lindvall
Re: (Eclipse Forms) FormText.setText() crash [message #443539 is a reply to message #443465] Mon, 27 September 2004 17:21 Go to previous message
Jaakko Lindvall is currently offline Jaakko LindvallFriend
Messages: 9
Registered: July 2009
Junior Member
On Sat, 25 Sep 2004 00:34:35 +0300, Jaakko Lindvall
<jaakko.lindvall@pp.inet.fi> wrote:

> Hi,
>
> I've been following the examples from the excellent Eclipse Forms guide
> found in
> http://dev.eclipse.org/viewcvs/index.cgi/~checkout~/pde-ui-h ome/working/EclipseForms/EclipseForms.html.
> I've noticed that whenever I try to pass in a String that contains an
> URL to FormText's setText() method, the program crashes. The same crash
> also occurs if I use <form>-tags and describe the link using <a href..>.
>

Figured this one out. The FormText instance apparently did not have color
to use for hyperlink foreground, so I created an HyperlinkSettings
instance, set the foreground and passed it to the FormText. This, however,
wasn't really indicated in the tutorial.
Previous Topic:Minimize vs. close on Pocket PC
Next Topic:Problem using Scrolled Composite
Goto Forum:
  


Current Time: Tue Apr 16 07:59:58 GMT 2024

Powered by FUDForum. Page generated in 0.32447 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top