add a listener for it
|
How do I create a link button in a Java GUI?
At the moment I have this code for the button I want to link:
Please help if you can, I will rep+Code:private JButton websitebutton; public StartupGUI() { websitebutton = new JButton("Visit our website"); add (websitebutton); }
Thanks
add a listener for it
would be something like this:
static class Action implements ActionListener {
public void actionPerformed(ActionEvent event){
Object site = event.getSource();
if(site == button) {
try {
Desktop d = Desktop.getDesktop();
d.browse(new URI("www.google.com"));
} catch (Exception e) {
}
}
}
« Previous Thread | Next Thread » |
Thread Information |
Users Browsing this ThreadThere are currently 1 users browsing this thread. (0 members and 1 guests) |