【问题标题】:Displaying MalformedURLException in JTextArea在 JTextArea 中显示 MalformedURLException
【发布时间】:2013-03-04 16:07:15
【问题描述】:

我正在开发具有多个组件的 Java 程序。我想要实现的是,任何异常都显示在 JTextArea 中,而不是控制台中。下面的代码不起作用。我能做些什么?

catch ( MalformedURLException e) { textArea.append(e); }

谢谢

【问题讨论】:

  • 怎么不工作?而是做什么?你能发布更多代码吗?

标签: java jtextarea malformedurlexception


【解决方案1】:

JTextArea 不支持 append() 方法。 如果你只需要显示错误,你可以试试这个:

catch ( MalformedURLException e) { textArea.setText(e.toString()); }

如果你需要附加消息,你可以试试这个:

catch ( MalformedURLException e) { textArea.setText(textArea.getText()+e.toString()); }

【讨论】:

    猜你喜欢
    • 2011-03-17
    • 2013-05-22
    • 2015-07-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-11-26
    • 2017-09-03
    相关资源
    最近更新 更多