> Hi all,
> I'm trying to embed a a data plotting class in a simple SWT
> application, the calss is driven from JPanel. The code generates
> nothing btut an empty window, I tried the same thing with a simple
> JPanel holding a couple of controls and the result is always an empty
> window.
Can you usefully mix SWT and Swing? I thought this was not possible?
> here is the code of the secound attempt:
>
> public static void main(String[] args) {
> final Display display = new Display();
> final Shell shell = new Shell(display);
> shell.setText("Plot2d in SWT app");
> Composite compos = new Composite(shell, SWT.EMBEDDED);
I don't see why you use SWT above, why not use the Swing equivalents?
> java.awt.Frame frame = SWT_AWT.new_Frame(compos);
Aren't you now mixing in AWT? Why not use JFrame?
> javax.swing.JPanel panel = new javax.swing.JPanel( );
> javax.swing.JLabel label = new javax.swing.JLabel("hi");
[quoted text clipped - 3 lines]
> panel.add(label);
> panel.add(button);
> shell.open();
> while(!shell.isDisposed()) {
[quoted text clipped - 3 lines]
> }
> }
If it was a JFrame wouldn't you need to
frame.pack();
frame.setVisible(true);
instead of all this SWTish code.
Swing components normally need to be instatiated in the event
dispatching thread (e.g. using SwingUtilities.invokeLater()).
Is there some reason you don't write this as a Swing app if you want to
doodle on a JPanel?
Doubtless there is a SWT component that can be drawn on if you want a
SWT app - isn't there?
Maybe you are doing something clever, too clever for my level of knowledge?
qetoom@gmail.com - 31 Oct 2006 18:03 GMT
Here is how others have been doing it.
http://eclipsezone.com/eclipse/forums/t45697.html
http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.swt.snippets/src/org/eclips
e/swt/snippets/Snippet154.java?rev=HEAD&content-type=text/vnd.viewcvs-markup
I need to use a small number of data visualization calsses that are
written using swing in applications written in swt. Rewriting either is
not an option :).
> > Hi all,
> > I'm trying to embed a a data plotting class in a simple SWT
[quoted text clipped - 8 lines]
> >
>..........