Page 1 of 1

Implementing Menus using the Swing Toolkit Rate Topic: ***** 3 Votes

#1 v0rtex  Icon User is offline

  • Caffeine: db "Never Enough!"
  • member icon

Reputation: 223
  • View blog
  • Posts: 773
  • Joined: 02-June 10

Posted 01 May 2011 - 04:51 AM

*
POPULAR

Implementing Menus using the Swing Toolkit:

(note: I expect you to have a basic working knowledge of the Swing toolkit, there are "read on" articles after the tutorial for those that are new to Swing, you should cope fine either way.)
A menu is one of the most important (if not the most important) aspect of any application that features a GUI (Graphics User Interface http://en.wikipedia....user_interface)
A menu in simple terms is a visual element whereby the most commonly used and generally most needed commands for the applications are grouped. There are various ways that a menu can be implemented in Java however in this tutorial we are going to learn one of the most common methods to implement a menu in any application designed with the Swing Toolkit.
Now onto setting up a menu in a JFrame:
import javax.swing.*;
public class MainFrame extends JFrame{
    MainFrame() {
        //------Setup of simple menu
        JMenuBar menuBar = new JMenuBar(); //set up of JMenuBar, this is the final element that the menu itself will be displayed in, similiar to a container.
        ImageIcon exitIcon = new ImageIcon ("close.gif"); //stores our Image for the exit command of the menu.
        JMenu menu = new JMenu("Menu"); //sets up the JMenu
        menu.setMnemonic(KeyEvent.VK_M); /*allows our menu to be accessed when we click ALT + M, you can do this for 
        individual menu items aswell. */                    
        JMenuItem exitItem = new JMenuItem ("Exit Program", exitIcon);//create our first command (menu item)
        menu.add(exitItem); //add the command (menu item) to our menu
        menuBar.add(menu); //add the JMenu to the JMenuBar
        
        setJMenuBar(menuBar); //set the default JMenuBar of the Swing application
        //------Setup of JFrame
        setSize(350,175); //set the size of the application (350 pixels width, 175 pixels high)
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //set what occurs when the "X" button at the top right of the application is clicked        
        setTitle("Menu in Java"); //set the title of our Swing application
        setVisible(true); //set the graphical elements of our Swing application to visible, so they can be seen.
    }
    public static void main(String[] args) {
      new MainFrame(); 
    }
}


Now, what you should see when you run this program is:

Posted Image

However try and click on your menu item...
Nothing happens, don't worry you haven't done anything wrong :)

We have to get our menu item to receive input:
There are several ways to receive input from the computer all thanks to the java.awt.event package. In this tutorial we will receive input via the mouse or keyboard to our menu items using an ActionListener interface. This is quite a simple task and is done via the following:

  • We set up a Listener for our menu item, in this case we do so using an ActionListener interface
  • We then add what would occur should a user event occur on our exit menu item.
  • That's it, now if the exitItem is clicked via a button or mouse, our functionality coded above will occur!


The process of doing the above is rather simplistic, here is the code:
   exitItem.addActionListener(new ActionListener() { //adds an ActionListener interface for our exitItem
            public void actionPerformed(ActionEvent e) {
                   System.exit(0); //exit our application should the user click our menu item called exit
            }
        });


That was simple enough, there are many more things that we can do with menus in java such as the following:
Setting up a submenu:

