JOptionPane和滚动功能

use*_*187 9 java swing jscrollpane jlist joptionpane

我想在JOptionPane中列出很多结果,但是,如果结果太多,我不知道如何添加滚动函数.如何向JOptionPane添加滚动条?任何帮助都会很棒.

谢谢.

GET*_*Tah 23

以下是使用JTextArea嵌入式的示例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);
Run Code Online (Sandbox Code Playgroud)