我正在尝试使用 void print() 函数在可滚动对话框中进行打印,但我似乎无法弄清楚这一点。是否可以按原样使用该功能?
rslt = JOptionPane.showConfirmDialog(this,
tempPanel,
univ.printList,
JOptionPane.OK_CANCEL_OPTION,
JOptionPane.PLAIN_MESSAGE);
最佳答案
可能有几十种方法可以做到这样的事情......
首先查看 How to Make Dialogs了解更多详情
以下内容只是创建一个基于 html
的项目列表...
public void showProfessorList(){
StringBuilder sb = new StringBuilder(25);
sb.append("<html>");
for (int i=0; i < professorList.size(); i++){
sb.append(professorList.get(i).getName())).append("<br>");
}
JOptionPane.showConfirmDialog(this,
new JScrollPane(new JLabel(sb.toString),
"Behold",
JOptionPane.OK_CANCEL_OPTION,
JOptionPane.PLAIN_MESSAGE);
}
您可以使用 JList
来代替,但这取决于您的需求......
关于Java:如何使用 void Print() 函数打印到可滚动对话框?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27096050/