Java Swing JMenu Example

By | 2017-11-14T16:46:09+00:00 November 14th, 2017|java|0 Comments

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:

Hi Folks, you have reach this so far, that shows you like what you are learning. Then why don't you support us to improve for bettor tutorials by leaving your valuable comments and why not you keep in touch with us for latest updates on your favorite blog @ facebook , twitter , Or Google+ ,

Leave A Comment