[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.platform.swt] Border in form layout

Hello

I found a way to add a border around a text widget here: http://www.java-tips.org/other-api-tips/eclipse/how-to-add-colored-border-around-the-text-widgets.html

Now I need a that in a form layout. Does somebody know how to do that?

Thx
Arno

Code:
1. private void initialize() {
2. GridData g=new GridData();
3. g.grabExcessHorizontalSpace=true;
4. g.horizontalAlignment = org.eclipse.swt.layout.GridData.FILL;
5. Label label=new Label(this,SWT.NONE);
6. label.setText("Bordered Text");
7. text = new Text(this, SWT.NONE);
8. text.setBounds(new org.eclipse.swt.graphics.Rectangle(92,40,84,28));
9. text.setLayoutData(g);
10. addPaintListener(new PaintListener() {
11. public void paintControl(PaintEvent e) {
12. GC gc=e.gc;
13. Color red=new Color(null,255,0,0);
14. gc.setBackground(red);
15. Rectangle rect=text.getBounds();
16. Rectangle rect1 = new Rectangle(rText.x-1, rText.y-1, 17. rText.width+2, rText.height+2);
18.
19. gc.fillRectangle(rect1);
20. addControlListener(new ControlAdapter() {
21. public void controlResized(ControlEvent e) {
22. super.controlResized(e); 21. }
23. });
24. }
25 });
26.}