Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Standard Widget Toolkit
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== Extensibility and comparison to other Java code === Due to the use of native code, SWT classes do not allow for easy inheritance for all widget classes, which some users consider can hurt extensibility.<ref name= "taleof2guis" /> This can make customizing existing widgets more difficult to achieve with SWT than if one were using Swing.<ref name="creatingSWTWidgets" >{{cite web |url= http://www.eclipse.org/articles/Article-Writing%20Your%20Own%20Widget/Writing%20Your%20Own%20Widget.htm |title= Creating Your Own Widgets using SWT |publisher=eclipse.org |date= 2007-03-22 |quote=''Subclassing may cause bad system-level bugs, and runs the risk of leaking resources(...)Subclassing Canvas or Composite is the best way to ensure that your widget works on all SWT platforms(...)When subclassing anything other than Composite or Canvas you must override the method protected void checkSubclass() to do nothing'' |access-date= 2008-12-13}}</ref> Both toolkits support writing new widgets using only Java code, however in SWT extra work is needed to make the new widget work on every platform.<ref name="creatingSWTWidgets" /> SWT widgets, unlike almost any other Java toolkit, requires manual object deallocation, in contrast to the standard Java practice of [[Garbage collection (computer science)|automatic garbage collection]]. SWT objects must be explicitly deallocated using the <code>dispose</code> method, which is analogous to the [[C (programming language)|C language]]'s <code>free</code>.<ref>The Java developers guide to Eclipse, 2nd ed., p359</ref> If this is not done, [[memory leak]]s or other unintended behavior may result. On this matter, some have commented that "explicitly de-allocating the resources could be a step back in development time (and costs) at least for the average Java developer" and that "this is a mixed blessing. It means more control (and more complexity) for the SWT developer instead of more automation (and slowness) when using Swing."<ref name="taleof2guis" /> The need for manual object deallocation when using SWT is largely due to SWT's use of native objects. These objects are not tracked by the Java JVM, so it cannot track whether or not such objects are in use, and thus cannot garbage collect them at a suitable time.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)