Hi,
I am trying to draw a shape (RectangleSprite) and add a text inside it (TextSprite). I don't know this is the right way.. so, please help me out. I am new to GXT. The size of the rectangle should be just little bigger than the text inside. How do I do it? Sample code here ->
Is this the correct way?? or is there any other "better" way of drawing a shape and adding a text inside? Please let me know.
I am trying to draw a shape (RectangleSprite) and add a text inside it (TextSprite). I don't know this is the right way.. so, please help me out. I am new to GXT. The size of the rectangle should be just little bigger than the text inside. How do I do it? Sample code here ->
Code:
DrawComponent component = new DrawComponent();
TextSprite text = new TextSprite();
text.setText("Hello, World!");
text.setX(130);
text.setY(80);
text.setFont("Helvetica");
text.setFontSize(18);
text.setFill(RGB.BLACK);
component.addSprite(text);
RectangleSprite rect = new RectangleSprite();
rect.setX(125);
rect.setY(75);
rect.setWidth(200); //How do I change this dynalically depending on the text length above?
rect.setHeight(50); //How do I change this dynalically depending on the text max height above?
rect.setFill(new Color("#555555"));
rect.setFillOpacity(0.4);
rect.setComponent(component);
component.addSprite(rect);
Is this the correct way?? or is there any other "better" way of drawing a shape and adding a text inside? Please let me know.
Aucun commentaire:
Enregistrer un commentaire