A submenu is a menu to which is nested within another menu. Each menu that is created can have a submenu, a submenu is generally used to group similiar commands together. In the next example, we will group commands that will show a label together. See the code below:
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
public class MainFrame extends JFrame{
    JLabel menuLabel = new JLabel ("This is my Menu!");
    MainFrame() {
        //------Setup of simple menu
        JMenuBar menuBar = new JMenuBar(); //set up of JMenuBar, this is the final element that the menu itself will be displayed in, similiar to a container.
        ImageIcon exitIcon = new ImageIcon ("close.gif"); //stores our Image for the exit command of the menu.
        ImageIcon hideIcon = new ImageIcon ("hide.gif");
        ImageIcon showIcon = new ImageIcon ("show.gif");
        JMenu menu = new JMenu("Menu"); //sets up the JMenu
        JMenu exitMenu = new JMenu("Label"); //creation of our submenu
        menu.setMnemonic(KeyEvent.VK_M); //allows our menu to be accessed when we click ALT + M, you can do this for individual menu items aswell.
        JMenuItem exitItem = new JMenuItem ("Exit Program", exitIcon);//create our first command (menu item)
        JMenuItem hidelblItem = new JMenuItem ("Hide Label", hideIcon);
        JMenuItem showlblItem = new JMenuItem("Show Label", showIcon);
        menu.add(exitItem); //add the command (menu item) to our menu
        exitMenu.add(hidelblItem); //add our JMenuItem's to our submenu --
        exitMenu.add(showlblItem); //--
        menu.addSeparator(); //visual element that seemingly splits our two menu's, you can comment this out, it just makes the program look nicer :)/>
        menu.add(exitMenu); //Add our submenu to our original menu.
        menuBar.add(menu); //add the JMenu to the JMenuBar
        setJMenuBar(menuBar); //set the default JMenuBar of the Swing application
        //------Setup of JFrame
       // FlowLayout layout = new FlowLayout();
        setSize(650,450); //set the size of the application (350 pixels width, 175 pixels high)
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //set what occurs when the "X" button at the top right of the application is clicked
        setTitle("Menu in Java"); //set the title of our Swing application
        menuLabel.setText("This is my Menu Comment!");
      //  setLayout(layout);
        add(menuLabel); //adds the label to our form using the defaul FlowLayout.
        setVisible(true); //set the graphical elements of our Swing application to visible, so they can be seen.
       exitItem.addActionListener(new ActionListener() { //adds an ActionListener interface for our exitItem
            public void actionPerformed(ActionEvent e) {
                   System.exit(0); //exit our application
            }
        });
    //--Add actionListeners for our submenu items and the functionality code:
      showlblItem.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
           menuLabel.setVisible(true); //hide our menuLabel
            }
        });
          hidelblItem.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
            menuLabel.setVisible(false); //show our menuLabel
            }
        });
    } //end of class
    public static void main(String[] args) {
      new MainFrame();
    }
}



There are obviously more things that you can do with a Java Menu and many more ways you can customize your menu such as the following, we will finally add a ToolTipText which is a tip that is shown to the user when they hover over the menu item that displays what the menu is about, the format is like follows:

<item>.setToolTipText(Message);


so this would work:
exitItem.setToolTipText("Exit The Program");
hidelblItem.setToolTipText("Hide Label");
showlblItem.setToolTipText("Show Label");



A Java menu is quite a interesting component and definitely a must have in your program, there are other ways of implementing a menu system such as via buttons, a JToolBar etc... However I really enjoy using this menu system as it is simplistic and effective.

Now, some may wonder but i'm really bad at art, I'm going to do a bad Icon and my menu will look terrible! No worries, there are many free Swing Icons on the internet and this set is what was used in this tutorial http://java.sun.com/...tory/index.html
and are rather standard in Java applications.

For those that are new to Swing, I have some links for you that you can read before reading this tutorial that should bring you up to scratch:
http://www.javaswingtutorial.com/ and http://www.javabegin...-swing-tutorial
There are of course also some great tutorials here on Dream In Code, so you can also read those.
The final output of our Java Menu Swing application should be similar to:

Posted Image

The full code listing for this tutorial can be found here:

