开发者

JDialogBox dont display content intermittently

Good evening stackoverflow. I have a problem involving JOptionPanes. Every so often they simply do not display the content that i give it. And here to illustrate my problem: This is what it should look like:

JDialogBox dont display content intermittently

and every so often, this is what it displays:

JDialogBox dont display content intermittently

heres the function call to build the thing. "panel" is just a simple JPanel with the widgets added.

int a = JOptionPane.showConfirmDialog(null,panel,"Please enter result details",JOptionPane.OK_CANCEL_OPTION,JOptionPane.QUESTION_MESS开发者_如何学GoAGE);

The thing with this that is driving me crazy is that it's intermittent so i have no idea what caused this. Any ideas?


You should ensure that you are calling your JOptionPane updating code on the Event Dispatching Thread. Swing components should be updated on the EDT to ensure they are repainted properly, most issues with incorrect updating are because it is not being called on the EDT.

If you are ever unsure about whether or not you are on the EDT, SwingUtilities.isEventDispatchThread() is a good debugging tool.

Edit: I missed that there was a comment that mentioned this, sorry.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