troubleshooting Question

How can I make a window popup here with swing?

Avatar of Computer Guy
Computer Guy asked on
6 Comments1 Solution214 ViewsLast Modified:

I am trying to make an app similar to the attached, where I have a menu bar.

When I click on an item in the menu bar, in this case Add Client,  how can I make the add client window will appear with the contents of that window? Can someone please just list list a little example?


import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;

public class MenuExp extends JFrame {
    public MenuExp() {
        setTitle("Menu Example");
        setSize(1024, 768);
        // Creates a menubar for a JFrame
        JMenuBar menuBar = new JMenuBar();
        // Add the menubar to the frame
        // Define and add two drop down menu to the menubar
        JMenu fileMenu = new JMenu("File");
       // JMenu editMenu = new JMenu("Edit");
        // Create and add simple menu item to one of the drop down menu
        JMenuItem addClientAction = new JMenuItem("Add Client");
        JMenuItem editClientAction = new JMenuItem("Edit Client");
        JMenuItem exitAction = new JMenuItem("Exit");

        // Add a listener to the New menu item. actionPerformed() method will
        // invoked, if user triggred this menu item
        addClientAction.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent arg0) {
                System.out.println("You have clicked on the add new client");
    public static void main(String[] args) {
        MenuExp me = new MenuExp();

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 6 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros