1
因此,基本上,即时通讯实现在视图中的接口,然后传递视图作为自定义事件的来源,在3“instanceof”调用之一它返回false。Java - instanceof返回false时,应该是true
查看:
public class NamedOffensiveStatsView extends BagVectorPanel implements INamedOffensiveStatsView {
Event.toString():
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(this.getSource().getClass() + ": ");
e.toString()打印:
class pl.drag0nius.diablo3.DPSCalc.NamedOffensiveStats.NamedOffensiveStatsView$2
的instanceof返回false:
@Override
public void eventFired(Event e) {
logger.debug("eventFired: " + e.toString());
if (e.getSource() instanceof INamedOffensiveStatsView) {
另外我不能从视图转换到它的界面。
回答:
在我朋友的帮助下,我们发现了这个问题。
(视野内的initComponents())的代码调用事件:
jComboBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (comboBoxReady) {
logger.debug("actionPerformed");
listener.eventFired(new Event(this, "selection", jComboBox.getSelectedIndex()));
}
}
});
它应该是什么:
jComboBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (comboBoxReady) {
logger.debug("actionPerformed");
listener.eventFired(new Event(NamedOffensiveStatsView.this, "selection", jComboBox.getSelectedIndex()));
}
}
});
“这个” 被引用嵌套类,而不是视图。
e.getSource()== null其中instanceof返回false? – Keppil
我认为你应该把你的编辑作为答案,并接受你自己的答案。 – nhahtdh
事情是我不能回答我自己的问题发布后的头10个小时或类似的东西。 – drag0nius