[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Newsgroup Home]
|
[news.eclipse.platform.swt] pack() or setVisible or how ?
|
- From: Torsten 'Ilja' Rathgen <vgap4@xxxxxx>
- Date: Sun, 12 Nov 2006 02:48:58 +0100
- Newsgroups: eclipse.platform.swt
- Organization: EclipseCorner
- User-agent: Thunderbird 1.5.0.8 (Windows/20061025)
Hello ng,
I have a problem with making a composite visible.
I have a Composite on right top corner of my shell, left and down a Sash
using FormLayout. Inside this Composite I have three Labels and one
Canvas on wich I draw an image.
Now my problem:
When I make the Composite and all inside first I see nothing. If I move
one of the Sashs the Composite gets drawn fine. But if I click inside
the Composite all vanishes again.
Well, if I use:
info.pack();
it gets drawn all the time but it shrinks the Composite very small (I
want to have the Composite the size that it has between the Sashs) and
my image is only shown half (it looks like pack() minimizes my image to
64x64 pixels, don't know why ?).
Using info.setVisible(true); doesn't work.
What am I missing? Thanks
regards
Ilja
code:
final Composite info= new Composite(shell, SWT.BORDER | SWT.V_SCROLL);
FormData infoData= new FormData();
infoData.left= new FormAttachment(sash_v);
infoData.right= new FormAttachment(100);
infoData.top= new FormAttachment(0);
infoData.bottom= new FormAttachment(sash_h);
info.setLayoutData(infoData);
FormLayout layout= new FormLayout();
layout.spacing= 5;
layout.marginHeight= layout.marginWidth= 10;
info.setLayout(layout);
Label t_name= new Label(c, SWT.LEFT);
FormData (...)
t_name.setText(obj.Name);
Label t_hull= new Label(c, SWT.LEFT);
FormData (...)
t_hull.setText(Integer.toString(obj.HullID));
Label t_player= new Label(c, SWT.LEFT);
FormData (...)
t_player.setText("Player # "+ obj.PlayerID);
final Canvas can= new Canvas(c, SWT.NONE);
img= new Image(can.getDisplay(), "C:\\AVC\\ship.jpg");
FormData (...)
can.addPaintListener(new PaintListener() {
public void paintControl(PaintEvent e) {
can.setSize(160, 120);
GC gc= new GC(can);
gc.drawImage(img, 0, 0);
}
});