use of javax.swing.event.HyperlinkListener in project GenericKnimeNodes by genericworkflownodes.
the class ParameterDialog method createHeader.
private void createHeader() {
// use JPanel to be able to create a border
headerpanel = new JPanel();
headerpanel.setLayout(new BorderLayout());
TitledBorder b = new TitledBorder(new EtchedBorder(), "Please cite:");
b.setTitleFont(MAND_FONT);
headerpanel.setBorder(b);
headerpanel.setPreferredSize(new Dimension(table.getWidth(), 50));
// fill the Panel with a non-editable HTML TextPane
header = new JTextPane();
header.setContentType("text/html");
header.setEditable(false);
header.addHyperlinkListener(new HyperlinkListener() {
// Open Desktop browser when clicking links (e.g. dois)
public void hyperlinkUpdate(HyperlinkEvent e) {
if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
if (Desktop.isDesktopSupported()) {
try {
Desktop.getDesktop().browse(e.getURL().toURI());
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (URISyntaxException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
}
}
});
headerpanel.add(new JScrollPane(header));
}
use of javax.swing.event.HyperlinkListener in project org.alloytools.alloy by AlloyTools.
the class SimpleGUI method doHelp.
/**
* This method displays the help html.
*/
private Runner doHelp() {
if (wrap)
return wrapMe();
try {
int w = OurUtil.getScreenWidth(), h = OurUtil.getScreenHeight();
final JFrame frame = new JFrame();
final JEditorPane html1 = new JEditorPane("text/html", "");
final JEditorPane html2 = new JEditorPane("text/html", "");
final HTMLDocument doc1 = (HTMLDocument) (html1.getDocument());
doc1.setAsynchronousLoadPriority(-1);
final HTMLDocument doc2 = (HTMLDocument) (html2.getDocument());
doc2.setAsynchronousLoadPriority(-1);
html1.setPage(this.getClass().getResource("/help/Nav.html"));
html2.setPage(this.getClass().getResource("/help/index.html"));
HyperlinkListener hl = new HyperlinkListener() {
@Override
public final void hyperlinkUpdate(HyperlinkEvent e) {
try {
if (e.getEventType() != HyperlinkEvent.EventType.ACTIVATED)
return;
if (e.getURL().getPath().endsWith("quit.htm")) {
frame.dispose();
return;
}
HTMLDocument doc = (HTMLDocument) (html2.getDocument());
// So that we can
doc.setAsynchronousLoadPriority(-1);
// catch any
// exception
// that may
// occur
html2.setPage(e.getURL());
html2.requestFocusInWindow();
} catch (Throwable ex) {
}
}
};
html1.setEditable(false);
html1.setBorder(new EmptyBorder(3, 3, 3, 3));
html1.addHyperlinkListener(hl);
html2.setEditable(false);
html2.setBorder(new EmptyBorder(3, 3, 3, 3));
html2.addHyperlinkListener(hl);
JScrollPane scroll1 = OurUtil.scrollpane(html1);
JScrollPane scroll2 = OurUtil.scrollpane(html2);
JSplitPane split = OurUtil.splitpane(JSplitPane.HORIZONTAL_SPLIT, scroll1, scroll2, 150);
split.setResizeWeight(0d);
frame.setTitle("Alloy Analyzer Online Guide");
frame.getContentPane().setLayout(new BorderLayout());
frame.getContentPane().add(split, BorderLayout.CENTER);
frame.pack();
frame.setSize(w - w / 10, h - h / 10);
frame.setLocation(w / 20, h / 20);
frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
frame.setVisible(true);
html2.requestFocusInWindow();
} catch (Throwable ex) {
return null;
}
return null;
}
use of javax.swing.event.HyperlinkListener in project vcell by virtualcell.
the class LoginPanel method getDtrpnUseThisLink.
private JEditorPane getDtrpnUseThisLink() {
if (dtrpnUseThisLink == null) {
dtrpnUseThisLink = new JEditorPane();
dtrpnUseThisLink.setBorder(null);
dtrpnUseThisLink.setBackground(getBackground());
dtrpnUseThisLink.setFont(new Font("Arial", Font.BOLD, 14));
dtrpnUseThisLink.setContentType("text/html");
String s = "<html><body bgcolor=\"#" + Hex.toString(new byte[] { (byte) (getBackground().getRed() & 0xFF), (byte) (getBackground().getGreen() & 0xFF), (byte) (getBackground().getBlue() & 0xFF) }) + "\"><center><font size=5 face=Arial>Use <a href=\"" + BeanUtils.getDynamicClientProperties().getProperty(PropertyLoader.ACKNOWLEGE_PUB__WEB_URL) + "\">this link</a> for details on how to<br>acknowledge Virtual Cell in your<br>publication and how to share your<br>published research through<br>the VCell database.</font></center></body></html>";
// System.out.println(s);
dtrpnUseThisLink.setText(s);
dtrpnUseThisLink.setEditable(false);
dtrpnUseThisLink.addHyperlinkListener(new HyperlinkListener() {
@Override
public void hyperlinkUpdate(HyperlinkEvent e) {
if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
DialogUtils.browserLauncher(LoginPanel.this, e.getURL().toString(), "Please visit " + BeanUtils.getDynamicClientProperties().getProperty(PropertyLoader.VCELL_URL) + " for Online Help");
}
}
});
}
return dtrpnUseThisLink;
}
use of javax.swing.event.HyperlinkListener in project SKMCLauncher by SKCraft.
the class WebpagePanel method setDocument.
private void setDocument() {
activated = true;
JLayeredPane panel = new JLayeredPane();
panel.setLayout(new WebpageLayoutManager());
documentView = new JEditorPane();
documentView.setEditable(false);
documentView.addHyperlinkListener(new HyperlinkListener() {
@Override
public void hyperlinkUpdate(HyperlinkEvent e) {
if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
if (e.getURL() != null) {
SwingHelper.openURL(e.getURL(), self);
}
}
}
});
JScrollPane scrollPane = new JScrollPane(documentView);
panel.add(scrollPane, new Integer(1));
progressBar = new JProgressBar();
progressBar.setIndeterminate(true);
panel.add(progressBar, new Integer(2));
add(panel, BorderLayout.CENTER);
}
use of javax.swing.event.HyperlinkListener in project triplea by triplea-game.
the class EngineVersionProperties method getOutOfDateComponent.
Component getOutOfDateComponent() {
final JPanel panel = new JPanel(new BorderLayout());
final JEditorPane intro = new JEditorPane("text/html", getOutOfDateMessage());
intro.setEditable(false);
intro.setOpaque(false);
intro.setBorder(BorderFactory.createEmptyBorder());
final HyperlinkListener hyperlinkListener = e -> {
if (HyperlinkEvent.EventType.ACTIVATED.equals(e.getEventType())) {
OpenFileUtility.openUrl(e.getDescription());
}
};
intro.addHyperlinkListener(hyperlinkListener);
panel.add(intro, BorderLayout.NORTH);
final JEditorPane updates = new JEditorPane("text/html", getOutOfDateReleaseUpdates());
updates.setEditable(false);
updates.setOpaque(false);
updates.setBorder(BorderFactory.createEmptyBorder());
updates.addHyperlinkListener(hyperlinkListener);
updates.setCaretPosition(0);
final JScrollPane scroll = new JScrollPane(updates);
// scroll.setBorder(BorderFactory.createEmptyBorder());
panel.add(scroll, BorderLayout.CENTER);
final Dimension maxDimension = panel.getPreferredSize();
maxDimension.width = Math.min(maxDimension.width, 700);
maxDimension.height = Math.min(maxDimension.height, 480);
panel.setMaximumSize(maxDimension);
panel.setPreferredSize(maxDimension);
return panel;
}
Aggregations