У меня есть JEditorPane, показывающая на JOptionPane, с URL-адресом, который я хочу открыть перед закрытием моего приложения. Он отлично работает в Windows и Linux, но он не работает на Mac.Гиперссылка в JEditorPane не открывается на MAC
Вот код:
//LINK
String link = "http://www.google.com/";
String link_name = "Google";
//Editor_Pane
JEditorPane editor_pane = new JEditorPane();
editor_pane.setEditorKit(JEditorPane.createEditorKitForContentType("text/html"));
editor_pane.setText(/*some text*/ + "<a href=\"" + link + "\">" + link_name + "</a>");
editor_pane.setEditable(false);
//ADD A LISTENER
editor_pane.addHyperlinkListener(new HyperlinkListener(){
public void hyperlinkUpdate(HyperlinkEvent e){
if(e.getEventType() == (HyperlinkEvent.EventType.ACTIVATED)){
//OPEN THE LINK
try{ Desktop.getDesktop().browse(e.getURL().toURI());
}catch (IOException | URISyntaxException e1) {e1.printStackTrace();}
//EXIT
System.exit(0);
}
}
});
//SHOW THE PANE
JOptionPane.showOptionDialog(null, editor_pane, "text", JOptionPane.DEFAULT_OPTION,
JOptionPane.PLAIN_MESSAGE, null, new Object[] {}, null);
Ссылка кажется интерактивной, но ничего не происходит, когда я нажимаю, даже если я пытаюсь удалить метод Desktop.browse
и пусть только метод exit
.
Что я делаю неправильно? Благодаря !
Для лучшей помощи раньше, оставить [MCVE] или [Короткий, самодостаточный Правильный пример] (http://www.sscce.org/). –