Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Creating own widget from SWT Label
Creating own widget from SWT Label [message #445208] Thu, 28 October 2004 12:58 Go to next message
Francois is currently offline FrancoisFriend
Messages: 7
Registered: July 2009
Junior Member
Hi, I have a problem I think simple for SWT initiated.

My problem is the following, I am building an application with custom
widgets on 3 level of components:
1st level: public class Buttons extends Composite, to create custom
buttons for my application. In this class, I create a new Label(...) with
a variable text and image assigned (already implemented and working) to
simulate a button. The simulation is only switch the image of the Label,
while my images already do the "push" like button style;
2nd level: public class Keypad , instanciating a set of my custom new
Buttons(...) positionned. This level gives a position for each Buttons of
the set.
3rd level: public class MyApp, the main() with a display 800X600 and a
shell instanciating new Keypad() that is suppose to bring visible all
Buttons of the second level at the good position and image set.

As I have seen in some example, it's not recommended to extend a Label
but extend a Composite instanciating the control we want to use. Thats
what I did. But when I want to instanciate a new Label in my widget I
must add some parameters, like it's suggested :
label = new Label(this,0);
At first, it's seems strange to me, as new beginner in Java, because the
supposed parameter to put in a new Label is not the shell???
Anyway... when I do that, my custom Buttons are well displayed, good
position, good image at the right place, but no event are accessible from
the main shell, because I think there is no reference to my shell at all!
So, what I did was to pass the main shell in up to the constructor of my
Buttons and use it in the :
label = new Label(shell,0); (or Composite parent as seen in many example).
When I do that, my custom Buttons looklike to have their grey frame at the
good emplacement, with events working, but all the images of the buttons
are displayed in the top-left corner one over the other. And I realy
don't understand why!!!!

I followed the main lines of "Writing your own widgets" in www.eclipse.org
articles, and test a lot of other things with always the same result. Do
you have any idea what could be my problem?

Help! :)


... hum two last thing:
Is there any way to avoid flicking when display image in a shell?
Is there any way to do a widget modal as a display dialog?

