Please help..
I need to have a Menu Applet using Java codes..
Still a beginner and as to now I can't get a better result
using tutorials on such sites..
Thanks a lot to those who'll help.. ^^
[sp
Please help..
I need to have a Menu Applet using Java codes..
Still a beginner and as to now I can't get a better result
using tutorials on such sites..
Thanks a lot to those who'll help.. ^^
[spoiler]import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.ButtonGroup;
import javax.swing.JMenuItem;
public class MenuExp extends JFrame {
public MenuExp() {
setTitle("Menu Example");
setSize(150, 150);
// Define and add two drop down menu to the menubar
JMenu fileMenu = new JMenu("File");
// Create and add simple menu item to one of the drop down menu
JMenuItem newAction = new JMenuItem("New");
JMenuItem openAction = new JMenuItem("Open");
JMenuItem exitAction = new JMenuItem("Exit");
// Create a ButtonGroup and add both radio Button to it. Only one radio
// button in a ButtonGroup can be selected at a time.
ButtonGroup bg = new ButtonGroup();
fileMenu.add(newAction);
fileMenu.add(openAction);
fileMenu.add(exitAction);
// Add a listener to the New menu item. actionPerformed() method will
// invoked, if user triggred this menu item
newAction.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
System.out.println("You have clicked on the new action");
}
});
}
public static void main(String[] args) {
MenuExp me = new MenuExp();
me.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
me.setVisible(true);
}
}[/spoiler]