Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » customizing swt widget
customizing swt widget [message #465954] Mon, 26 December 2005 06:50 Go to next message
andy is currently offline andyFriend
Messages: 10
Registered: July 2009
Junior Member
hi,
i wanna develop my swt widget. (e.g. MyButton)
MyButton support some properties (e.g. setRolloverIcon,
setPressedIcon,setDisabledIcon and something like SWING JButton's
properties)

so, I try to make MyButton extending Button.
but it's restricted to be subclssing

alternatives are extending composite or extending canvas.
but both are not easy to expose basic Button properties to user.

what is better idea?
Re: customizing swt widget [message #465972 is a reply to message #465954] Tue, 27 December 2005 16:42 Go to previous message
Daniel Spiewak is currently offline Daniel SpiewakFriend
Messages: 263
Registered: July 2009
Senior Member
You can subclass Button as long as you're extremely careful to only use/override the public API and not the internal methods (even the public ones) which aren't declared as platform agnostic. Otherwise you'd have to create a new subclass for each platform and would have to change it practically with every milestone. To extend Button (or any SWT widget) use the following:

protected void checkSubclass() {
    if (!getClass().getName().equals("com.custom.MyButton"))
        SWT.error(SWT.ERROR_INVALID_SUBCLASS);
}
Previous Topic:control widget on main form from composite?
Next Topic:Standard SWT Menu Icons
Goto Forum:
  


Current Time: Fri Dec 06 04:55:47 GMT 2024

Powered by FUDForum. Page generated in 0.03227 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top