Thanks a lot !!
Re: Creating own widget from SWT Label [message #445221 is a reply to message #445208] Thu, 28 October 2004 14:08 Go to previous messageGo to next message
Steve Northover is currently offline Steve NorthoverFriend
Messages: 1636
Registered: July 2009
Senior Member
This just sounds like you have a programming error. Are you adding
listeners and creating your custom control using the right parent in the
constructor? We can't really do much without a simple stand alone example
that shows what you are doing.

"Francois" <francoislamothe@hotmail.com> wrote in message
news:clqqd0$q2v$1@eclipse.org...
> Hi, I have a problem I think simple for SWT initiated.
>
> My problem is the following, I am building an application with custom
> widgets on 3 level of components:
> 1st level: public class Buttons extends Composite, to create custom
> buttons for my application. In this class, I create a new Label(...) with
> a variable text and image assigned (already implemented and working) to
> simulate a button. The simulation is only switch the image of the Label,
> while my images already do the "push" like button style;
> 2nd level: public class Keypad , instanciating a set of my custom new
> Buttons(...) positionned. This level gives a position for each Buttons of
> the set.
> 3rd level: public class MyApp, the main() with a display 800X600 and a
> shell instanciating new Keypad() that is suppose to bring visible all
> Buttons of the second level at the good position and image set.
>
> As I have seen in some example, it's not recommended to extend a Label
> but extend a Composite instanciating the control we want to use. Thats
> what I did. But when I want to instanciate a new Label in my widget I
> must add some parameters, like it's suggested :
> label = new Label(this,0);
> At first, it's seems strange to me, as new beginner in Java, because the
> supposed parameter to put in a new Label is not the shell???
> Anyway... when I do that, my custom Buttons are well displayed, good
> position, good image at the right place, but no event are accessible from
> the main shell, because I think there is no reference to my shell at all!
> So, what I did was to pass the main shell in up to the constructor of my
> Buttons and use it in the :
> label = new Label(shell,0); (or Composite parent as seen in many
example).
> When I do that, my custom Buttons looklike to have their grey frame at the
> good emplacement, with events working, but all the images of the buttons
> are displayed in the top-left corner one over the other. And I realy
> don't understand why!!!!
>
> I followed the main lines of "Writing your own widgets" in www.eclipse.org
> articles, and test a lot of other things with always the same result. Do
> you have any idea what could be my problem?
>
> Help! :)
>
>
> .. hum two last thing:
> Is there any way to avoid flicking when display image in a shell?
> Is there any way to do a widget modal as a display dialog?
>
> Thanks a lot !!
>
Re: Creating own widget from SWT Label [message #445224 is a reply to message #445221] Thu, 28 October 2004 15:17 Go to previous messageGo to next message
Francois is currently offline FrancoisFriend
Messages: 7
Registered: July 2009
Junior Member
Ok, so there is a sample...


The first level:
public class Buttons extends Composite
{
public static final int BUTTON1 = 1;

public Label image;

// my Buttons attributes
private int width;
private int height;
private int state;
private String img_src[] = {"",""}; // img_src[0]=off, img_src[1]=on

public Buttons(Composite parent, int style, int byttonType)
{
super(parent, style);

image = new Label(parent,style); // with this one, label background
// all appears at the right place
// and all mouse event work, but
// all the image appears in the
top
// left corner, the first packed
on
// the top
//image = new Label(this,style); // with this one, label background
// all appears at the right place,
// and image in the correspondant
// label, but no mouse event are
// working

// Switch on the button type removed here
width = 74;
height = 78;
state = OFF;
img_src[OFF]= "/root/workspace/images/buttons/button_off.png";
img_src[ON]= "/root/workspace/images/buttons/button_on.png";

// Add an event listener for mouse down only in this case...
addMouseListener(new MouseAdapter()
{
public void mouseDown(MouseEvent event)
{
if (event.button==1) // left button
{
Buttons.this.mouseDown(event);
}
}
});

}
// Other public functions
public void setBtnState(int new_state)
{
this.state = new_state;
}

public String getImagePath()
{
return this.img_src[this.state];
}

public void setImage(Image i)
{
this.image.setImage(i);
}

public int getWidth()
{
return this.width;
}

public int getHeight()
{
return this.height;
}

public void pack()
{
this.image.pack();
}


// Event handling stuff... working well and tested so didn't copy
// this part

public class ButtonsClickedEvent extends java.util.EventObject
{
// ...
}// ...
}

Second level:

public class Keypad
{
Buttons button0;
// Buttons 1-9...

Image i;

public Keypad(Shell shell)
{
button0 = new Buttons (shell, SWT.NONE, Buttons.BUTTON1);
button0.setBtnState(0);

// Set the good image to the label
i = new Image(display,button0.getImagePath());
button0.setImage(i);

// Positionning the button
button0.setBounds(300,100,button0.getWidth(), button0.getHeight());

// Add listener to the button0
button0.addButtonsClickedListener(new ButtonsClickedListener()
{
public void buttonClicked(ButtonsClickedEvent event)
{
System.out.println("button 1 clicked ");
/* stuff*/
}
});

button0.pack();
}

Third level:
public class MyApp
{
//Main window application
public static Display display;
public static Shell shell;
private static final int app_width = 810;
private static final int app_height = 630;

public static Keypad keypad;

public static void main(String[] args)
{

MyApp app = new MyApp();
shell.setBounds(0,0, app_width app_height);

// Calling my Keypad
keypad = new Keypad(shell);

// here adding a background to see the background of label in
keypad
// ...

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

public QuatroApp()
{
display = new Display();
shell = new Shell(display);
}
}
/*****************************************************/

Steve Northover wrote:

> This just sounds like you have a programming error. Are you adding
> listeners and creating your custom control using the right parent in the
> constructor? We can't really do much without a simple stand alone example
> that shows what you are doing.

> "Francois" <francoislamothe@hotmail.com> wrote in message
> news:clqqd0$q2v$1@eclipse.org...
> > Hi, I have a problem I think simple for SWT initiated.
> >
> > My problem is the following, I am building an application with custom
> > widgets on 3 level of components:
> > 1st level: public class Buttons extends Composite, to create custom
> > buttons for my application. In this class, I create a new Label(...) with
> > a variable text and image assigned (already implemented and working) to
> > simulate a button. The simulation is only switch the image of the Label,
> > while my images already do the "push" like button style;
> > 2nd level: public class Keypad , instanciating a set of my custom new
> > Buttons(...) positionned. This level gives a position for each Buttons of
> > the set.
> > 3rd level: public class MyApp, the main() with a display 800X600 and a
> > shell instanciating new Keypad() that is suppose to bring visible all
> > Buttons of the second level at the good position and image set.
> >
> > As I have seen in some example, it's not recommended to extend a Label
> > but extend a Composite instanciating the control we want to use. Thats
> > what I did. But when I want to instanciate a new Label in my widget I
> > must add some parameters, like it's suggested :
> > label = new Label(this,0);
> > At first, it's seems strange to me, as new beginner in Java, because the
> > supposed parameter to put in a new Label is not the shell???
> > Anyway... when I do that, my custom Buttons are well displayed, good
> > position, good image at the right place, but no event are accessible from
> > the main shell, because I think there is no reference to my shell at all!
> > So, what I did was to pass the main shell in up to the constructor of my
> > Buttons and use it in the :
> > label = new Label(shell,0); (or Composite parent as seen in many
> example).
> > When I do that, my custom Buttons looklike to have their grey frame at the
> > good emplacement, with events working, but all the images of the buttons
> > are displayed in the top-left corner one over the other. And I realy
> > don't understand why!!!!
> >
> > I followed the main lines of "Writing your own widgets" in www.eclipse.org
> > articles, and test a lot of other things with always the same result. Do
> > you have any idea what could be my problem?
> >
> > Help! :)
> >
> >
> > .. hum two last thing:
> > Is there any way to avoid flicking when display image in a shell?
> > Is there any way to do a widget modal as a display dialog?
> >
> > Thanks a lot !!
> >
Re: Creating own widget from SWT Label [message #445242 is a reply to message #445224] Fri, 29 October 2004 14:20 Go to previous messageGo to next message
Veronika Irvine is currently offline Veronika IrvineFriend
Messages: 1272
Registered: July 2009
Senior Member
The following is the right way to create your label, you should not create
widgets in your parent because you have no idea what sort of layout the
parent may use.

//image = new Label(this,style); // with this one, label background
// all appears at the right place,
// and image in the correspondant
// label, but no mouse event are
// working

To get the mouse events, you need to add the mouse listener to the Label and
resend the mouse event from Buttons using notifyListeners. NOTE: You really
shouldn't be listening for low level events like MouseDown on Buttons in
your applcaition because this results in an inaccessible widget - your
application should instead look for events like Selection and Buttons should
fire the Selection event for a mouse action and a keyboard action:

public class Buttons extends Composite
{
....
public Buttons(Composite parent, int style, int byttonType) {
super(parent, style);
image = new Label(this,style);
image.addListener(SWT.MouseDown, new Listener() {
public void handleEvent(Event e) {
Event event = new Event();
event.widget = Buttons.this;
event.time = e.time;
Buttons.this.notifyListeners(SWT.Selection, event);
}
});
image.addListener(SWT.KeyDown, new Listener() {
public void handleEvent(Event e) {
if (event.character == ' ') {
Event event = new Event();
event.widget = Buttons.this;
event.time = e.time;
Buttons.this.notifyListeners(SWT.Selection, event);
}
}
});

...
}
public void addSelectionListener(SelectionListener listener) {
checkWidget();
if (listener == null) {
SWT.error(SWT.ERROR_NULL_ARGUMENT);
}
TypedListener typedListener = new TypedListener(listener);
addListener(SWT.Selection, typedListener);
addListener(SWT.DefaultSelection, typedListener);
}
}



"Francois" <francoislamothe@hotmail.com> wrote in message
news:clr2it$edo$1@eclipse.org...
> Ok, so there is a sample...
>
>
> The first level:
> public class Buttons extends Composite
> {
> public static final int BUTTON1 = 1;
>
> public Label image;
>
> // my Buttons attributes
> private int width;
> private int height;
> private int state;
> private String img_src[] = {"",""}; // img_src[0]=off, img_src[1]=on
>
> public Buttons(Composite parent, int style, int byttonType)
> {
> super(parent, style);
>
> image = new Label(parent,style); // with this one, label background
> // all appears at the right place
> // and all mouse event work, but
> // all the image appears in the
> top
> // left corner, the first packed
> on
> // the top
> //image = new Label(this,style); // with this one, label background
> // all appears at the right place,
> // and image in the correspondant
> // label, but no mouse event are
> // working
>
> // Switch on the button type removed here
> width = 74;
> height = 78;
> state = OFF;
> img_src[OFF]= "/root/workspace/images/buttons/button_off.png";
> img_src[ON]= "/root/workspace/images/buttons/button_on.png";
>
> // Add an event listener for mouse down only in this case...
> addMouseListener(new MouseAdapter()
> {
> public void mouseDown(MouseEvent event)
> {
> if (event.button==1) // left button
> {
> Buttons.this.mouseDown(event);
> }
> }
> });
>
> }
> // Other public functions
> public void setBtnState(int new_state)
> {
> this.state = new_state;
> }
>
> public String getImagePath()
> {
> return this.img_src[this.state];
> }
>
> public void setImage(Image i)
> {
> this.image.setImage(i);
> }
>
> public int getWidth()
> {
> return this.width;
> }
>
> public int getHeight()
> {
> return this.height;
> }
>
> public void pack()
> {
> this.image.pack();
> }
>
>
> // Event handling stuff... working well and tested so didn't copy
> // this part
>
> public class ButtonsClickedEvent extends java.util.EventObject
> {
> // ...
> }// ...
> }
>
> Second level:
>
> public class Keypad
> {
> Buttons button0;
> // Buttons 1-9...
>
> Image i;
>
> public Keypad(Shell shell)
> {
> button0 = new Buttons (shell, SWT.NONE, Buttons.BUTTON1);
> button0.setBtnState(0);
>
> // Set the good image to the label
> i = new Image(display,button0.getImagePath());
> button0.setImage(i);
>
> // Positionning the button
> button0.setBounds(300,100,button0.getWidth(), button0.getHeight());
>
> // Add listener to the button0
> button0.addButtonsClickedListener(new ButtonsClickedListener()
> {
> public void buttonClicked(ButtonsClickedEvent event)
> {
> System.out.println("button 1 clicked ");
> /* stuff*/
> }
> });
>
> button0.pack();
> }
>
> Third level:
> public class MyApp
> {
> //Main window application
> public static Display display;
> public static Shell shell;
> private static final int app_width = 810;
> private static final int app_height = 630;
>
> public static Keypad keypad;
>
> public static void main(String[] args)
> {
>
> MyApp app = new MyApp();
> shell.setBounds(0,0, app_width app_height);
>
> // Calling my Keypad
> keypad = new Keypad(shell);
>
> // here adding a background to see the background of label in
> keypad
> // ...
>
> shell.open();
> while(!shell.isDisposed())
> {
> if(!display.readAndDispatch())
> {
> display.sleep();
> }
> }
> display.dispose();
> // other dispose...
> }
>
> public QuatroApp()
> {
> display = new Display();
> shell = new Shell(display);
> }
> }
> /*****************************************************/
>
> Steve Northover wrote:
>
>> This just sounds like you have a programming error. Are you adding
>> listeners and creating your custom control using the right parent in the
>> constructor? We can't really do much without a simple stand alone
>> example
>> that shows what you are doing.
>
>> "Francois" <francoislamothe@hotmail.com> wrote in message
>> news:clqqd0$q2v$1@eclipse.org...
>> > Hi, I have a problem I think simple for SWT initiated.
>> >
>> > My problem is the following, I am building an application with custom
>> > widgets on 3 level of components:
>> > 1st level: public class Buttons extends Composite, to create custom
>> > buttons for my application. In this class, I create a new Label(...)
>> > with
>> > a variable text and image assigned (already implemented and working) to
>> > simulate a button. The simulation is only switch the image of the
>> > Label,
>> > while my images already do the "push" like button style;
>> > 2nd level: public class Keypad , instanciating a set of my custom new
>> > Buttons(...) positionned. This level gives a position for each Buttons
>> > of
>> > the set.
>> > 3rd level: public class MyApp, the main() with a display 800X600 and a
>> > shell instanciating new Keypad() that is suppose to bring visible all
>> > Buttons of the second level at the good position and image set.
>> >
>> > As I have seen in some example, it's not recommended to extend a Label
>> > but extend a Composite instanciating the control we want to use. Thats
>> > what I did. But when I want to instanciate a new Label in my widget I
>> > must add some parameters, like it's suggested :
>> > label = new Label(this,0);
>> > At first, it's seems strange to me, as new beginner in Java, because
>> > the
>> > supposed parameter to put in a new Label is not the shell???
>> > Anyway... when I do that, my custom Buttons are well displayed, good
>> > position, good image at the right place, but no event are accessible
>> > from
>> > the main shell, because I think there is no reference to my shell at
>> > all!
>> > So, what I did was to pass the main shell in up to the constructor of
>> > my
>> > Buttons and use it in the :
>> > label = new Label(shell,0); (or Composite parent as seen in many
>> example).
>> > When I do that, my custom Buttons looklike to have their grey frame at
>> > the
>> > good emplacement, with events working, but all the images of the
>> > buttons
>> > are displayed in the top-left corner one over the other. And I realy
>> > don't understand why!!!!
>> >
>> > I followed the main lines of "Writing your own widgets" in
>> > www.eclipse.org
>> > articles, and test a lot of other things with always the same result.
>> > Do
>> > you have any idea what could be my problem?
>> >
>> > Help! :)
>> >
>> >
>> > .. hum two last thing:
>> > Is there any way to avoid flicking when display image in a shell?
>> > Is there any way to do a widget modal as a display dialog?
>> >
>> > Thanks a lot !!
>> >
>
>
Re: Creating own widget from SWT Label [message #445314 is a reply to message #445242] Mon, 01 November 2004 18:46 Go to previous message
Francois is currently offline FrancoisFriend
Messages: 7
Registered: July 2009
Junior Member
Thank you Veronika :) That is working very well.

Veronika Irvine wrote:

> The following is the right way to create your label, you should not create
> widgets in your parent because you have no idea what sort of layout the
> parent may use.

> //image = new Label(this,style); // with this one, label background
> // all appears at the right place,
> // and image in the correspondant
> // label, but no mouse event are
> // working

> To get the mouse events, you need to add the mouse listener to the Label and
> resend the mouse event from Buttons using notifyListeners. NOTE: You really
> shouldn't be listening for low level events like MouseDown on Buttons in
> your applcaition because this results in an inaccessible widget - your
> application should instead look for events like Selection and Buttons should
> fire the Selection event for a mouse action and a keyboard action:

> public class Buttons extends Composite
> {
> ....
> public Buttons(Composite parent, int style, int byttonType) {
> super(parent, style);
> image = new Label(this,style);
> image.addListener(SWT.MouseDown, new Listener() {
> public void handleEvent(Event e) {
> Event event = new Event();
> event.widget = Buttons.this;
> event.time = e.time;
> Buttons.this.notifyListeners(SWT.Selection, event);
> }
> });
> image.addListener(SWT.KeyDown, new Listener() {
> public void handleEvent(Event e) {
> if (event.character == ' ') {
> Event event = new Event();
> event.widget = Buttons.this;
> event.time = e.time;
> Buttons.this.notifyListeners(SWT.Selection, event);
> }
> }
> });

> ...
> }
> public void addSelectionListener(SelectionListener listener) {
> checkWidget();
> if (listener == null) {
> SWT.error(SWT.ERROR_NULL_ARGUMENT);
> }
> TypedListener typedListener = new TypedListener(listener);
> addListener(SWT.Selection, typedListener);
> addListener(SWT.DefaultSelection, typedListener);
> }
> }



> "Francois" <francoislamothe@hotmail.com> wrote in message
> news:clr2it$edo$1@eclipse.org...
> > Ok, so there is a sample...
> >
> >
> > The first level:
> > public class Buttons extends Composite
> > {
> > public static final int BUTTON1 = 1;
> >
> > public Label image;
> >
> > // my Buttons attributes
> > private int width;
> > private int height;
> > private int state;
> > private String img_src[] = {"",""}; // img_src[0]=off, img_src[1]=on
> >
> > public Buttons(Composite parent, int style, int byttonType)
> > {
> > super(parent, style);
> >
> > image = new Label(parent,style); // with this one, label background
> > // all appears at the right place
> > // and all mouse event work, but
> > // all the image appears in the
> > top
> > // left corner, the first packed
> > on
> > // the top
> > //image = new Label(this,style); // with this one, label background
> > // all appears at the right place,
> > // and image in the correspondant
> > // label, but no mouse event are
> > // working
> >
> > // Switch on the button type removed here
> > width = 74;
> > height = 78;
> > state = OFF;
> > img_src[OFF]= "/root/workspace/images/buttons/button_off.png";
> > img_src[ON]= "/root/workspace/images/buttons/button_on.png";
> >
> > // Add an event listener for mouse down only in this case...
> > addMouseListener(new MouseAdapter()
> > {
> > public void mouseDown(MouseEvent event)
> > {
> > if (event.button==1) // left button
> > {
> > Buttons.this.mouseDown(event);
> > }
> > }
> > });
> >
> > }
> > // Other public functions
> > public void setBtnState(int new_state)
> > {
> > this.state = new_state;
> > }
> >
> > public String getImagePath()
> > {
> > return this.img_src[this.state];
> > }
> >
> > public void setImage(Image i)
> > {
> > this.image.setImage(i);
> > }
> >
> > public int getWidth()
> > {
> > return this.width;
> > }
> >
> > public int getHeight()
> > {
> > return this.height;
> > }
> >
> > public void pack()
> > {
> > this.image.pack();
> > }
> >
> >
> > // Event handling stuff... working well and tested so didn't copy
> > // this part
> >
> > public class ButtonsClickedEvent extends java.util.EventObject
> > {
> > // ...
> > }// ...
> > }
> >
> > Second level:
> >
> > public class Keypad
> > {
> > Buttons button0;
> > // Buttons 1-9...
> >
> > Image i;
> >
> > public Keypad(Shell shell)
> > {
> > button0 = new Buttons (shell, SWT.NONE, Buttons.BUTTON1);
> > button0.setBtnState(0);
> >
> > // Set the good image to the label
> > i = new Image(display,button0.getImagePath());
> > button0.setImage(i);
> >
> > // Positionning the button
> > button0.setBounds(300,100,button0.getWidth(), button0.getHeight());
> >
> > // Add listener to the button0
> > button0.addButtonsClickedListener(new ButtonsClickedListener()
> > {
> > public void buttonClicked(ButtonsClickedEvent event)
> > {
> > System.out.println("button 1 clicked ");
> > /* stuff*/
> > }
> > });
> >
> > button0.pack();
> > }
> >
> > Third level:
> > public class MyApp
> > {
> > //Main window application
> > public static Display display;
> > public static Shell shell;
> > private static final int app_width = 810;
> > private static final int app_height = 630;
> >
> > public static Keypad keypad;
> >
> > public static void main(String[] args)
> > {
> >
> > MyApp app = new MyApp();
> > shell.setBounds(0,0, app_width app_height);
> >
> > // Calling my Keypad
> > keypad = new Keypad(shell);
> >
> > // here adding a background to see the background of label in
> > keypad
> > // ...
> >
> > shell.open();
> > while(!shell.isDisposed())
> > {
> > if(!display.readAndDispatch())
> > {
> > display.sleep();
> > }
> > }
> > display.dispose();
> > // other dispose...
> > }
> >
> > public QuatroApp()
> > {
> > display = new Display();
> > shell = new Shell(display);
> > }
> > }
> > /*****************************************************/
> >
> > Steve Northover wrote:
> >
> >> This just sounds like you have a programming error. Are you adding
> >> listeners and creating your custom control using the right parent in the
> >> constructor? We can't really do much without a simple stand alone
> >> example
> >> that shows what you are doing.
> >
> >> "Francois" <francoislamothe@hotmail.com> wrote in message
> >> news:clqqd0$q2v$1@eclipse.org...
> >> > Hi, I have a problem I think simple for SWT initiated.
> >> >
> >> > My problem is the following, I am building an application with custom
> >> > widgets on 3 level of components:
> >> > 1st level: public class Buttons extends Composite, to create custom
> >> > buttons for my application. In this class, I create a new Label(...)
> >> > with
> >> > a variable text and image assigned (already implemented and working) to
> >> > simulate a button. The simulation is only switch the image of the
> >> > Label,
> >> > while my images already do the "push" like button style;
> >> > 2nd level: public class Keypad , instanciating a set of my custom new
> >> > Buttons(...) positionned. This level gives a position for each Buttons
> >> > of
> >> > the set.
> >> > 3rd level: public class MyApp, the main() with a display 800X600 and a
> >> > shell instanciating new Keypad() that is suppose to bring visible all
> >> > Buttons of the second level at the good position and image set.
> >> >
> >> > As I have seen in some example, it's not recommended to extend a Label
> >> > but extend a Composite instanciating the control we want to use. Thats
> >> > what I did. But when I want to instanciate a new Label in my widget I
> >> > must add some parameters, like it's suggested :
> >> > label = new Label(this,0);
> >> > At first, it's seems strange to me, as new beginner in Java, because
> >> > the
> >> > supposed parameter to put in a new Label is not the shell???
> >> > Anyway... when I do that, my custom Buttons are well displayed, good
> >> > position, good image at the right place, but no event are accessible
> >> > from
> >> > the main shell, because I think there is no reference to my shell at
> >> > all!
> >> > So, what I did was to pass the main shell in up to the constructor of
> >> > my
> >> > Buttons and use it in the :
> >> > label = new Label(shell,0); (or Composite parent as seen in many
> >> example).
> >> > When I do that, my custom Buttons looklike to have their grey frame at
> >> > the
> >> > good emplacement, with events working, but all the images of the
> >> > buttons
> >> > are displayed in the top-left corner one over the other. And I realy
> >> > don't understand why!!!!
> >> >
> >> > I followed the main lines of "Writing your own widgets" in
> >> > www.eclipse.org
> >> > articles, and test a lot of other things with always the same result.
> >> > Do
> >> > you have any idea what could be my problem?
> >> >
> >> > Help! :)
> >> >
> >> >
> >> > .. hum two last thing:
> >> > Is there any way to avoid flicking when display image in a shell?
> >> > Is there any way to do a widget modal as a display dialog?
> >> >
> >> > Thanks a lot !!
> >> >
> >
> >
Previous Topic:Can't get Bidi to work like StyledText
Next Topic:Manipulating images
Goto Forum:
  


Current Time: Thu Apr 18 08:43:03 GMT 2024

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