JOptionPane和滚动功能 [英] JOptionPane and scroll function
本文介绍了JOptionPane和滚动功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在JOptionPane中列出很多结果,但是,如果结果太多,我不确定如何添加滚动函数。如何向JOptionPane添加滚动条?任何帮助都会很棒。
I want to JList a lot of results in a JOptionPane, however, I'm not sure how to add in a scroll function should there be too many results. How would I add a scroll bar to a JOptionPane? Any help would be great.
谢谢。
推荐答案
这是使用嵌入在 JScrollPane
中的 JTextArea
的示例:
Here is an example using a JTextArea
embedded in a JScrollPane
:
JTextArea textArea = new JTextArea("Insert your Text here");
JScrollPane scrollPane = new JScrollPane(textArea);
textArea.setLineWrap(true);
textArea.setWrapStyleWord(true);
scrollPane.setPreferredSize( new Dimension( 500, 500 ) );
JOptionPane.showMessageDialog(null, scrollPane, "dialog test with textarea",
JOptionPane.YES_NO_OPTION);
这篇关于JOptionPane和滚动功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文