Adding SWT Canvas to JPanel -
i'm trying add nattable (which extends org.eclipse.swt.widgets.canvas) jpanel (the majority of program's graphics in swing, , i'm rather unfamiliar swt). attempted use code below test swt_awt class, got error:
org.eclipse.swt.widgets.canvas canvas = new org.eclipse.swt.widgets.canvas( new org.eclipse.swt.widgets.shell( display.getdefault(), 1264), swt.none); java.awt.frame frame = swt_awt.new_frame(canvas); //error here jpanel returnme = new jpanel(); returnme.add(frame); return returnme;
exception in thread "awt-eventqueue-0" java.lang.illegalargumentexception: argument not valid
i not understand why have error passed swt composite. can explain did wrong , how fix it?
in order embedding succeed, composite must have been created
swt.embedded
style.
also, going other way: embedding swing component in swt. instead need
java.awt.canvas canvas = ... // assumes code running in swt thread shell shell = swt_awt.new_shell(display.getcurrent(), canvas); nattable table = new nattable(shell, swt.none); // etc.
note need arrange run swt code in swt dispatch thread , swing code in awt dispatch thread.
Comments
Post a Comment