eclipse - WindowBuilder encountered unexpected internal error; Cannot cast? -
i'm trying run windowbuilder build swt apps. however, when click design tab, error:
the code i'm using produces above error basic default code when starting new project. same error occurs when try run actual swt project run when executed within java:
here's code:
package ch2; import org.eclipse.swt.*; public class helloswt { public static void main(string[] args) { // todo auto-generated method stub display display = new display(); shell shell = new shell(display); shell.settext("hello world"); shell.setbounds(100, 100, 200, 50); //layout rowlayout rowlay = new rowlayout(swt.horizontal); rowlay.justify = true; rowlay.margintop = 20; rowlay.marginbottom = 20; //form layout formdata formdata = new formdata(); formdata.right = new formattachment(100, -5); formdata.bottom = new formattachment(100, -5); //shell.setlayout(new filllayout(swt.vertical)); shell.setlayout(rowlay); final label label = new label(shell, swt.center); label.settext("hello inside world"); org.eclipse.swt.graphics.color red = new org.eclipse.swt.graphics.color(display, 255, 0, 0); label.setforeground(red); //button final button button = new button(shell, 0); button.settext("a button"); image img = new image(display, "c:\\users\\ra_stein\\pictures\\koala.png"); button.setimage(img); button.setforeground(red); button.pack(); button.addselectionlistener(new selectionadapter(){ public void widgetselected(selectionevent event){ button.settext("a clicked button"); label.settext("hello yourself"); } }); text txt = new text(shell, swt.single); txt.settext("text object"); txt.addverifylistener(new verifylistener(){ public void verifytext(verifyevent event){ event.doit = event.text.length() == 1 || character.isdigit(event.text.charat(0)); //set doit true if length of event.text (the text want put in) 1 or the first character digit. } } ); //table final table table = new table(shell, swt.single | swt.border | swt.full_selection); table.setheadervisible(true); table.setlinesvisible(true); tablecolumn column1 = new tablecolumn(table, swt.null); column1.settext("name"); column1.pack(); tablecolumn column2 = new tablecolumn(table, swt.null); column2.settext("age"); column2.pack(); tableitem item1 = new tableitem(table, swt.null); item1.settext(new string[] {"dan", "43"}); tableitem item2 = new tableitem(table, swt.null); item2.settext(new string[] {"john", "23"}); table.addselectionlistener(new selectionadapter() { public void widgetselected(selectionevent event){ tableitem[] selected = table.getselection(); if (selected.length > 0){ system.out.println("name: " + selected[0].gettext(0)); system.out.println("age: " + selected[0].gettext(1)); } } }); //tab folder final tabfolder tabfolder = new tabfolder(shell, swt.border); tabitem tabitem1 = new tabitem(tabfolder, swt.null); tabitem1.settext("tab 1"); tabitem tabitem2 = new tabitem(tabfolder, swt.null); tabitem2.settext("tab 2"); composite compo = new composite(tabfolder, swt.null); tabitem2.setcontrol(compo); //text hellotext = new text(shell, swt.center); //hellotext.settext("hello swt"); //hellotext.pack(); shell.pack(); shell.open(); while(!shell.isdisposed()){ if (!display.readanddispatch()) display.sleep(); } display.dispose(); } }
and here's error:
Comments
Post a Comment