Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [platform-swt-dev] Creating a form in SWT


See http://www.eclipse.org/swt/ for links to tutorials and various other resources.  Once you get going, the snippets are worth twice their weight in documentation.



stephan langhammer <langhammerstephan@xxxxxx>
Sent by: platform-swt-dev-bounces@xxxxxxxxxxx

07/13/2007 08:49 PM

Please respond to
"Eclipse Platform SWT component developers list."        <platform-swt-dev@xxxxxxxxxxx>

To
anthony.aziz@xxxxxxxxx, "Eclipse Platform SWT component developers list." <platform-swt-dev@xxxxxxxxxxx>
cc
Subject
Re: [platform-swt-dev] Creating a form in SWT






Am 13.07.2007 um 20:26 schrieb anthonya@xxxxxxxxxxxxxxx:

It seems there is a lack of tutorials for SWT out there, at least
significantly less than the amazing Swing Tutorial. Anyways . . . I
was thinking of converting my partially developed app from Swing to
SWT. I'm currently spending my free time testing out SWT, however a
have an issue.


I currently have a class, lets say, "AppFrame"


which is something like:


public class AppFrame extends JFrame
{         public AppFrame(String title)         {
super(title);


                // set-up components, etc etc         }


        // methods, etc etc


}

Now, this class is called from a main class, or perhaps other classes,
or perhaps another project. I know you can't subclass Shell in SWT.
What is the equivalent way to go about this in SWT.


I'm also on the fence about this approach versus creating an instance
of JFrame/Shell and doing whatnot that way . . . but my current
argument is that the Form's behaviour and set-up should be
encapsulated into itself.

_______________________________________________
platform-swt-dev mailing list
platform-swt-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/platform-swt-dev

1. There aren't some good tutorial, but some swt examples and snippets  form the CVS in Eclipse. Just have a look.

- Swich to the CVS Perspective in Eclipse and add a new Repository Location :
Host: dev.eclipse.org
Repository Path: /cvsroot/eclipse
user: anonymous
password:
in the Head you could find a lot a stuff around swt, just have a look at the projects starting with org.eclipse.swt.examples or org.eclipse.swt.snippet


2:Now, you could subclass a Shell and all class inherited from Widget  in SWT but you have to override the Methode "checkSubclass" :

Here is a useful link :http://www.eclipse.org/swt/faq.php#subclassing

Just have a look at the question : Why can't I subclass SWT widgets like Button and Table?


And here is a small example:

import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

public class JFrame extends Shell {
public JFrame() {
// set-up components, etc etc   
}

@Override
protected void checkSubclass() {
// Disable the check that prevents subclassing of SWT components
// super.checkSubclass();
}

public static void main(String[] args) {
final Display display = new Display();
final JFrame shell = new JFrame();
final GridLayout gridLayout = new GridLayout();
shell.setLayout(gridLayout);
shell.open();

shell.layout();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
}

}






_______________________________________________
platform-swt-dev mailing list
platform-swt-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/platform-swt-dev


Back to the top