Icon alignment problem [message #122577] |
Tue, 16 March 2004 05:00  |
Eclipse User |
|
|
|
Hi group,
I'm having problems with icon alignment. I'm using the Logic example as
a base for my application. I've extended the NodeFigure class to produce
my own TextArea class having image in the label. Well, the problem is
that the icon image is aligned at the top-left corner. No matter what
alignment settings I made every time the icon image goes to the top left
position. I would like to have the icon image in the middle of the label.
I'm doing something totally wrong? Is there a better way (than icons) to
show images in my application? All comments are highly appreciated.
Code for my TextArea class is copy pasted here:
---- code clip ----
public class TextAreaFigure extends NodeFigure {
public static Color classColor = new Color(null, 255, 255, 206);
/**
* Constructor for GroundFigure.
*/
public TextAreaFigure() {
super();
Display d = Display.getDefault();
Image iconImage = new
Image(d,"C:/programmingtools/eclipse/images/middle_button.bmp ");
Label testLabel = new Label("editbox");
testLabel.setIcon(iconImage);
testLabel.setIconAlignment(PositionConstants.CENTER);
testLabel.setIconDimension(new Dimension(iconImage));
testLabel.setLabelAlignment(PositionConstants.TOP);
add(testLabel);
}
public Dimension getPreferredSize(int w, int h) {
Dimension prefSize = super.getPreferredSize(w, h);
Dimension defaultSize = new Dimension(100, 100);
prefSize.union(defaultSize);
return prefSize;
}
}
---code clip ends ----
|
|
|
Re: Icon alignment problem [message #122587 is a reply to message #122577] |
Tue, 16 March 2004 06:11  |
Eclipse User |
|
|
|
Originally posted by: brian.fernandes.codito.com
Hi Pekka,
When I needed to properly place and align text (and hence the icon) while
using a Label figure, I used the Label#setTextPlacement method. NodeFigure
should have a similar method - check it out.
All the best,
Brian.
"Pekka Laukkanen" <pekka.laukkanen@tietoenator.com> wrote in message
news:c36ivr$6lb$1@eclipse.org...
> Hi group,
>
> I'm having problems with icon alignment. I'm using the Logic example as
> a base for my application. I've extended the NodeFigure class to produce
> my own TextArea class having image in the label. Well, the problem is
> that the icon image is aligned at the top-left corner. No matter what
> alignment settings I made every time the icon image goes to the top left
> position. I would like to have the icon image in the middle of the label.
>
> I'm doing something totally wrong? Is there a better way (than icons) to
> show images in my application? All comments are highly appreciated.
>
> Code for my TextArea class is copy pasted here:
>
> ---- code clip ----
>
> public class TextAreaFigure extends NodeFigure {
>
> public static Color classColor = new Color(null, 255, 255, 206);
>
> /**
> * Constructor for GroundFigure.
> */
> public TextAreaFigure() {
> super();
> Display d = Display.getDefault();
> Image iconImage = new
> Image(d,"C:/programmingtools/eclipse/images/middle_button.bmp ");
>
> Label testLabel = new Label("editbox");
> testLabel.setIcon(iconImage);
> testLabel.setIconAlignment(PositionConstants.CENTER);
> testLabel.setIconDimension(new Dimension(iconImage));
> testLabel.setLabelAlignment(PositionConstants.TOP);
> add(testLabel);
> }
>
> public Dimension getPreferredSize(int w, int h) {
>
> Dimension prefSize = super.getPreferredSize(w, h);
> Dimension defaultSize = new Dimension(100, 100);
> prefSize.union(defaultSize);
> return prefSize;
> }
> }
>
> ---code clip ends ----
>
|
|
|
Powered by
FUDForum. Page generated in 0.30147 seconds