I want to have JMenu on a Side bar(JPanel) with sub menu.

I want to have the JMenu on the sidebar(which is a
JPanel placed at WEST). This JMenu shall have the sub
menu with it. I got the JMenu on the Sidebar but when
i take mouse over(or click) the MenuItem it is
displaying the sub Menu. I am attaching the my code.
Can anyone please let me know why it is not displaying
the sub menu and what should be added to my code to
work?
Thanks in Advance(see below for code)
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class SideBarMenu extends JFrame {
     JMenuItem menuItem1,menuItem2;
     JMenu books, softwares, tools;
     JSeparator horizontal1, horizontal2,horizontal3;
     JPanel p1, p2;
      public static void main(String[] args) {
       SideBarMenu vAR =  new SideBarMenu();
     public SideBarMenu() {
          super("Side Bar");
          setSize(500,500);
          setLocation(150,100);
          setResizable(true);     
          Container content = getContentPane();
          p1 = new JPanel(new BorderLayout());
          p2 = new JPanel();
          p2.setLayout(new GridLayout(20,1));
          p2.setBorder(BorderFactory.createLineBorder(Color.black,1));
          books = new JMenu("Books");
          horizontal1 = new JSeparator( JSeparator.HORIZONTAL );
          softwares = new JMenu("Softwares");
          horizontal2 = new JSeparator( JSeparator.HORIZONTAL );
          tools = new JMenu("Tools");
                                horizontal3 = new JSeparator( JSeparator.HORIZONTAL );
          //sub Menu for menu "books"     
          menuItem1 = new JMenuItem("Java");
          books.add(menuItem1);
          menuItem2 = new JMenuItem(".Net");
          books.add(menuItem2);
          //sub Menu for menu "Softwares"          
          menuItem1 = new JMenuItem("Java");
          softwares.add(menuItem1);
          menuItem2 = new JMenuItem(".Net");
          softwares.add(menuItem2);
          //sub Menu for menu "tools"          
          menuItem1 = new JMenuItem("Java");
          tools.add(menuItem1);
          menuItem2 = new JMenuItem(".Net");
          tools.add(menuItem2);
          p2.add(books);
          p2.add(horizontal1);
          p2.add(softwares);
          p2.add(horizontal2);
          p2.add(tools);
          p2.add(horizontal3);
          p1.add(p2,BorderLayout.WEST );
          content.add(p1);
          setVisible(true);
}

Hi Ashwin,
I saw the above code which is approaching my requirement... Thats cool man. Taking that as reference i modified it to make it what i want. The code i have modified and which is very closer to my requirement is attached below. I have set the Windows Look and Feel, because its easy to track my problems with it. The problems am having are:
1) When the mouse is removed from the menu its submenu is not disappearing.
2) When i take the mouse over the menu its making the name(Books/softwares/tools) of the menu invisible.
3) When i take the mouse over the sub menu items they are not getting highlighted, which means they are not listening
I hope u will solve these issues for me...
Also make the menu items work ie., just make them print when i click submenus like "Clicked books->java" and "clicked softwares->.Net" so that i get an idea of events....
Many Thanks .
Here we go,
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Container;
import java.awt.GridLayout;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionAdapter;
import javax.swing.BorderFactory;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.JSeparator;
import javax.swing.UIManager;
public class SideBarMenu4 extends JFrame
    JMenuBar menuBar;
    JPopupMenu popup = new JPopupMenu();
    JMenuItem menuItem1, menuItem2;
    JMenu books, softwares, tools;
    JLabel mainMenu = new JLabel("Main Menu");
    JMenu subMenu;
    JSeparator horizontal1, horizontal2, horizontal3;
    JPanel p1, p2;
    public static void main(String[] args)
        SideBarMenu4 vAR = new SideBarMenu4();
    public SideBarMenu4()
        super("Side Bar");
        setSize(500, 500);
        setLocation(150, 100);
        setResizable(true);
        setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
        Container content = getContentPane();
        p1 = new JPanel(new BorderLayout());
                    try {
          //MetalLookAndFeel.setCurrentTheme(new MacMetricsTheme());
             UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");            
        } catch(Exception e) {}
        p2 = new JPanel();
        p2.setLayout(new GridLayout(30, 1));
        p2.setBorder(BorderFactory.createLineBorder(Color.black, 1));
        books = new JMenu("Books");
        horizontal1 = new JSeparator(JSeparator.HORIZONTAL);
        softwares = new JMenu("Softwares");
        horizontal2 = new JSeparator(JSeparator.HORIZONTAL);
        tools = new JMenu("Tools");
        horizontal3 = new JSeparator(JSeparator.HORIZONTAL);
        // sub Menu for menu "books"
        menuItem1 = new JMenuItem("Java");
          popup.add(menuItem1);
        //books.add(menuItem1);
        menuItem2 = new JMenuItem(".Net");
          popup.add(menuItem2);
          popup.setPopupSize(100,50);
        menuBar = new JMenuBar();
        menuBar.setLayout(new GridLayout(0, 1, 5, 5));
        books.add(popup);
          books.setComponentPopupMenu(popup);
        books.addMouseMotionListener(new MouseMotionAdapter(){
            public void mouseMoved(MouseEvent e)
                 popup.show(books, 88, 0);
          softwares.add(popup);
          softwares.setComponentPopupMenu(popup);
        softwares.addMouseMotionListener(new MouseMotionAdapter(){
            public void mouseMoved(MouseEvent e)
                 popup.show(softwares, 88, 0);
          tools.add(popup);
          tools.setComponentPopupMenu(popup);
        tools.addMouseMotionListener(new MouseMotionAdapter(){
            public void mouseMoved(MouseEvent e)
                 popup.show(tools, 88, 0);
        // p2.add(menuBar);
        p2.add(books);
          p2.add(horizontal1);
          p2.add(softwares);
          p2.add(horizontal2);
          p2.add(tools);
          p2.add(horizontal3);
        p1.add(p2, BorderLayout.WEST);
        content.add(p1);
        setVisible(true);
}

Similar Messages

  • Question when I log into Firefox, the screen scrolls down and I have to use the side-bar to go back up to type my query into the 'search' window. How can I stop that and get Firefox to start with the 'search' window accessible? With thanks, Peter

    Question
    when I log into Firefox, the screen scrolls down and I have to use the side-bar to go back up to type my query into the 'search' window. How can I stop that and get Firefox to start with the 'search' window accessible? With thanks, Peter

    See this. <br />
    https://support.mozilla.com/en-US/kb/Firefox+hangs#Hang_at_exit

  • When I log into Firefox, the screen scrolls down and I have to use the side-bar to go back up to type my query into the 'search' window. How can I stop that and get Firefox to start with the 'search' window accessible? With thanks, Peter

    Question
    When I log into Firefox, the screen scrolls down and I have to use the side-bar to go back up to type my query into the 'search' window. How can I stop that and get Firefox to start with the 'search' window accessible? With thanks, Peter

    See this. <br />
    https://support.mozilla.com/en-US/kb/Firefox+hangs#Hang_at_exit

  • I want to have chords played so I can experiment with soloing my guitar. Is there a place to choose chords to be played back in GarageBand? For instance I want a Cmajor 7th chord looped? etc.

    I want to have chords played so I can experiment with soloing my guitar. Is there a place to choose chords to be played back in GarageBand? For instance I want a Cmajor 7th chord looped? etc.

    No extra gear required.
    Open up Logic
    Select 'software instrument' from the New Tracks box (which opens automatically with a new project)
    Select an instrument from the Library (to the right of the Global Tracks field), e.g. piano
    Click on the Tools icon, a drop-down list appears
    Select the Pencil tool
    Click in the Global Tracks area, next to your piano instrument track. A green box of a few bars will open
    Doubleclick on that and then, using the Pencil Tool again, draw your notes for each chord.
    Drag and 'draw' a green bar at the top of Global Tracks, and that's your loop.
    Play it and jam along!

  • HT4623 i have installed ios7 and when 'i agree to terms' etc, with sub menu....nothing happens. please tell me if i have missed something

    i have installed ios7 and when 'i agree to terms' etc, with sub menu....nothing happens. please tell me if i have missed something

    By the way, the safari setting is: private browsing off and accept cookies from visited. Much help is appreciated!

  • Right side bar problems with BC template

    I'm using the BC template that was called Cadca from themforest. It has a nice thumbnail portfolio gallery with a drop down menu called Categories. I am trying to use the Categories feature on another page WITHOUT the thumbnail feature. The problem is that it seems to over ride the class="box_one_third last". Which means that any box with box_one_third now has a preview_icon showing up on the box.
    You can see it here:
    http://www.eplusmarketing.com/video-sample-testimonial_4.html  Look next to the pie chart on the right side bar you'll see a shadow of the preview icon peeking out. Plus notice the sidebar and the main content the dividing line graphic disappeared.
    The problem I'm having is with a  sidebar that has the box_one_third. I tired to change it to: box_one_half and the side bar slides under the main content as shown here:
    http://www.eplusmarketing.com/video-sample-testimonial_copy.html
    the preview icon is gone, the nice dividing graphic is back, but it is no longer a side bar. The entire sidebar moved under the main content.
    Any ideas on how to solve this issue?

    Can anyone please help me with this problem regarding my website using the CADAC template (see the complete issue above posted on Oct 12th) and the issue about the portfolio categories drop down menu found on the Cadac BC's template?  Thank you!!

  • I have read 118 files (from a directory) each with 2088 data and put them into a 2 D array with 2cols and 246384row, I want to have aeach file on a separate columns with 2088 rows

    I have read 118 files from a directory using the list.vi. Each file has 2 cols with 2088rows. Now I have the data in a 2 D array with 2cols and 246384rows (118files * 2088rows). However I want to put each file in the same array but each file in separate columns. then I would have 236 columns (2cols for each of the 118 files) by 2088 rows. thank you very much in advance.

    Hiya,
    here's a couple of .vi's that might help out. I've taken a minimum manipulation approach by using replace array subset, and I'm not bothering to strip out the 1D array before inserting it. Instead I flip the array of filenames, and from this fill in the end 2-D array from the right, overwriting the column that will eventually become the "X" data values (same for each file) and appear on the right.
    The second .vi is a sub.vi I posted elsewhere on the discussion group to get the number of lines in a file. If you're sure that you know the number of data points is always going to be 2088, then replace this sub vi with a constant to speed up the program. (by about 2 seconds!)
    I've also updated the .vi to work as a sub.vi if you wa
    nt it to, complete with error handling.
    Hope this helps.
    S.
    // it takes almost no time to rate an answer
    Attachments:
    read_files_updated.vi ‏81 KB
    Num_Lines_in_File.vi ‏62 KB

  • I have a mac book pro i want to have another monitor added and open garageband with 2 projects open is this possible.

    I have a mac book pro I want to use 2 monitors and have garageband open with 2 projects is this possible?

    GarageBand can open only one project at a time.  Project are treated differently from audio files; you can have many audio files open in QuickTime or other audio players, but GarageBand will always close the current project when you open a new one.
    If you have the newest GarageBand 10.0 and the previous version, GarageBand '11, version 6.0.5, you can open one project in GarageBand 10.0 and one project in GarageBand '11.
    However, you cannot drag and top between the windows or transfer media. And once a project has been converted to GarageBand 10 format, it can no longer be opened by GarageBand '11.

  • Side Bar Navation with three Quick Links Help Required

    Dear OAF Team
    Can you guide me
    we have to show the single page with side navation with three quick links(Employee Details, Salary details, Transfered Details)
    when ever we click the Employee details link we need to show emplyee details complete with same page
    when ever we click the Salary Details link we need to show Salary Details complete with same page
    when ever we click the Transfered Details link we need to show Transfered Details complete with same page.
    If any body having same code and page files please send me [email protected]
    Thanks
    Venkat Reddy

    Dear Reetesh,
    Am able to get the HTML Tab type But am not able to get the HTML Side Navigator Menu Type
    I developed two search pages
    1 Employee details
    2 Assignment Details
    Both information coming with Two Tabs in Home Page but my client want to show side Navigator Links
    Please find what i created Functions and Menus
    Function Creation Details
    Function Name : XX_EMP_SEARCH
    User Function Name: Employee Details
    Web HTML: OA.jsp?page=/xxtab/oracle/apps/per/selfservice/webui/XXEmployeeDetailsPG
    Function Name : XX_EMP_ASS_SEARCH
    User Function Name: Employee Details
    Web HTML: OA.jsp?page=/xxtab/oracle/apps/per/selfservice/webui/XXEmployeeAssignmentsDetailsPG
    Function Name : XX_EMP_HOME_FUN
    User Function Name: Employee Details Home Page
    Web HTML: OA.jsp?page=/xxtab/oracle/apps/per/selfservice/webui/XXEmployeeDetailsPG&OAHP=XX_EMP_ASS_HOME_MENU&OASF=XX_EMP_HOME_FUN
    Function Name : XX_ASS_HOME_FUN
    User Function Name: Assignment Details Home Page
    Web HTML: OA.jsp?page=/xxtab/oracle/apps/per/selfservice/webui/XXEmployeeAssignmentsDetailsPG&OAHP=XX_EMP_ASS_HOME_MENU&OASF=XX_ASS_HOME_FUN
    Standard Menu Details
    Menu Name : XX_EMP_STANDARD_MENU
    User Menu Name : Employee and Assignment Details Standard Menu
    Discription: Employee and Assignment Details Standard Menu
    Promite Name : Employee Assignment Details
    Submenu : Employee and Assignment Home Page
    Home Page Details
    Menu Name: XX_EMP_ASS_HOME_MENU
    User Menu Name: Employee and Assignment Home Page
    Menu Type : Home Page
    Description: Employee and Assignment Home Page
    1 Promit: Employee Details
    Submenu: Employee Details Menu
    2 Promit: Assignment Details
    Submenu: Assignment Details Home Menu
    HTML Side Navigator Menu Details
    Menu Name : XX_EMP_HOME_MENU
    User Menu Name : Employee Details Menu
    Menu Type : HTML Side Navigator Menu
    1 Promit: Employee Details Home Page
    Function Name: Employee Details Home Page
    Description : Employee Details Home Page
    Menu Name : XX_ASS_HOME_MENU
    User Menu Name : Assignment Details Home Menu
    Menu Type : HTML Side Navigator Menu
    1 Promit: Assignment Details Home Page
    Function Name : Assignment Details Home Page
    Please give me idea how to resolve this issue
    Thanks
    Venkat Reddy
    [email protected]

  • Iphoto albums have disapeared from side bar? how do I recover them?

    All my iphoto albums have disareared from the side bar how do I recover them?

    To repair your iPhoto Library you basically select your iPhoto Library in the Finder, hold down the key-combination ⌥⌘ very firmly, then double click the iPhoto library to open the "LIbrary First Aid" panel. Select "Repair Database" to repair your database files in the library. You may also add an "Repair Permissions", if the first repair did not help.
    If all fails, try "Rebuild Database", but that should not be tried without a current backup. Did you bring a portable drive with you?
    You did not mention your iPhoto version; if your version is not the most recent 9.4.3, look at this document on how to run the repair: iPhoto 6 and later: Rebuilding the iPhoto library
    Léonie

  • Why some book marks open in side bar window and some don't, I want to turn it off

    Book marker side bar opens with some book markers. I want all to open in a new tab, full screen.
    Thanks

    For the bookmarks that open in the sidebar, right-click on the bookmark and select Properties. De-select the option "Load this bookmark in the sidebar"

  • Unwanted side bar History

    I have accidentally caused a side bar to appear on the left of Firefox which says History at the top and then has a small Search box and a dropdown menu called View. It is taking up screen space and I can't find a way to remove it.
    Thanks.

    { Ctrl + H } from the keyboard will close (and open) the History Sidebar.

  • Why most of the pages of my site are named "About me" if none have that name in the side bar nor in the inspector?

    Here is my site for you to see what I am talking about; http://www.minkstereo.com  after you enter, if you go to each of the menus you will notice that only Books and Ilustrations is named correctly in the tab, if you go to Drawings, Graphic Design, Crafts or any of the images you'll see that the page name is "About me" I have republished and check all over the page in iweb and I don't know why it is happening. Each page has a different name in accordance with the content both in the side bar and in the inspector it shows.
    Any help is appreciated thank you.

    Your images shows how to change the pagename, the filename. of the page.
    Not the browser title.
    Anyway, there is a textbox out of view that holds the title :
    Beats me what it is doing there, but here is the oft repeated explanation :
    iWeb uses the textbox in the Header layer of an iWeb page as the title in the browserwindow.
    If the textbox in the Header is missing, iWeb uses a textbox down the page in the Content layer. If that textbox is also missing, it uses another textbox. If that fails it uses the pagename in the Sidebar. To replace a missing textbox in the Header, choose another theme and then change it back to the original one.
    Sometimes you may want a different text in the titlebar and not display it on the page itself. Or not display it at all.
    So use that textbox in the Header layer. Type your text. Do Command-T to open the font palette and make the font smaller (Or do Command--(minus)). Then select the textbox. In the Inspector choose T, click a color to open the color palette and drag the opacity slider to 0 (zero).
    Resize the textbox. You may want to change the height of the Header layer.
    Do Command-Shift-B to move the textbox to the back, possibly behind other objects.
    Next add a optional second textbox to the Header layer and use that one to display text on the page.
    If you want to move the textbox to the front again to make changes, but can't remember the location on the page, drag the area with the mouse to select the objects.
    Deselect objects you do not want to move forward by Command-dragging  the mouse over these objects.
    Next do Command-Shift-F to move the textbox to the front. Repeat the steps in reverse order to make the text visible.
    Source : http://www.wyodor.net/htmlegg/TallCard/TallAjax.html?pg=BrowserWindowTitle

  • How can I have the side bar in iTunes 12??

    I just installed iTunes 12 that was claimed to provide "a more pleasant interface for navigation"!?!?
    Personally, I do not find the new view format pleasant at all. I expected to be allowed to go back to the lateral bar visualization, finding it as a view option. It was quite upsetting finding out that the option disappeared from the menue. Did you have the brilliant idea to remove it, or did you simply hide it somewhere else? (I am definitely too old to play "hide and seek" with visualization options and I really do not have the time either)
    Probably, kids like big figures that do not require any reading skill, unfortunately I do not.
    I conclusion, how can I have the side bar visible again in iTunes 12???
    Thank you
    P.S. Playlists is similar to lateral bar, but not the same, as it is not ONE allowing to navigate music, movies, podacast, but one for each.

    The functionality of the sidebar has changed indeed. But what's the problem? Category's of the library have been separated from playlists and moved to one of the top bars. I think it's an improvement for people using iTunes as a media-management tool. In the old version the playlists were at the bottom of the sidebar and if you had all options activated you had to scroll down to find your playlists.
    You don't have to do that anymore. Your music library is now aside with the playlists. If you want to activate another categorie you can use the icons in the topbar and still keep the overview on your playlists.
    People who use iTunes for syncing iDevices seem less happy with this new presentation. It seems a minor adjustment to me, but others seems to think otherwise.

  • How can i split the edit screen to have the same image side by side?

    In other words I want to have the before and after right next to each other
    thanks in advance!

    In Quick and Guided modes there is a View:  Before and After; however, if Expert mode, there is no such view. 
    In Export mode what you can do is open the Photo Bin, and right-click Duplicate, then choose Window / Tile and see the two images, side-by-side.  Then  you can do your edits on one of the two images and the other will remain the same.

Maybe you are looking for