import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
public class MainFrame extends JFrame{
    JLabel menuLabel = new JLabel ("This is my Menu!");
    MainFrame() {
        //------Setup of simple menu
        JMenuBar menuBar = new JMenuBar(); //set up of JMenuBar, this is the final element that the menu itself will be displayed in, similiar to a container.
        ImageIcon exitIcon = new ImageIcon ("close.gif"); //stores our Image for the exit command of the menu.
        ImageIcon hideIcon = new ImageIcon ("hide.gif");
        ImageIcon showIcon = new ImageIcon ("show.gif");
        JMenu menu = new JMenu("Menu"); //sets up the JMenu
        JMenu exitMenu = new JMenu("Label"); //creation of our submenu
        menu.setMnemonic(KeyEvent.VK_M); //allows our menu to be accessed when we click ALT + M, you can do this for individual menu items aswell.
        JMenuItem exitItem = new JMenuItem ("Exit Program", exitIcon);//create our first command (menu item)
        JMenuItem hidelblItem = new JMenuItem ("Hide Label", hideIcon);
        JMenuItem showlblItem = new JMenuItem("Show Label", showIcon);
        //Add ToolTipTexts
        exitItem.setToolTipText("Exit The Program");
        hidelblItem.setToolTipText("Hide Label");
        showlblItem.setToolTipText("Show Label");
        menu.add(exitItem); //add the command (menu item) to our menu
        exitMenu.add(hidelblItem); //add our JMenuItem's to our submenu --*
        exitMenu.add(showlblItem); //--*
        menu.addSeparator(); //visual element that seemingly splits our two menu's, you can comment this out, it just makes the program look nicer :)/>
        menu.add(exitMenu); //Add our submenu to our original menu.
        menuBar.add(menu); //add the JMenu to the JMenuBar
        setJMenuBar(menuBar); //set the default JMenuBar of the Swing application
        //------Setup of JFrame
       // FlowLayout layout = new FlowLayout();
        setSize(650,450); //set the size of the application (350 pixels width, 175 pixels high)
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //set what occurs when the "X" button at the top right of the application is clicked
        setTitle("Menu in Java"); //set the title of our Swing application
        menuLabel.setText("This is my Menu Comment!");
      //  setLayout(layout);
        add(menuLabel); //adds the label to our form using the defaul FlowLayout.
        setVisible(true); //set the graphical elements of our Swing application to visible, so they can be seen.
       exitItem.addActionListener(new ActionListener() { //adds an ActionListener interface for our exitItem
            public void actionPerformed(ActionEvent e) {
                   System.exit(0); //exit our application
            }
        });
    //--Add actionListeners for our submenu items and the functionality code:
      showlblItem.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
           menuLabel.setVisible(true); //hide our menuLabel
            }
        });
          hidelblItem.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
            menuLabel.setVisible(false); //show our menuLabel
            }
        });
    } //end of class
    public static void main(String[] args) {
      new MainFrame();
    }
}


(Note: When compiling the source code you will not see any icons as these icons have to got to be in the same project folder
Icons:
exitIcon: Posted Image
hidelblIcon: Posted Image
showlblIcon: Posted Image
)


I hope you have enjoyed my tutorial and that it has benefited you :)
Thanks,
v0rtex

Is This A Good Question/Topic? 9
  • +

Replies To: Implementing Menus using the Swing Toolkit

#2 alpha_x  Icon User is offline

  • D.I.C Head

Reputation: 6
  • View blog
  • Posts: 55
  • Joined: 03-May 11

Posted 04 May 2011 - 11:49 AM

Nice tutorial Thanks!
Was This Post Helpful? 0
  • +
  • -

#3 MrGreenforya  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 06-March 11

Posted 14 May 2011 - 12:38 PM

Pretty interesting tutorial. Go stop signs for exiting!
Was This Post Helpful? 0
  • +
  • -

#4 darek9576  Icon User is offline

  • D.I.C Lover

Reputation: 198
  • View blog
  • Posts: 1,682
  • Joined: 13-March 10

Posted 14 May 2011 - 01:28 PM

Very good tutorial. Thanks.
Was This Post Helpful? 0
  • +
  • -

#5 v0rtex  Icon User is offline

  • Caffeine: db "Never Enough!"
  • member icon

Reputation: 223
  • View blog
  • Posts: 773
  • Joined: 02-June 10

Posted 15 May 2011 - 01:26 AM

Welcome, glad to help
Was This Post Helpful? 0
  • +
  • -

#6 uzzi7862  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 17
  • Joined: 28-February 12

Posted 30 June 2012 - 01:16 PM

mod: removed silly excessive quote

Hello i was just wondering if you know how to use images for the Jmenu and JmenuItems.Like instead of the stanard look i want to apply my own image to the item to make it look diffrent

