Make a website open when a button is clicked.
i made a program that has a JMenuBar with some JMenuItems.
i want to make a website pop up when someone clicks a JMenuItem.
but i don't really know how, can you guys give me some help?
this is the code for my JMenuItems and JMenuBar.
JFrame frame = new JFrame("Calc");
JMenuBar bar = new JMenuBar();
JMenu about = new JMenu("About");
JMenu calcs = new JMenu("More calculators..");
JMenuItem me = new JMenuItem("me");
JMenuItem calcs2 = new JMenuItem("Skill calcs");
Re: Make a website open when a button is clicked.
first of all you need an action listener to the component you want and then implement the actionPerformed method. if you don't know how to do that check How to Write an Action Listener (The Java™ Tutorials > Creating a GUI With JFC/Swing > Writing Event Listeners)
inside you probably need something like this
java.awt.Desktop.getDesktop().browse(java.net.URI. create(the url you want as string);
I think this works