S
Spider
Gast
Hallo weis jemand ob es möglich ist einen JButton als Hyperlink für eine Website zu benutzen?
VL. hat da jemand schon Erfahrungen gesammelt?
VL. hat da jemand schon Erfahrungen gesammelt?
Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + url);
Desktop d = Desktop.getDesktop();
try {
d.browse(new URI("www.wikipedia.de"));
} catch (IOException e) {
e.printStackTrace();
} catch (URISyntaxException e) {
e.printStackTrace();
}
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Desktop d = Desktop.getDesktop();
try {
d.browse(new URI("www.wikipedia.de"));
} catch (IOException e) {
e.printStackTrace();
} catch (URISyntaxException e) {
e.printStackTrace();
}
}
});
import java.awt.*;
import java.awt.event.*;
import java.io.IOException;
import java.net.*;
import javax.swing.*;
package de.jpki.test.java6;
public class DesktopTest extends JFrame {
public static void main(String args[]) {
new DesktopTest();
}
public DesktopTest() {
super("de.jpki.test.java6.DesktopTest");
setSize(300,300);
setDefaultCloseOperation(EXIT_ON_CLOSE);
JButton button = new JButton("Hier klicken");
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Desktop d = Desktop.getDesktop();
try {
d.browse(new URI("www.wikipedia.de"));
} catch (IOException ex) {
ex.printStackTrace();
} catch (URISyntaxException ex) {
ex.printStackTrace();
}
}});
getContentPane().add(button);
setVisible(true);
}
}