This post has been edited by modi123_1: 11 July 2012 - 08:25 AM
Reason for edit:: removed excessive quote

Was This Post Helpful? 0
  • +
  • -

#7 v0rtex  Icon User is offline

  • Caffeine: db "Never Enough!"
  • member icon

Reputation: 223
  • View blog
  • Posts: 773
  • Joined: 02-June 10

Posted 11 July 2012 - 08:14 AM

Just use a different image than the ones I used... Those are not the standard, mainly a free artwork set for open-source use.
Was This Post Helpful? 0
  • +
  • -

#8 vbabey  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 73
  • Joined: 30-July 12

Posted 15 August 2012 - 02:28 AM

A very good tutorial...
Everything is explained in the best way...
Thanks for these tutorials..
Post more tutorials...
Good Luck
Was This Post Helpful? 0
  • +
  • -

#9 Betrayal  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 29
  • Joined: 09-March 12

Posted 15 August 2012 - 04:06 AM

Thank you, this is a very great tutorial as I am a bit new to Swing! This taught me how to make submenu and put graphics inside menu, which I didn't know before.

This post has been edited by Betrayal: 15 August 2012 - 04:06 AM

Was This Post Helpful? 0
  • +
  • -

#10 LocalNomad  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 01-September 11

Posted 17 September 2012 - 12:56 PM

Thanks for posting this tutorial. i am new to J-Swing and exciting about using graphics. I ran into a problem though. I ran this code and It did not work it said no main methods, appelets, or MIDIlets found. I am not sure what this means. I tried alligning the text but that didn't work. What do I need to include in this code?





View Postv0rtex, on 01 May 2011 - 04:51 AM, said:

Implementing Menus using the Swing Toolkit:

(note: I expect you to have a basic working knowledge of the Swing toolkit, there are "read on" articles after the tutorial for those that are new to Swing, you should cope fine either way.)
A menu is one of the most important (if not the most important) aspect of any application that features a GUI (Graphics User Interface http://en.wikipedia....user_interface)
A menu in simple terms is a visual element whereby the most commonly used and generally most needed commands for the applications are grouped. There are various ways that a menu can be implemented in Java however in this tutorial we are going to learn one of the most common methods to implement a menu in any application designed with the Swing Toolkit.
Now onto setting up a menu in a JFrame:
import javax.swing.*;
public class MainFrame extends JFrame{
    MainFrame() {
        //------Setup of simple menu
        JMenuBar menuBar = new JMenuBar(); //set up of JMenuBar, this is the final element that the menu itself will be displayed in, similiar to a container.
        ImageIcon exitIcon = new ImageIcon ("close.gif"); //stores our Image for the exit command of the menu.
        JMenu menu = new JMenu("Menu"); //sets up the JMenu
        menu.setMnemonic(KeyEvent.VK_M); /*allows our menu to be accessed when we click ALT + M, you can do this for 
        individual menu items aswell. */                    
        JMenuItem exitItem = new JMenuItem ("Exit Program", exitIcon);//create our first command (menu item)
        menu.add(exitItem); //add the command (menu item) to our menu
        menuBar.add(menu); //add the JMenu to the JMenuBar
        
        setJMenuBar(menuBar); //set the default JMenuBar of the Swing application
        //------Setup of JFrame
        setSize(350,175); //set the size of the application (350 pixels width, 175 pixels high)
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //set what occurs when the "X" button at the top right of the application is clicked        
        setTitle("Menu in Java"); //set the title of our Swing application
        setVisible(true); //set the graphical elements of our Swing application to visible, so they can be seen.
    }
    public static void main(String[] args) {
      new MainFrame(); 
    }
}


Now, what you should see when you run this program is:

Posted Image

However try and click on your menu item...
Nothing happens, don't worry you haven't done anything wrong :)

We have to get our menu item to receive input:
There are several ways to receive input from the computer all thanks to the java.awt.event package. In this tutorial we will receive input via the mouse or keyboard to our menu items using an ActionListener interface. This is quite a simple task and is done via the following:

  • We set up a Listener for our menu item, in this case we do so using an ActionListener interface
  • We then add what would occur should a user event occur on our exit menu item.
  • That's it, now if the exitItem is clicked via a button or mouse, our functionality coded above will occur!


The process of doing the above is rather simplistic, here is the code:
   exitItem.addActionListener(new ActionListener() { //adds an ActionListener interface for our exitItem
            public void actionPerformed(ActionEvent e) {
                   System.exit(0); //exit our application should the user click our menu item called exit
            }
        });


That was simple enough, there are many more things that we can do with menus in java such as the following:
Setting up a submenu:

A submenu is a menu to which is nested within another menu. Each menu that is created can have a submenu, a submenu is generally used to group similiar commands together. In the next example, we will group commands that will show a label together. See the code below:
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
public class MainFrame extends JFrame{
    JLabel menuLabel = new JLabel ("This is my Menu!");
    MainFrame() {
        //------Setup of simple menu
        JMenuBar menuBar = new JMenuBar(); //set up of JMenuBar, this is the final element that the menu itself will be displayed in, similiar to a container.
        ImageIcon exitIcon = new ImageIcon ("close.gif"); //stores our Image for the exit command of the menu.
        ImageIcon hideIcon = new ImageIcon ("hide.gif");
        ImageIcon showIcon = new ImageIcon ("show.gif");
        JMenu menu = new JMenu("Menu"); //sets up the JMenu
        JMenu exitMenu = new JMenu("Label"); //creation of our submenu
        menu.setMnemonic(KeyEvent.VK_M); //allows our menu to be accessed when we click ALT + M, you can do this for individual menu items aswell.
        JMenuItem exitItem = new JMenuItem ("Exit Program", exitIcon);//create our first command (menu item)
        JMenuItem hidelblItem = new JMenuItem ("Hide Label", hideIcon);
        JMenuItem showlblItem = new JMenuItem("Show Label", showIcon);
        menu.add(exitItem); //add the command (menu item) to our menu
        exitMenu.add(hidelblItem); //add our JMenuItem's to our submenu --
        exitMenu.add(showlblItem); //--
        menu.addSeparator(); //visual element that seemingly splits our two menu's, you can comment this out, it just makes the program look nicer :)/>
        menu.add(exitMenu); //Add our submenu to our original menu.
        menuBar.add(menu); //add the JMenu to the JMenuBar
        setJMenuBar(menuBar); //set the default JMenuBar of the Swing application
        //------Setup of JFrame
       // FlowLayout layout = new FlowLayout();
        setSize(650,450); //set the size of the application (350 pixels width, 175 pixels high)
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //set what occurs when the "X" button at the top right of the application is clicked
        setTitle("Menu in Java"); //set the title of our Swing application
        menuLabel.setText("This is my Menu Comment!");
      //  setLayout(layout);
        add(menuLabel); //adds the label to our form using the defaul FlowLayout.
        setVisible(true); //set the graphical elements of our Swing application to visible, so they can be seen.
       exitItem.addActionListener(new ActionListener() { //adds an ActionListener interface for our exitItem
            public void actionPerformed(ActionEvent e) {
                   System.exit(0); //exit our application
            }
        });
    //--Add actionListeners for our submenu items and the functionality code:
      showlblItem.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
           menuLabel.setVisible(true); //hide our menuLabel
            }
        });
          hidelblItem.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
            menuLabel.setVisible(false); //show our menuLabel
            }
        });
    } //end of class
    public static void main(String[] args) {
      new MainFrame();
    }
}



There are obviously more things that you can do with a Java Menu and many more ways you can customize your menu such as the following, we will finally add a ToolTipText which is a tip that is shown to the user when they hover over the menu item that displays what the menu is about, the format is like follows:

<item>.setToolTipText(Message);


so this would work:
exitItem.setToolTipText("Exit The Program");
hidelblItem.setToolTipText("Hide Label");
showlblItem.setToolTipText("Show Label");



A Java menu is quite a interesting component and definitely a must have in your program, there are other ways of implementing a menu system such as via buttons, a JToolBar etc... However I really enjoy using this menu system as it is simplistic and effective.

Now, some may wonder but i'm really bad at art, I'm going to do a bad Icon and my menu will look terrible! No worries, there are many free Swing Icons on the internet and this set is what was used in this tutorial http://java.sun.com/...tory/index.html
and are rather standard in Java applications.

For those that are new to Swing, I have some links for you that you can read before reading this tutorial that should bring you up to scratch:
http://www.javaswingtutorial.com/ and http://www.javabegin...-swing-tutorial
There are of course also some great tutorials here on Dream In Code, so you can also read those.
The final output of our Java Menu Swing application should be similar to:

Posted Image

The full code listing for this tutorial can be found here:

import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
public class MainFrame extends JFrame{
    JLabel menuLabel = new JLabel ("This is my Menu!");
    MainFrame() {
        //------Setup of simple menu
        JMenuBar menuBar = new JMenuBar(); //set up of JMenuBar, this is the final element that the menu itself will be displayed in, similiar to a container.
        ImageIcon exitIcon = new ImageIcon ("close.gif"); //stores our Image for the exit command of the menu.
        ImageIcon hideIcon = new ImageIcon ("hide.gif");
        ImageIcon showIcon = new ImageIcon ("show.gif");
        JMenu menu = new JMenu("Menu"); //sets up the JMenu
        JMenu exitMenu = new JMenu("Label"); //creation of our submenu
        menu.setMnemonic(KeyEvent.VK_M); //allows our menu to be accessed when we click ALT + M, you can do this for individual menu items aswell.
        JMenuItem exitItem = new JMenuItem ("Exit Program", exitIcon);//create our first command (menu item)
        JMenuItem hidelblItem = new JMenuItem ("Hide Label", hideIcon);
        JMenuItem showlblItem = new JMenuItem("Show Label", showIcon);
        //Add ToolTipTexts
        exitItem.setToolTipText("Exit The Program");
        hidelblItem.setToolTipText("Hide Label");
        showlblItem.setToolTipText("Show Label");
        menu.add(exitItem); //add the command (menu item) to our menu
        exitMenu.add(hidelblItem); //add our JMenuItem's to our submenu --*
        exitMenu.add(showlblItem); //--*
        menu.addSeparator(); //visual element that seemingly splits our two menu's, you can comment this out, it just makes the program look nicer :)/>
        menu.add(exitMenu); //Add our submenu to our original menu.
        menuBar.add(menu); //add the JMenu to the JMenuBar
        setJMenuBar(menuBar); //set the default JMenuBar of the Swing application
        //------Setup of JFrame
       // FlowLayout layout = new FlowLayout();
        setSize(650,450); //set the size of the application (350 pixels width, 175 pixels high)
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //set what occurs when the "X" button at the top right of the application is clicked
        setTitle("Menu in Java"); //set the title of our Swing application
        menuLabel.setText("This is my Menu Comment!");
      //  setLayout(layout);
        add(menuLabel); //adds the label to our form using the defaul FlowLayout.
        setVisible(true); //set the graphical elements of our Swing application to visible, so they can be seen.
       exitItem.addActionListener(new ActionListener() { //adds an ActionListener interface for our exitItem
            public void actionPerformed(ActionEvent e) {
                   System.exit(0); //exit our application
            }
        });
    //--Add actionListeners for our submenu items and the functionality code:
      showlblItem.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
           menuLabel.setVisible(true); //hide our menuLabel
            }
        });
          hidelblItem.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
            menuLabel.setVisible(false); //show our menuLabel
            }
        });
    } //end of class
    public static void main(String[] args) {
      new MainFrame();
    }
}


(Note: When compiling the source code you will not see any icons as these icons have to got to be in the same project folder
Icons:
exitIcon: Posted Image
hidelblIcon: Posted Image
showlblIcon: Posted Image
)


I hope you have enjoyed my tutorial and that it has benefited you :)
Thanks,
v0rtex

Was This Post Helpful? 0
  • +
  • -

#11 Mike+9  Icon User is offline

  • D.I.C Head

Reputation: 13
  • View blog
  • Posts: 104
  • Joined: 10-July 12

Posted 21 September 2012 - 12:02 AM

Great tutorial! Thank you for your work! :bigsmile:
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1