Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Newcomer:
Newcomer: [message #461395] Wed, 21 September 2005 20:35 Go to next message
Eclipse UserFriend
Originally posted by: info.zuehlke-it.de

I have the following problem, my application become over
"SGVstarter.main()" started.

The Code...
----------------------
public static void main(String[] args) {
Display display = new Display();
Shell topShell = new Shell(display);
topShell.setText("Schadensgutachten Verwaltung V.0");
topShell.setBackground(new Color(display, 160, 160, 255));
topShell.setSize(800, 600);
topShell.setLayout(new GridLayout());
topShell.setMenuBar(new ViewMenu(topShell).getMenu());

new ViewInit(topShell);
...
----------------------


Following one becomes "new ViewInit(topShell)" produced, in this
produced.... it follows now "stacklayout.topControl = inhalt[0];"

----------------------
public class ViewInit{

private static StackLayout stacklayout;
private static Composite[] inhalt = new Composite[5];
private static Composite container;
private static Composite compToolbar;

public ViewInit(Shell shell){
compToolbar = new Composite(shell,SWT.NONE);
GridLayout composite2Layout = new GridLayout();
GridData composite2LData = new GridData();
composite2LData.horizontalAlignment = GridData.FILL;
composite2LData.verticalAlignment = GridData.FILL;
compToolbar.setLayoutData(composite2LData);
compToolbar.setLayout(composite2Layout);
{
GridData toolBar1LData = new GridData();
ToolBar toolBar1 = new ToolBar(compToolbar,SWT.NONE);
toolBar1.setLayoutData(toolBar1LData);
{
ToolItem toolItem1 = new ToolItem(toolBar1,SWT.NONE);
toolItem1.setText("Vorgang");
toolItem1.addListener(SWT.Selection, new Listener()
{
public void handleEvent(Event e)
{
stacklayout.topControl = inhalt[0];
container.layout();
}
});
}
{
ToolItem toolItem2 = new ToolItem(toolBar1,SWT.NONE);
toolItem2.setText("Entschädigung");
toolItem2.addListener(SWT.Selection, new Listener()
{
public void handleEvent(Event e)
{
stacklayout.topControl = inhalt[1];
container.layout();
}
});
}
{
ToolItem toolItem3 = new ToolItem(toolBar1,SWT.NONE);
toolItem3.setText("Berichte");
}
.....

final Composite container = new Composite(shell, SWT.BORDER);
container.setLayoutData(new GridData());
final StackLayout stacklayout = new StackLayout();
container.setLayout(stacklayout);

inhalt[0] = new ViewVorgang(container).getComposite();
----------------------

in the following one produces...

----------------------
public class ViewVorgang extends Composite{
private static Composite comVorgang;

public Composite getComposite(){
return comVorgang;
}

public ViewVorgang(Composite compTop){
super (compTop, SWT.NONE);
comVorgang = new Composite(compTop, SWT.NONE);
GridLayout thisLayout = new GridLayout();
comVorgang.setLayout(thisLayout);
thisLayout.numColumns = 2;
{
...
----------------------

When i use the button "toolItem1", the I get "Exception in thread "main"
java.lang.NullPointerException".

Ok one, to which there is the "debug" mode in eclipse. I set the BREAK
POINT on "comVorgang = new Composite(compTop, SWT.NONE);", there get I
further window with the following message
"Class File Editor

Source not found
etc. etc ."

Which make I wrongly??

(Sorry, please excuses my English)
Re: Newcomer: [message #461397 is a reply to message #461395] Wed, 21 September 2005 21:24 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: richkulp.us.NO_SPAM.ibm.com

Erik Zuehlke wrote:
> ----------------------
> public class ViewInit{
>
> private static StackLayout stacklayout; private static Composite[]
> inhalt = new Composite[5];
> private static Composite container; private static Composite
> compToolbar;
> public ViewInit(Shell shell){
> toolItem1.addListener(SWT.Selection, new Listener()
> {
> public void handleEvent(Event e)
> {
> stacklayout.topControl = inhalt[0];
> container.layout();
>
> final Composite container = new Composite(shell, SWT.BORDER);
> container.setLayoutData(new GridData());
> final StackLayout stacklayout = new StackLayout();
> container.setLayout(stacklayout);
>
> inhalt[0] = new ViewVorgang(container).getComposite();

The problem is you are hiding container and stacklayout. First you made
a static instance called "container" and "stacklaout". Which you
probably shouldn't do. Statics for widgets in generally a bad idea.

Then you proceeded to create a variable called container and stacklayout
within the method and set it to final.

Now the container and stacklayout that are being referenced in the
toolItem1.addListener are referencing the static container and
stacklayout. It is not referencing the method's variables container and
stacklayout because the declaration for those in the method are AFTER
the usage of them in the listener. So the static variables will always
be null, and that is why you get the NPE.

You should get rid of the static variables and instead move the
addListener call to after the declarations of the final variables
stackLayout and container in the method so that they can be referenced
in the listener.
--
Thanks,
Rich Kulp
Re: Newcomer: Stacklayout, change a composite [message #461403 is a reply to message #461397] Thu, 22 September 2005 05:59 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: info.zuehlke-it.de

Since I only gradually JAVA (OOP), Eclipse and SWT to become acquainted
with, I will certainly produce still further of these errors:)

I had imagined, was however not not safe this already somehow me,
particularly since I had found also still no "complete" example of this
case.
I had the first beginning found under "Constructing SWT layout By Koray
Guclu (google)", but the code is only one fragment.

My background knowledge is not sufficient yet for the remainder.

In this case please I mean to excuse beginner questions, vocationally
program I still under COBOL, I only now change (36 years old) on the OOP
under Java, and in my limited spare time (father of 2 children:)

Thank Rich, I your thoughts will today times convert.
Re: next ...Size of Layout [message #461415 is a reply to message #461397] Thu, 22 September 2005 11:20 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: info.zuehlke-it.de

Rich, again thank you. Your references were very well, it functioned now
and I something to it-learned.

Now a further problem, neither under the "shell", has or the following
"composite" any statements of size made.

But a window with a firm size of the "toolBar" and the "container" appears
appears fundamental in the same size. Their sizes are however
substantially less than from the opened Shell.

The announcement of the Composite "inhalt[0]" functioned also, it fills
out the entire Composite "container". The announcement of "inhalt[1]"
however not, it is material larger than "inhalt[0]".

Changing "container" or "toolbar" does not have effect, also that packs
into an outside "composite" and the following thing sets the size has no
success.

Does someone have a tip, a suggestion?

(Sorry for my english, i use the translator from google, i hope you can
understand me ...)
Re: [other... lf/cr in posting] [message #461416 is a reply to message #461415] Thu, 22 September 2005 11:28 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: info.zuehlke-it.de

How can I force or produce lf/cr, with write from messages??

All my messages are sequentially stored :(

I use Firefox and the Webinterface from eclispe.org.
Re: [other... lf/cr in posting] TEST! [message #461420 is a reply to message #461416] Thu, 22 September 2005 11:56 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: info.zuehlke-it.de

A TEST -------- which see straight, in my last message is a CR. How can
be? I make a "CoPy/paste" from the translated announcement of google.
And insert then into "eclipse/webinterface" the CR.

This was the result...

A TEST
--------
which see straight, in my last message is a CR.
How can be?
I make a "Copy/paste" from the translated announcement of google.
And insert then into "eclipse/webinterface" the CR.

An another Test (with copy and past in vim, eding the cr into, and then
paste in this posting)
--------
A TEST
--------
which see straight, in my last message is a CR.
How can be?
I make a "CoPy/paste" from the translated announcement of google.
And insert then into "eclipse/webinterface" the CR, with the current
result.


(soory , for this test...)
Re: next ...Size of Layout [message #461432 is a reply to message #461415] Thu, 22 September 2005 16:04 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: richkulp.us.NO_SPAM.ibm.com

Look at:

http://eclipse.org/articles/Understanding%20Layouts/Understa nding%20Layouts.htm

This explains layouts in SWT.

--
Thanks,
Rich Kulp
Re: [other... lf/cr in posting] TEST! [message #461433 is a reply to message #461420] Thu, 22 September 2005 16:05 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: richkulp.us.NO_SPAM.ibm.com

I don't know what you mean.

--
Thanks,
Rich Kulp
Re: [other... lf/cr in posting] TEST! [message #461444 is a reply to message #461433] Fri, 23 September 2005 08:40 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: info.zuehlke-it.de

Please excuse the confusion.

With direct copy/paste of mine translate text into the Webinferace of
eclipse/newsgroup and the following edit, my line pagings are lost.

Only if I copy, there work on and afterwards into the Web interface copy
the whole in a VIM editor, is all OK ONE!

It was only one test of me.
Re: next ...Size of Layout [message #461445 is a reply to message #461432] Fri, 23 September 2005 09:16 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: info.zuehlke-it.de

Thank you for the reference, is a large article article.

It helped me very well. My error was the following, I has to everything
only with Jigloo the surfaces developed, afterwards has I with CoPy/paste
tries an application too wrote, with my partially very incomplete
knowledge of JAVA, now I had noticed it, much I promptly on the nose.

I now looked at and had the code still once to determine, which was it any
errors as at the beginning of my message.

Logically wrongly positioned doubly variable declaration calls etc. etc..

Thanks, I get along now already much better.
Re: [other... lf/cr in posting] TEST! [message #461458 is a reply to message #461444] Fri, 23 September 2005 14:38 Go to previous message
Eclipse UserFriend
Originally posted by: richkulp.us.NO_SPAM.ibm.com

I can't help you here. I use Thunderbird and have no problems.


--
Thanks,
Rich Kulp
Previous Topic:[KTable] New Release 2.0
Next Topic:How to control shell size?
Goto Forum:
  


Current Time: Thu Mar 28 16:10:50 GMT 2024

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

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

Back to the top