Scroll bar in JPopupMenu when used in JList

Hi,
I want variable list (not combo box) where I can add multiple JMenuItems through JPopupMenu. I have created JList in JScrollPane and I have added multiple JMenuItems one by one but in output I am getting the list of JMenuItems without scrollbar. There is no way I can navigate to last JMenuItem in the JList. Could someone help me with integration of JList, JMenuItems, JPopupMenu with scroll bars?
Below given is the sample code. GUI components have been added through Netbeans.
public void updatePopUp()
final JPopupMenu menu = new JPopupMenu();
menu.setBorder(null);
menu.setAutoscrolls(true);
JMenuItem item = new JMenuItem("JMenuItem");
item.addActionListener(this);
menu.add(item);
item = new JMenuItem("JMenuItem");
menu.add(item);
item = new JMenuItem("JMenuItem");
menu.add(item);
item = new JMenuItem("JMenuItem");
menu.add(item);
item = new JMenuItem("JMenuItem");
menu.add(item);
item = new JMenuItem("JMenuItem");
menu.add(item);
item = new JMenuItem("JMenuItem");
menu.add(item);
item = new JMenuItem("JMenuItem");
menu.add(item);
item = new JMenuItem("JMenuItem");
menu.add(item);
item = new JMenuItem("JMenuItem");
menu.add(item);
item = new JMenuItem("JMenuItem");
menu.add(item);
item = new JMenuItem("JMenuItem");
menu.add(item);
item = new JMenuItem("JMenuItem");
menu.add(item);
item = new JMenuItem("JMenuItem");
menu.add(item);
item = new JMenuItem("JMenuItem");
menu.add(item);
item = new JMenuItem("JMenuItem");
menu.add(item);
item = new JMenuItem("JMenuItem");
menu.add(item);
item = new JMenuItem("JMenuItem");
menu.add(item);
item = new JMenuItem("JMenuItem");
menu.add(item);
item = new JMenuItem("JMenuItem");
menu.add(item);
item = new JMenuItem("JMenuItem");
menu.add(item);
item = new JMenuItem("JMenuItem");
menu.add(item);
item = new JMenuItem("JMenuItem");
menu.add(item);
item = new JMenuItem("JMenuItem");
menu.add(item);
item = new JMenuItem("JMenuItem");
menu.add(item);
item = new JMenuItem("JMenuItem");
menu.add(item);
item = new JMenuItem("JMenuItem");
menu.add(item);
item = new JMenuItem("JMenuItem");
menu.add(item);
item = new JMenuItem("JMenuItem");
menu.add(item);
item = new JMenuItem("JMenuItem");
menu.add(item);
item = new JMenuItem("JMenuItem");
menu.add(item);
item = new JMenuItem("JMenuItem");
menu.add(item);
item = new JMenuItem("JMenuItem");
menu.add(item);
item = new JMenuItem("JMenuItem");
menu.add(item);
item = new JMenuItem("JMenuItem");
menu.add(item);
item = new JMenuItem("JMenuItem");
menu.add(item);
item = new JMenuItem("JMenuItem");
menu.add(item);
item = new JMenuItem("JMenuItem");
menu.add(item);
menu.setVisible(true);
menu.pack();
varList.add(menu);
// Set the component to show the popup menu
/* this.addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent evt) {
if (evt.isPopupTrigger()) {
menu.show(evt.getComponent(), evt.getX(), evt.getY());
public void mouseReleased(MouseEvent evt) {
if (evt.isPopupTrigger()) {
menu.show(evt.getComponent(), evt.getX(), evt.getY());
}

I was going to say try setting the preferred (or maximum) size of the scrollpane to force it to be no larger than you want.
But ...
a) I don't see you putting menu items in a JList in that code. You are putting them directly into the popup menu (aka, the normal way to do things).
b) Calling setAutoscrolls() on the JPopupMenu does not make it a "scrollable" menu. It is for supporting dragging of components in a scrollpane (usually). Read the API docs.

Similar Messages

  • My horizontal scroll bar went missing when I maximise the window. How do I fix them?

    My horizontal scroll bar went missing when I maximise the window. How do I fix them? I tried everything; such as auto hide the task bar. Even with this, I still can't see the horizontal scroll bar. I even tried the following and I still can't see the horizontal scroll bar.
    1) In a new tab, type or paste about:config in the address bar and press Enter. Click the button promising to be careful.
    (2) In the search box above the list, type or paste dom and pause while the list is filtered
    (3) Double-click the dom.disable_window_open_feature.scrollbars preference to switch it from false to true. By choosing true, you disable sites from deciding whether there can be scrollbars on a window, and Firefox uses its standard behavior for the page.
    If you want to always get other bars, here are the corresponding settings:
    Menu Bar: dom.disable_window_open_feature.menubar
    Navigation Toolbar: dom.disable_window_open_feature.toolbar
    Bookmarks Toolbar: dom.disable_window_open_feature.personalbar
    Please help.

    Can you post a screen shot?
    Taking a Screen shot; '''''Windows > Start >''''' search box '''''> Snipping Tool'''''.
    Save the picture(s) to your desktop. Now look at the '''Reply''' box below.
    Do you see the button under it that says '''Browse'''? Click it and then select
    the screen shot(s) from the desktop.

  • How can I make the status bar hide automatically when using safari?

    How can I make the status bar hide automatically when using safari?

    When Safari is in FullScreen mode, menu bar will be hidden.
    Safari window to fit the screen?
    Move the mouse pointer to the bottom right corner of the Safari window.
    Double arrows will appear. Drag it to resize the window to fit the screen.

  • I can't scroll by hitting the space bar, or clicking on the scroll bar itself, or even use the scroll arrows- how do I make them work again?

    I wake up, unhibernate my laptop and suddenly I can't scroll by hitting the space bar, or clicking on the scroll bar itself, or even use the scroll arrows. In other programs it works fine. What happened and how do I fix this?

    You may have switched on [http://kb.mozillazine.org/accessibility.browsewithcaret caret browsing].<br />
    You can press press F7 (on Mac: fn + F7) to toggle caret browsing on/off.
    See http://kb.mozillazine.org/Scrolling_with_arrow_keys_no_longer_works
    * Tools > Options > Advanced : General: Accessibility: [ ] "Always use the cursor keys to navigate within pages"
    You can press Ctrl + L to go to the location bar.

  • Why does my scroll bar keep disappearing when I am trying to scroll on my macbook pro . I am using osx version 10.9

    The scroll bar keeps disappearing as I am trying to scroll on the macbook pro   osx 10.9 update installed.

    Scroll bars have been doing this since Lion. You can set them to stay on in System Preferences.

  • Setting scroll bar to inbisible when not needed

    Here is the post again, some quotation marks came out as
    letters before. This is correct version
    I'm using AS 2.0, and have added a
    scroll bar with instance name: ...................sb1
    a dynamic text field with instance name:.... tb1_txt
    an external text file named as:....................home.txt
    I want to make the scroll bar invisible or transparent, when
    its is not needed. I'm thinking that I may have to use the _visible
    property, but not sure of the correct code to integrate this.
    Any suggestions anyone?

    // Note:
    Create a movie clip to put the code into
    Use only 2 frames
    Use 2 layers
    Layer 1 put the action script
    Layer 2 put the textarea and the scrollbar
    Put a keyframe on each frame in only the Action Script layer.
    The 2nd layer should only have a keyfram on the first frame
    and span both frames 1 and 2.
    On the first frame (do not put a stop() method here)
    - set the visibility of the scrollbar to false
    - set the text content / value of the textarea
    On the second frame
    - Put the action script
    stop();
    if(textDisplay.maxscroll &gt; 1){
    textscroll._visible = true;
    } // if

  • Scroll Motion Elements Shake When Using Anchors

    When the browser window is narrower than the site, elements with scroll motion "shake", often severely, and sometimes change position when using links to jump to different anchors on the page. What causes this and is there a way to fix it?
    Here is the site I'm working with. If you scroll using the scroll bars, there is no issue, it only happens when using the links in the bar at the top. Any ideas? Thanks.
    http://cuberogroup.businesscatalyst.com/

    Hi @Kydos 
    Thank you for your reply.
    I grasp that if you disable the graphic driver in device manager the issue is gone.
    Here is a link to  Resolving Video and Graphics Issues that will assist with this.
    Have you tried running the  HP Support Assistant  to look for any HP updates?
    Here is a link to the  HP Envy 17t-1000 CTO Notebook Software & Drivers  to verify you have all the recommended updates.
    You could also try reseating the card if that does not help.
    Next would be to test the card. Testing for Hardware Failures (Windows 7, Vista)
    Good Luck!
    Sparkles1
    I work on behalf of HP
    Please click “Accept as Solution ” if you feel my post solved your issue, it will help others find the solution.
    Click the “Kudos, Thumbs Up" on the bottom right to say “Thanks” for helping!

  • My scrolling bar stopped working when I updated to firefox 3.6.9 and adobe flash 10.1

    Never had a problem before, but when I just updated to Firefox 3.6.9 my scrolling bar stopped working. It still works in vistas explorer and wordperfect, just not firefox.
    At the same time I updated to adobe flash 10.1 (I think). Whatever the latest version is.
    thnaks

    I have the same problem. I have never had a problem with Firefox before, and use it as my main browser. However recently, after updating to 3.6.8, its been crashing all the time. Up to 20 times an hour. Usually it occurs when I click a link from a Google search, or in Yahoo. Even if I send in a crash report and restart Firefox, it crashes as soon as the same page is brought back up, or the same link is clicked. I have also had it crash when completely idle. Its very frustrating as it is my favorite browser. I've resorted to using Google Chrome for the time being.

  • Website Won't Scroll in Google Chrome When using Layers

    Hi there, this is starting to really get frustrating.
    I am building a site in Adobe Muse, and I so far have three layers: Header (contains header elements), Intro (Contains the first part of the page everyone sees when they load the browser), Our Details (Contains the second section of what will be the first of many when the site is done). In google chrome, clicking the "Find out why" link works fine and scrolls to the section, but using the mouse wheel or scroll bar at any point in the website doesn't work- it just makes everything flicker and sometimes returns you to the top of the page if you are already in the second section. This seems to be happening in some other peoples muse websites in chrome that I looked at too: it seems to be layers that are causing the issue when viewed in chrome. It seems to work flawlessly in Internet Explorer however....
    The Link to my site that I am building is here: http://niad.businesscatalyst.com
    My google chrome version is the newest (Version 29.0.1547.66 m) for Windows 8
    This does not happen however on google chrome (or safari) for mac.

    Hey- thanks but that isn't the issue. The problem occurs when trying to scroll using the scroll wheel on the mouse or using the scroll bar. Scrolling using the anchor tag links like "Learn Why" works fine. Again, this problem only seems to effect the google chrome browser- version 29.0.1547.76 m
    This is also happening on pretty much every adobe muse site I visit-when usng this browser.
    Thanks,
    Jaiden

  • How can I retrieve the scroll bar in Home applications using OS 10.6.8?  I don't have a general section after clicking on System Preferences.  Thanks.

    I have deleted the scroll bar twice in 4 years and I still don't know how to set it back.  Please help.

    hi Samberl
    thanks a lot for the fast reply.
    I was dragging folders from main folders on the laptop-desktop  onto the external drive icon - to copy them across....
    Your suggestion sounds very promising -  I didn't know about 'cloning'.
    Yes the idea is to backup the laptop -    I thought I would just move it all now, new - and then keep saving/dragging physically   across to the new drive myself each day or two...
    Would this be the sizeof the internal hard drive = c.500 gb  ?   =   under the HD icon on desktop is written  : 
    " 499.76gb , 311.5 gb free  " 
    I can erase and start agin on the new external drive - so this plan is to make two partititions, rather than the one at present, and make one of them 500 gb ?
    I have found CCC [carbon copy cloner] googling - looks good.
    When CCC site says it backs up  the hard drive - would this  mean all my files  [over 100 gb] that are mostly  in folders on the desktop, plus the others in itunes, iphotos etc found in the HD icon,  would all copy across successfully [wherever they are in the computer ]  ?
    thanks again, hope you can clarify these things and then I will go for it. 
    It would be great and amazing if this 'lack of permission' message doesn't show up in the process of doing this ccc transfer - hopeful!
    Julie

  • Why can I no longer scroll with the mouse when using Pages?

    A few days ago, I realized that I am unable to scroll within a Pages document with the mouse.  The scroll bar is not there.  The scroll feature works fine, and after trying to figure this out myself with no success, I thought I'd ask here.  I have Pages '09 and I'm using OS X 10.9.5.

    Thanks.  That's not the problem.  Scrolling works in everything else except Pages.  I used to be able to scroll just by using my finger up or down on the mouse.  Now, I can't do that.  I tried setting the scroll bars to "Always", but then I have to physically click on the scroll bar and move it up and down.  Not like it's that much hassle, lol, but I got used to just scrolling with my finger on the mouse.

  • My scroll bar keeps freezing when a open a second PDF in a session.

    When I open the first PDF, it works just fine, but when I open a second PDF, either in a second tab or just later on in the same session, the scroll bar remains locked at the top.

    try doing a SMC RESET if you've tried repair permissions...

  • Scroll bar keeps sliding while using internet

    While using the internet, on certain web-pages, the scroll bar keeps sliding down or up and page will turn dark in color. I have linux operating system. What is causing this and how can I fix the problem.

    Start Firefox in <u>[[Safe Mode]]</u> to check if one of the extensions or if hardware acceleration is causing the problem (switch to the DEFAULT theme: Firefox (Tools) > Add-ons > Appearance/Themes).
    *Don't make any changes on the Safe mode start window.
    *https://support.mozilla.com/kb/Safe+Mode
    *https://support.mozilla.com/kb/Troubleshooting+extensions+and+themes
    Can you post a link where you see this?

  • Missing Scroll Bar with Maverick - when will it change?

    What are the plans to fix this problem?  I am about ready to get rid of my Apple MacPro because I am not finding Apple to be a "consumer friendly" company any longer.  Whoever made this decision, made a VERY bad one.  I waste so much time trying to get the scroll bar because I there is no longer  way to keep it visible.  Terrible way to lose a customer...guess my thoughts of an IPhone or IPad just went down the tubes, too!  Ha..I am trying to "scroll down" to send this...that was 2 minutes ago!

     (Apple menu) > System Preferences > General.
    The Discussion you referenced was for Safari's Preferences, not System Preferences, and the reply in that Discussion is correct.
    guess my thoughts of an IPhone or IPad just went down the tubes, too!
    Scroll bars are similar in both appearance and behavior in iOS.

  • Scroll Bar does not show using Mac OS X 10.10.1, Thunderbird 31.3.0

    I upgraded to Thunderbird 31.3.0, running Mac OS X 10.10.1. The scroll bars in both the inbox window and the message text window seem to have disappeared. There does not seem to be any support available on this.

    ''Matt [[#answer-671555|said]]''
    <blockquote>
    Ok so you most likely have an add-on or theme that is not compatible with the current version. Check in the add-ons manager for updates. Disable all add-ons and enable one at a time until the culprit is found.
    How does OSX 10.10.1 handle scroll bars. Perhaps appearing and disappearing is a new mac feature. Windows hiding menu bars is an infuriating OS feature, perhaps it is the mac users turn.
    </blockquote>
    Turns out, this is the case.
    If I drag two fingers over the Track Pad, the Scroll Bar does appear. If I don't let go of the Track Pad, and roll over to the Track Bar it stays up. I hate it, but now I have a work-around.
    Thank you, Matt.

Maybe you are looking for

  • How do I get back my phoneshortcut onto my homepage?

    I accidentally deleted my phone short cut key on my homepage and cant seem to find the phone shortcut to drag onto my home page Can any one please help?

  • Can't use eyedropper to pick colors

    Hi. Anyone know why I can't use the eyedropper  to pick color from the images (quadtone psd) I'm using in my brochure  project? When I attempt to do this, the Fill box in my tools panel gets a  diagonal red line going through it.

  • Importing java classes ?

    I'm trying to use "Java Embedding" process activity to add a simple java snippet, this code needs a set of classes. I've copied the required jar files to \OraBPELPM_1\integration\jdev\jdev\lib\ext. But I'm not able to figure out where to add the impo

  • Adobe After Effects CC 2014 warning plug-ins failed..

    Hello, This is a fresh update version with no previous 3rd party plug-ins. Asking if it is  better to delete and re-install program or other method to correct problem. Thanks for the help Kelly

  • LabVIEW Help Important Information Copyright page broken links

    None of the files or folders listed in the LabVIEW Help >> Important Information >>Copyright page are existing in my W7 64 bits LV 2013 installation: