Problem with custom controls

SWT Designer allows you to create the views, editors, perspectives, pref pages, composites, etc. that comprise Eclipse SWT & RCP applications and plug-ins.

Moderators: Konstantin.Scheglov, gnebling, Alexander.Mitin, jwren, Eric Clayberg

Problem with custom controls

Postby Pawel Banaszkiewicz » Thu Nov 10, 2005 1:36 am

Hello

I've made a simple control (code below):

Code: Select all
package test.application;

import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Text;

public class AText extends Text {

  private String a;
   
  public String getA() {
    return a;
  }

  public void setA(String a) {
    this.a = a;
  }

  public AText(Composite arg0, int arg1) {
    super(arg0, arg1);
  }
}

and when I try to put it on the application form in designer, I can't see it. Here is a source for test application:

Code: Select all
package test.application;

import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import test.application.AText;

public class TestApplication {

  private static AText text_1;

  public static void main(String[] args) {
    final Display display = Display.getDefault();
    final Shell shell = new Shell();
    shell.setSize(500, 375);
    shell.setText("SWT Application");
    shell.open();
    {
      text_1 = new AText(shell, SWT.BORDER);
      text_1.setBounds(85, 155, 120, 30);
    }
    shell.layout();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch())
      display.sleep();
    }
  }
}

Eclipse:
Version: 3.1.1
Build id: M20050929-0840

Designer:
ver 4.2.0 (trial... maybe here is a problem)

J2SE 5.0

Regards
PawelB
Pawel Banaszkiewicz
 
Posts: 1
Joined: Thu Nov 10, 2005 1:20 am
Location: Poland

Re: Problem with custom controls

Postby Eric Clayberg » Thu Nov 10, 2005 5:32 am

The problem is with your AText class. It needs the following method in order to be instantiated (SWT rules; not ours)...

Code: Select all
    protected void checkSubclass() {
    }
Eric Clayberg
Software Engineering Manager
Google
http://code.google.com/webtoolkit/download.html

Author: "Eclipse Plug-ins"
http://www.qualityeclipse.com
Eric Clayberg
Moderator
 
Posts: 4503
Joined: Tue Sep 30, 2003 6:39 am
Location: Boston, MA USA


Return to SWT Designer

Who is online

Users browsing this forum: No registered users and 1 guest