Looking For JComboBox Help

(Sorry about the lack of rendered tags. I don't know how to use them in this forum.)
I have a JComboBox (a drop menu) that when opened clears all its items and then adds new items from a list. Whenever the list is augmented (and is small), the JComboBox's display size is too small, and it creates a little scrollbar to accomodate. When the popmenu is closed and reopened, the menu is normal. The problem is that when I open the menu after adding a new item to a list, I have to triple click the JComboBox to make it display correctly.
Numbers 2 and 4 are unwanted displays.
<img src="http://img.photobucket.com/albums/v251/Trinithis/dynamicDrive/jcombobox.jpg" />
I could fix it by having the button itself change the contents of the JComboBox (instead of popupMenuWillBecomeVisible()), but I want to have lazy evaluation for it because in my actual program the ArrayList will have to be sorted each time and the JComboBox will have to re-add all its contents. I suppose this is always an option, but I would like to know how to do it this or some other way.
<pre>
import javax.swing.*;
import javax.swing.event.*;
import java.util.*;
import java.awt.*;
import java.awt.event.*;
public class GUI extends JFrame implements ActionListener, PopupMenuListener {
     private JButton bAdd = new JButton("Add");
     private JComboBox jcb = new JComboBox();
     private ArrayList<String> items = new ArrayList<String>(10);
     private int addCount = 0;
     public GUI() {
          Container c = this.getContentPane();
          c.setLayout(new FlowLayout());
          bAdd.addActionListener(this);
          jcb.addPopupMenuListener(this);
          c.add(bAdd);
          c.add(jcb);
          this.setSize(200, 100);
          this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
          this.setVisible(true);
     public void actionPerformed(ActionEvent e) {
          Object source = e.getSource();
          if(source==bAdd) items.add("Item #" + addCount++);
     public void popupMenuWillBecomeVisible(PopupMenuEvent e){
          Object source = e.getSource();
          if(source==jcb) {
               jcb.removeAllItems();
               for(int i=0; i<items.size(); ++i) jcb.addItem(items.get(i));
     public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {}
     public void popupMenuCanceled(PopupMenuEvent e) {}
     public static void main(String[] args) {
          new GUI();
</pre>
Edited by: Trinithis on Sep 21, 2007 11:18 AM
Edited by: Trinithis on Sep 21, 2007 11:29 AM
Edited by: Trinithis on Sep 21, 2007 11:33 AM
Edited by: Trinithis on Sep 21, 2007 11:34 AM

try it a different way (not using the popupListener)
public GUI() {
Container c = this.getContentPane();
c.setLayout(new FlowLayout());
bAdd.addActionListener(this);
jcb.setUI(new javax.swing.plaf.metal.MetalComboBoxUI(){
  protected JButton createArrowButton(){
    JButton btn = super.createArrowButton();
    btn.addMouseListener(new MouseAdapter(){
      public void mousePressed(MouseEvent me){
        if(jcb.getModel().getSize() < items.size()){
          DefaultComboBoxModel model = new DefaultComboBoxModel();
          for(int i=0; i<items.size(); ++i){
            model.addElement(items.get(i));
          jcb.setModel(model);
    return btn;
//jcb.addPopupMenuListener(this);the tags you're looking for are
[code]
paste code here
[/code]

Similar Messages

  • I'm looking for some help connecting linksys IP Cameras to my home network to monitor my property when I'm travelling. I used to do this with linksys WAPS, but since I've discarded all my old linksys networking and standardized on airport, I can't get the

    I'm looking for some help connecting linksys IP Cameras to my home network to monitor my property when I'm travelling.  I used to do this with linksys WAPS, but since I've discarded all my old linksys networking and standardized on airport, I can't get these things working.  I know that I have to identify my camera through the DHCP table and set up port forwarding and there is the problem. 
    My network consists of 4  base stations set up in a roaming network - same network name and passwords.  I need to do it this way so I don't have to switch network when I move from one side of the house to the other, go to the cabana, or my shop in the barn.  The network works pretty well since I went to a roaming set up.  Good performance, yata, yata, yata.
    However, the roaming network requires the AEBS's to be set up in bridge mode, rather than sharing an ip address.  When the AEBS is set to  bridge mode, you don't see a DCHP table or have the ability to identify your IP Cam through the AEBS - and hence, no port forwarding. 
    I am able to identify and set up my Linksys IP Cam by locating the ip address on my FIOS router, even though, it's plugged into an AEBS.  I set it up, see the video, remove the ethernet cable from the IP Cam, restart - and I can't get to it from an AEBS.  In researching this, it appears, I should be setting up the AEBS to "share an IP Address", going to the DHCP table and identifying the camera's IP address and setting up port forwarding.  However, you don't see any of the DHCP or port forwarding options in Airport Network Utility when configuring in bridge mode. 
    I'm hoping I'm missing something here and that the solution isn't to set it up at the FIOS router level, but I'm beginning to think that's my only hope.  What concerns me there is that I should be able to see the IP cam on the network without port forwarding since I'm not coming from outside, and I can't even do this unless it's connected hard wire.
    I'd appreciate any insight into this that anyone might have.  I've hit the wall with what I know.
    Thanks.

    In a roaming network, your "main" router is the device that would require port mapping/forwarding to be configured in order to access the IP camera from the Internet. This router is also the one that would be provide the private IP address for the camera which you will want to be a static one.
    So as you described your network, the IP cameras should be getting an IP address or you assigned it a static one and this is the address that you would enter in the Private IP address (or equivalent depending on the router used) field when setting up port mapping.
    If you are not able to access this camera from the local network, then this should be troubleshot first.

  • Looking for some help in creating an ItemFilter for a Targeter

    Looking for some help in creating an ItemFilter for a Targeter
    Need a examples for creating itemfilter and TargeterFirst

    Hi David,
    We can integrate Syncfusion with LightSwitch application, if you want to customize column when create a report using syncfusion reportviewer, since I didn't try this third party
    extension before, I think you could consider getting help from
    syncfusion forum, more syncfusion experts can help you on this issue.
    Thanks for your understanding.
    Best regards,
    Angie
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Still looking for flex help

    I had a couple of responses to my request for help that were excellent. Unfortunately, I have lost all my emails and cannot find the email of the people who responded. Could you please respond again at [email protected] I am still looking for some help.
    thank you

    I've provided this type of basic support to others at $50 per hour. I bill in 15 minute increments, so for quick questions you would typically pay
    $12.50 per question, $50 / hour for more involved issues.
    One thing, I'm more of a front-end guy, so while I can help with HTTPService connecting to PHP scripts, I'm not up to speed on ColdFusion,
    Java, etc.
    I have a day job, so I would have to respond outside the hours of 9 - 5 pacific standard time.
    I have emailed you about this, so please reply to that email on this topic.

  • Evening folks...looking for some help about my iphone microphone

    Evening folks....looking for some help.....I have a 3G Iphone and when I phone people they cannot hear me properly...sound like I am underwater....
    Any ideas or suggestions gratelfully accepted..

    I thought that is what the big deal was that people did not know until they opened the box and started using the iPhone 5, that it not only worked with one carrier but several carriers.  I did not say it will work with any carrier at one time.  I was trying to find out the reason for this and why people were so surprised that the iPhone 5 had this function and the reason for it.  As stated in my post, is it there so that after your contract is up and you want to go to another carrier you do not have to purchase a new iPhone, you  cna purchase a SIM card that works with your new carrier.
    The Otterbox Defender has a tendency to let too much dirt, dust, etc. in the cracks on the case. At least this has been my expereince.  I was thinking something more along some of the really durable cases at BallisticCaseCo.com
    As far as the iPhone 5 having issues, I have heard that there were more than usual with the first couple of manufactured batches that were shipped.  For example the Map App by Apple, the scratches on the backside of hundreds of iPhones, etc.  I am hoping these will get to be less and less, but with the recent riot at the one plant in China where the iPhone 5 is assembled is supposed to increase the waiting time.

  • HI everyone. Im looking for some help. Im getting the Itunes error 50 and No network connection error. I have a perfect connection. My iphone will download and my ipad but nothing from my computer. any help would be great.

    HI everyone. Im looking for some help. Im getting the Itunes error 50 and No network connection error. I have a perfect connection. My iphod will not  download and my ipad  any help would be great.

    A lot of people are experiencing it, which suggests that Apple is having issues. If that is the case all people can do is wait it out.

  • New To The Forum And Looking For Speed Help!

    Hello, After trying to find information about my problem on the Internet and then speaking to the BT Indian Call Centre, I stumbled upon this forum. I am hoping, having looked at so many helpful comments and contributions, that I might be able to shed some light upon my connection speed issue. I have had a very pleasing and stable Internect connection speed of nearly 8Mb. However, I recently moved my router to the Master socket in the house which was better positioned to give a good WiFi signal throughout my house. However, when I have plugged in the router and booted it up, I can only connect at just over 4Mb regardless of what I try. I know I am at risk of sounding a touch ungrateful here because there are many more people with bigger problems than I but I would be very grateful for some advice / assisitance as to why my problem might have occurred and how I might regain my previous speed. Thank you in advance for any help! Cheers.
    Solved!
    Go to Solution.

    welcome to the forum
    in order for the forum members to help please can you post the adsl stats from your router may need to 'show detail' to get all stats (if hub enter 192.168.1.254 in your browser and navigate to adsl or use a-z, if netgear enter 192.168.0.1) and run btspeedtester (MAC users may have problems) http://speedtester.bt.com or http://bt.custhelp.com/app/answers/detail/a_id/935​4/c/346,4740,5520 and post the results .
    are you connected directly to the NTE5 master or test socket or to somewhere else? Is the master the only phone socket in your home?
    Have you tried the quiet line test? - dial 17070 option 2 - should hear nothing - best done with a corded phone. if cordless phone you may hear a 'dull hum' which is normal
    Someone may then be able to offer help/assistance/suggestions to your problem
    If you like a post, or want to say thanks for a helpful answer, please click on the Ratings star on the left-hand side of the post.
    If someone answers your question correctly please let other members know by clicking on ’Mark as Accepted Solution’.

  • Looking for some help!

    I have been using Dreamweaver for a short time now and
    absolutely love it. Okay I've been looking for sometime now and
    cannot find what I am looking for not sure if I'm just not looking
    in the right place and could use some help and advice. I my
    maincontent div area I would like to add something that I can post
    news, either weekly or a daily basis I have found alot of weblog
    programs, but what I am looking for is something simple. Hopefully
    someone will be able to help me out here.
    Thanks in advance for any info.

    >>the beer is optional :-)
    Sez You!
    Walt
    "Nancy O" <[email protected]> wrote in message
    news:g4r4d9$76$[email protected]..
    > Not sure what you mean exactly.
    > 1) Do you want to create and publish RSS feeds which
    people can subscribe
    > to?
    > Or 2) do you want to have other people's RSS news feeds
    appear on your web
    > site?
    >
    > If 1)
    > How to Create an RSS Feed with Notepad, a Web Server and
    a Beer - the beer
    > is optional :-)
    >
    http://www.downes.ca/cgi-bin/page.cgi?post=56
    >
    > RSS Specifications - everything you need to know about
    RSS:
    >
    http://www.rss-specifications.com/display-rss.htm
    >
    > FeedForAll - feed generating software for win/mac:
    >
    http://www.feedforall.com/
    >
    > If 2)
    > Feed Roll - javascript generator for including news
    feeds in websites:
    >
    http://www.feedroll.com/rssviewer/
    >
    > Google Ajax feedfetcher - requires you to have a Google
    API key#
    >
    http://www.dynamicdrive.com/dynamicindex18/gajaxrssdisplayer.htm
    >
    >
    > --Nancy O.
    > Alt-Web Design & Publishing
    > www.alt-web.com
    >
    >
    > "jvulga" <[email protected]> wrote in
    message
    > news:g4r2eu$rjm$[email protected]..
    >> I have been using Dreamweaver for a short time now
    and absolutely love
    >> it.
    > Okay
    >> I've been looking for sometime now and cannot find
    what I am looking for
    > not
    >> sure if I'm just not looking in the right place and
    could use some help
    > and
    >> advice. I my maincontent div area I would like to
    add something that I
    >> can
    > post
    >> news, either weekly or a daily basis I have found
    alot of weblog
    >> programs,
    > but
    >> what I am looking for is something simple. Hopefully
    someone will be able
    > to
    >> help me out here.
    >>
    >> Thanks in advance for any info.
    >>
    >
    >

  • Looking for some help with building insert statements...

    Hi, I am using some sql to build some insert statements for me to update a set of tables in our qa environments. The scripts that I have created were working great until someone added a column to some of the tables in the qa env which in turn makes my scripts break because I was simply building the statment to do someting like this...
    insert into dest_table (select * from source_table@dblink);
    But now when the coumns in the tables do not match it breaks...
    This is the dynamic create script I use, can anyone help or suggest a better way to be able to build update statements update to qa tables when the columns are mismatched?
    spool insert.sql
    select
    'insert into ' || table_name || ' (select * from ' || table_name || '@prod );' || chr(10) || ' commit;'
    from user_tables
    where table_name in
    (select * from refresh_tablesl)
    any help is greatly appreciated,
    Thanks.

    See my reply to your duplicate post
    looking for help building dynamic insert statements...

  • I am looking for some help page regarding organizing bookmarks

    Forgive me if I am mistaken, I have searched for some paragraph or any help page regarding organizing bookmarks but it returned zero results.
    More specifically, I am looking for a way to separate my bookmarks into different categories for example, game links and mathematics links and this game link book mark folder (Say) could further be broken into folders like counter strike links, stronghold crusader links....
    I shall be very thankful for any piece of advice in this regard
    Best Regards!!!

    Other things that need attention.<br>
    See http://www.mozilla.com/plugincheck/
    Your above posted system details show outdated plugin(s) with known security and stability risks that you should update.
    *Shockwave Flash 10.0 r12
    Update the [[Managing the Flash plugin|Flash]] plugin to the latest version.
    *http://www.adobe.com/software/flash/about/
    You can organize the bookmarks and create folders and sub folders ([[Bookmark folders]]) via the right-click context menu or the Organize menu in the Bookmarks Manager.
    See also http://kb.mozillazine.org/Sorting_and_rearranging_bookmarks_-_Firefox

  • Looking for some help with package design (box)

    I'm pretty good with Photoshop, but Illustrator is fairly new to me. I'm helping a friend do his product packages and I already have all of the graphics, I'm just having trouble figuring out how to put it all together in Illustrator.
    We already have the box dimensions and just need to get a vector file that the factory can use to print. My main question is how do I create the actual layout of the box to work on? In the pdf that was sent to us I can pull out the box, but it just sits on a white background.
    My next question is how do I fill the layout with a pattern. I have a carbon fiber look pattern in Photoshop, but I'm having trouble figuring out how to use it to fill in Illustrator.
    Thanks ahead of time for any help.

    Jem,
    Pardon me if I sound rude by suggesting that before you launch into an expensive printing job (which could result in disastrous consequences if you don't do it right) that you actually learn how to use the program first. You may also want to learn something about the offset printing process and how to prepare print jobs.
    Even many Illustrator novices know that there is no such thing as a background in Illustrator, in the sense that there is in Photoshop. You will need to PLACE your Photoshop background as a high resolution CMYK tiff in the provided template. That's the answer to your second question. I don't really understand your first question. Maybe someone else will. Are you simply asking, "where do I begin?" If so, then you REALLY REALLY need to read a book on how to use Illustrator. The Adobe Illustrator Classroom in a Book might be the place to start.
    "I'm pretty good with CPR. I'm helping a friend do his vasectomy and I already have all the equipment (scalpels, thread, etc.) I'm just having trouble figuring out where to cut."

  • Paid Project:  Looking for some help with the AddressBookUI Framework

    I am looking for someone with experience accessing contacts using the AddressBook related frameworks. I am able to call up the contacts modal view using the ABPeoplePickerNavigationController, but am having problems accessing the variables in the "person" "property" and/or "identifier" properties.
    I am working from within the shouldContinueAfterSelectingPerson:person:property:identifier method. When the user taps on a phone number or other element in the picker, I want to pass the information as a string to a variable in my program.
    If someone knows how to do this, and can help, let me know. I would love free advice, but also don't mind paying for your time. If I can get past this thing, I can move on with the rest of the program.
    Many thanks.

    Looks like I have it covered. Thanks to those that responded.
    --Mike

  • A Potential Convert Looking for Some Help with Boot Camp

    I posted this in the Macbook Pro forums, and somebody directed me here. Hopefully you can help me with my questions.
    Hello,
    I have been a PC user ever since I can remember. I have loved the operating system and have had a Dell Laptop for 4 years now without any problems at all. I have no qualms with the Windows Operating Systems. But, it is time for me to get a new laptop, as I will soon be heading off to college. I was thinking about getting another PC, as they are significantly cheaper than the lower-end MBP that I would get, but I was also thinking about trying out a Mac. I plan on using this laptop for most of my undergraduate education though, so I don't want to buy something and find out it isn't what I want or I can't use it. So, if you would help me, I would like to ask some questions about the lower-end Macbook Pro, and I may just end up getting one.
    First things first, I am going to be going into engineering, likely mechanical or systems, at either WPI, Northeastern, or Tufts. Ah the experience of choosing colleged. I know Tufts uses AutoCAD, WPI uses SolidWorks, but I am not sure which Northeastern uses. Either way, I most certainly will be using a CAD program. I know that most CAD programs do not work on Macs, so I will likely be using Boot Camp. I have though seen on these boards that the AutoCAD licensing does not work with Boot Camp, or that some users have faced major problems with it. If this is so, then it is highly likely that I will be unable to get a Mac as that program is going to be an absolute necessity. Even if this is just a small percentage of the population, I do not want to find mine being of major issue. For those of you who have gotten it to work, how difficult was the installation, and have you had any issues with AutoCAD or the like? With this in mind, would you even suggest that I get a MBP?
    Another Boot Camp question. I have read many posts on these boards discussing different partitioning options, yet I still am unsure what they all mean. I expect to use the Windows side for more than just AutoCAD. I likely will install some games on it for when I am bored, and Microsoft Office, as I do not wish to spend the extra money buying Office for Mac and I need to have the versatility of Excel that I have heard is not found in the Mac version. What is the difference between these two partitioning types, which would you recommend, and how much storage should I partition if I get a 200GB hard drive?
    Yet another Boot Camp question, sorry for so many of these. My friend who has a Mac lauds it for its security, nobody makes viruses for Macs. As I will most definitively be using Windows in Boot Camp, would this compromise this security? I know it will be Windows, but I still imagine that it would be encoded somewhat differently then normal, but I could be wrong. Also, if it is possible for the Windows portion to get a virus, could that affect the Mac portion?
    Also, I don't use an iPod. I suppose I always thought they were overpriced for what they do. Instead I use an Iriver Clix 2, and I love it. The only thing is, I use Windows Media Player to sync it with my library. I know many have qualms with WMP, but I personally favor it more than iTunes, but that is just me. I do not believe that you can download it for a Mac. If I were to download it for the Windows portion, I am assuming that I would have to switch to Windows in order to listen to my music then, correct? I can also add music to it via Windows Explorer. Can I do so through the "Finder"?
    Finally, is the battery life any different when using Windows than when using Leopard? I will likely be using the Windows portion in the class room.
    Sorry for the long-winded post, but I am certainly hoping that I can get some solid answers to make an educated decision before getting my next laptop. I would like to thank you very much for any help that you are able to give me. I do hope you can help me quickly. Thank you.
    Message was edited by: Pyrojoe

    I can't answer all your questions, especially not anything having to do with CAD.
    I still imagine that [Windows] would be encoded somewhat differently then normal,
    No. Windows is Windows. You will need a good Windows antivirus, firewall and antispyware program. It is unlikely that a Windows virus will infect the Mac partition because, ordinarily, Windows doesn't know how to do anything with the HFS+ formatted Mac partition. However, the existence of products like MacDrive means that it is possible to teach Windows how to write to the Mac partition, so I see no reason why a virus could not be programmed to.
    If I were to download it for the Windows portion, I am assuming that I would have to switch to Windows in order to listen to my music then, correct? I can also add music to it via Windows Explorer. Can I do so through the "Finder"?
    Yes. Probably/yes.
    Finally, is the battery life any different when using Windows than when using Leopard?
    Yes. Windows does not have the battery management that Leopard has. The battery runs down much quicker in Windows.
    You didn't ask, but depending on what kind of engineering you want to study, you may be interested in, or even need to, use some flavour of Unix/Linux. On the one hand, you could always create a partition on a PC--or wipe Windows--and install Linux on the PC. That could even be a good learning experience. On the other hand, Mac OS is Unix, but preinstalled. So with a Mac, you would already have a platform for writing shell scripts, you would have Perl and Python built-in, you would have an IDE (XCode Tools) for C/C++/Objective C/Java as well as gcc and make tools already on the disks which come with the computer, and so on.
    Message was edited by: Mr.Lobotomy

  • SQL SCRIPT LOOKING FOR PAPERCLIP HELP

    Good morning,
    Please I need hel I am looking for this famous paperclip  I have choosed each Icon and I cant find it
    Thank you
    Microsoft SQL Server Management Studio:<o:p></o:p>
    1. Right-click the paperclip icon to the left to open the Table_Size.txt script or save<o:p></o:p>
    the script to your hard disk. You’ll use this script to identify the largest table by<o:p></o:p>
    size in kilobytes in a Microsoft Database.<o:p></o:p>

    Then why do you ask strangers rather than your "consultant"?  And this question sounds much like your previous one
    how to get table size

  • Looking for some help with dbms_datapump.data_remap

    I moved this post from a diffrent forum. I think it might be a better fit.
    Hi I am trying to pass this line but keep getting ORA-39001: invalid argument value:
    dbms_datapump.data_remap(dph, 'EMP_NAME', 'EMP', 'ENAME', 'DATA_MASKER_UTIL.mask_varchar2', NULL);
    I am on Oracle 11.1.0.6.0 and using the SCOTT schema.
    Thanks for any help.

    Chris wrote:
    dbms_datapump.data_remap(dph, 'EMP_NAME', 'EMP', 'ENAME', 'DATA_MASKER_UTIL.mask_varchar2', NULL);Are you sure values being passed are correct? Because, as the [url http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28419/d_datpmp.htm#CHDHJFCB]documentation says, value of parameter name should be 'COULMN_NAME'.
    Also have a read of [url http://forums.oracle.com/forums/thread.jspa?messageID=9372117]this thread and specification of SYS.DBMS_DATAPUMP package.

Maybe you are looking for

  • How can I have two devices with separate iTunes accounts on the same computer without sharing libraries?

    I have an iPhone 3s and my sister has an iPhone 3.  We use them only as iPods.  We each have our own iTunes account, but we have to share a computer.  How can we both syn our devices without sharing our music and app libraries?

  • Can not add videos to library

    Hi, i am having trouble adding vidoes to the itunes library. i have added 9 with no dramas, all play perfect on the iPod, but i can no longer add any more. i click on add files, the top of itunes quicky flashes teh tranfer bar, then nothing?? i have

  • GRC AC 10 Show approved requests in work inbox

    Hello, Is it possible to show approved requests in work inbox? Denis.

  • Loaded  Data is not yet visible in Reporting

    Dear Experts, If i am uploading data in  Plant Maintenance Delta cube . The request status is green but it is not available for reporting. It scheduled daily. Regards, Anand Mehrotra.

  • New Canon 5D MkIII

    I have just downloaded  RAW 6.7 and PS5 will now see and open my files. BUT LR3 will not Any suggestions or do I just have to wait and not use LR3 until a version for that arrives. I am running these on an iMac (1 yr old) The computer also does not h