JOptionPane and scroll function

后端 未结 4 2312
一整个雨季
一整个雨季 2021-02-20 11:17

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 JOp

4条回答
  •  攒了一身酷
    2021-02-20 11:41

    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);
    

提交回复
热议问题