Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » How to use a TitleAreaDialog as main Window
How to use a TitleAreaDialog as main Window [message #448955] Sun, 16 January 2005 21:55 Go to next message
Thomas is currently offline ThomasFriend
Messages: 151
Registered: July 2009
Senior Member
I am really new to Eclipse and so I try out different things and run fro=
m =

on problem into another.

Today i wanted to use a TitleAreaDialog as main Window - the JVM crached=
.. =

here is the code snippet, that shows too, that I tried different things =
=

without success.


import org.eclipse.jface.dialogs.TitleAreaDialog;
import org.eclipse.swt.widgets.*;

public class Main
{ public static void main(String[] args)
{ //Display display =3D new Display();
//Shell shell =3D new Shell(display);
//shell.setSize(500, 500);
//shell.open();
=

TitleAreaDialog dlg =3D new TitleAreaDialog(new Shell());
//dlg.create();
dlg.setTitle("Test");
dlg.open();
=

//shell.dispose();
/*MessageBox m =3D new MessageBox(new Shell());
m.setMessage("Hello, World");
m.open();*/
}
}

The JVM Launcher crashes at the line
TitleAreaDialog dlg =3D new TitleAreaDialog(new Shell());
with the message
"Fatal exception occured.The program will exit"
The exception is:
"java.lang.NoClassDefFoundError: org/eclipse/core/runtime/IStatus
at Main.main(Main.java:25)"
That is the line described above.

Strange - if let run the message box comment out below the whole things =
=

work.
What did I do wrong ?
Are there any good online documentation that can explain me easy things =
=

like that ? I found documentation about SWT and JFrame classes - they ar=
e =

really good, but they just tell the functions and varibales, but not, ho=
w =

to create simple things. On the other side there are a lot of high compl=
ex =

examples - i just look for simple beginners examples to copy them and tr=
y =

them, before I start my own projects.

Thomas
Re: How to use a TitleAreaDialog as main Window [message #448957 is a reply to message #448955] Sun, 16 January 2005 22:39 Go to previous messageGo to next message
Victor is currently offline VictorFriend
Messages: 12
Registered: July 2009
Junior Member
Tomas,
i too am a beginner in these matters.
So much so that i really dont understand your problem.

I looked it up in my book, and i may even have the answer,
but i dont really understand it, so i cant even try it.
so i am passing it along, hopefully it will be helpful to you:

This is what my book says about TitleAreaDialog:

==================================================
you may be tempted to do this:

TitleAreaDialog dlg = new TitleAreaDialog(shell);
dlg.setMessage("Test message"); // WRONG!
dlg.open();

instead you have to do this:
===================
subclass TitleAreaDialog
and override its createContents() method.
Its signature looks like this:

protected Control createContents(Composite parent)

After calling the superclass's createContents()
(which creates the necessary controls),
call setMessage(), setTitleImage(),
or any of the other methods.
Your createContents() implementation might look like this:


protected Control createContents(Composite parent)
{
Control contents = super.createContents(parent);
setMessage("This is a TitleAreaDialog-derived dialog");
setTitle("My Dialog");
return contents;
}

good luck
Re: How to use a TitleAreaDialog as main Window [message #448960 is a reply to message #448955] Mon, 17 January 2005 01:12 Go to previous messageGo to next message
Thomas is currently offline ThomasFriend
Messages: 151
Registered: July 2009
Senior Member
To clarify some things:

It crashes with the following source code

> import org.eclipse.jface.dialogs.TitleAreaDialog;
> import org.eclipse.swt.widgets.*;
>
> public class Main
> { public static void main(String[] args)
> {
> TitleAreaDialog dlg =3D new TitleAreaDialog(new Shell());
> dlg.setTitle("Test");
> dlg.open();
> }
> }
>

It doesn't crash when I call a message dialog.

> import org.eclipse.jface.dialogs.TitleAreaDialog;
> import org.eclipse.swt.widgets.*;
>
> public class Main
> { public static void main(String[] args)
> { MessageBox m =3D new MessageBox(new Shell());
> m.setMessage("Hello, World");
> m.open();
> }
> }
Re: How to use a TitleAreaDialog as main Window [message #448962 is a reply to message #448960] Mon, 17 January 2005 04:03 Go to previous message
Eclipse UserFriend
Originally posted by: nickthat.yahoo.com

Thomas,
What you need to do is put a call like the following before you create
your TitleAreaDialog

new Display();

Nick

Thomas wrote:

> To clarify some things:

> It crashes with the following source code

>> import org.eclipse.jface.dialogs.TitleAreaDialog;
>> import org.eclipse.swt.widgets.*;
>>
>> public class Main
>> { public static void main(String[] args)
>> {
>> TitleAreaDialog dlg = new TitleAreaDialog(new Shell());
>> dlg.setTitle("Test");
>> dlg.open();
>> }
>> }
>>

> It doesn't crash when I call a message dialog.

>> import org.eclipse.jface.dialogs.TitleAreaDialog;
>> import org.eclipse.swt.widgets.*;
>>
>> public class Main
>> { public static void main(String[] args)
>> { MessageBox m = new MessageBox(new Shell());
>> m.setMessage("Hello, World");
>> m.open();
>> }
>> }
Previous Topic:Anyone used an SWT editor such as Swede?
Next Topic:Panic ! SWT kills the Java VM
Goto Forum:
  


Current Time: Wed Nov 13 22:15:04 GMT 2019

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

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

Back to the top