gpt4 book ai didi

java.awt.HeadlessException

转载 作者:行者123 更新时间:2023-12-02 09:25:41 26 4
gpt4 key购买 nike

JFileChooser chooser = new JFileChooser();
JDialog dialog=new JDialog();
dialog.setAlwaysOnTop(true);
/*System.out.println("is always on top?"+dialog.isAlwaysOnTop());*/
chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
int returnVal = chooser.showOpenDialog(dialog);

String path = null;

if(returnVal == JFileChooser.APPROVE_OPTION) {

path=chooser.getSelectedFile().getAbsolutePath();

}

我在 Servlet 的 doGet 方法中编写了这段代码。当我部署在 Linux 服务器中时,出现以下异常:

java.awt.HeadlessException
at java.awt.GraphicsEnvironment.checkHeadless(GraphicsEnvironment.java:159)

有人知道如何克服这个问题吗?

最佳答案

HeadlessException

Thrown when code that is dependent on a keyboard, display, or mouse is called in an environment that does not support a keyboard, display, or mouse.

关于java.awt.HeadlessException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15658493/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com