In this tutorial, we are going to create a simple Swing JMenu.

Swing JMenu Example :
package com.swing.examples;
import javax.swing.*;
import java.awt.Container;
import java.awt.BorderLayout;

public class MenuDemo extends JFrame {
    JMenu normalMenu, radioMenu, checkMenu;
    JMenuItem new1, open;
    JRadioButtonMenuItem radio1, radio2;
    JCheckBoxMenuItem check1, check2;
    JMenuBar mainMenu;
    Container ContentPane;
    ButtonGroup group;

    MenuDemo() {
        super("JMenu Demo");
        normalMenu = new JMenu("Normal Menu");
        radioMenu = new JMenu("Radio Menu");
        checkMenu = new JMenu("Check Menu");

        new1 = new JMenuItem("New...", new ImageIcon(
        open = new JMenuItem("Open...", new ImageIcon(


        radio1 = new JRadioButtonMenuItem("First Radio Option");
        radio2 = new JRadioButtonMenuItem("Second Radio Option");

        group = new ButtonGroup();



        check1 = new JCheckBoxMenuItem("First Check Option");
        check2 = new JCheckBoxMenuItem("Second Check Option");


        mainMenu = new JMenuBar();


        ContentPane = getContentPane();
        ContentPane.add(mainMenu, BorderLayout.NORTH);
        setSize(400, 275);


    public static void main(String[] args) {
        new MenuDemo();


Output :

JMenu with Images :JMenu Example ImagesJMenu with Check Boxes:

JMenu Example Check

JMenu with Radio Buttons:

JMenu Example Radio

Happy Learning 🙂

About the Author:

Founder of Love Java, Python, Shell and opensource frameworks. Follow him on twitter and facebook for latest updates.

Leave A Comment