我有一個面板,其中包含一堆(多選)列表框,每個面板都有自己的面板,我需要弄清楚列表框中選定的值是什麼。通過API,我可以看到這樣做的唯一途徑去,是(僞):GWT:訪問面板內面板的列表框
for (Wigdet w : outerPanel)
Panel innerPanel = (Panel) w;
for (Widget s : innerPanel) // only has the ListBox in it
ListBox box = (ListBox) s;
// do stuff with the ListBox to populate the list of selected options
麻煩的是與鑄造 - Eclipse不抱怨,它編譯罰款,但運行時它會產生一個ClassCastException (在第一次演員 - 我認爲它也會在第二次有同樣的問題,但因爲我無法得到它,我不能肯定地說)
什麼是正確的方法來做到這一點?
w.getClass()在發生ClassCastException的地方返回什麼?我的意思是使用你的調試器停止在這一點,並把w.getClass()。getName()在監視列表中。 –
使用[UI活頁夾](http://code.google.com/webtoolkit/doc/latest/DevGuideUiBinder.html)查看聲明性佈局... ...要簡單得多。 – Jason482