Setting default value for a jcombobox based on the value not the index

I am trying to set the default value for my combobox to the current year. One way I thought of doing it was to get the index of the value representing the current year and then use setSelectedInex to make it the default. Any ideas?
The relevent section of code is below.
GregorianCalendar gregorianCalendar = new GregorianCalendar();
int year = gregorianCalendar.get(Calendar.YEAR);
String currentyear = year + "";
int startyears = 2000;
int numyears = 25;
JComboBox endyearcombobox = new JComboBox();
endyearcombobox.setBorder( BorderFactory.createLineBorder(Color.DARK_GRAY));
endyearcombobox.setFont(standardfont);
endyearcombobox.addActionListener( new ActionListener() {
public void actionPerformed( ActionEvent event ) {
endyearcombobox = ( JComboBox )event.getSource();
endyear = endyearcombobox.getSelectedItem();
boolean same = endyear.equals(oldItem);
oldItem = endyear;
String[] endyearlist = new String[numyears];
for(int i = startyears; i < startyears+numyears; i++){
String item = new Integer(i).toString();
endyearcombobox.addItem(item);
Thanks
Ged

Thanks mate,
That was what I was looking for. I still had a little more manipulation to do, but sent me on the right track and have got it working now. I don't know why I didn't think of it in the first place.
Ged

Similar Messages

  • Cannot set default programs for a file extension in Gnome

    After a gnome upgrade (cannot remember when), I can no longer set the default program for a particular file extension by right clicking the file in nautilus -> going to "properties" -> going to "open with" tab -> highlighting a program -> pressing "set as default".

    The program I was trying to set was totem for default video playback; wine had made windows media player the default player prior. Interestingly, once I installed gnome-mplayer; the default program changed to gnome-mplayer and I was then able to switch default programs. This error may be related to wine.
    Last edited by Bluerider (2013-07-05 23:07:59)

  • F4 help for select options based on parameter value

    hi all,
    I need a help to create an F4 help for select options for object id based on parameter value of object type, I mean once an object type is given the f4 help should contain object id's only of that type for each option.
    Regard's,
    Girija
    Moderator Message : Duplicate post locked. Continue with [f4 help for select options based on parameter value |f4 help for select options based on parameter value;.
    Edited by: Vinod Kumar on May 17, 2011 1:36 PM

    hi all,
    I need a help to create an F4 help for select options for object id based on parameter value of object type, I mean once an object type is given the f4 help should contain object id's only of that type for each option.
    Regard's,
    Girija
    Moderator Message : Duplicate post locked. Continue with [f4 help for select options based on parameter value |f4 help for select options based on parameter value;.
    Edited by: Vinod Kumar on May 17, 2011 1:36 PM

  • How do you set default programs for all users when deploying Windows 8.1?

    I have my Windows 8.1 image set up the way I want including the start screen, theme, etc. But how can I set the default programs for all users. Most of out computers are non-touch and I want the desktop apps (e.g. Windows Photo Viewer), not the store apps
    to be the default for opening pictures, videos, etc. Can that be done?

    Great question, this has been bugging me too!
    So, I did some research by using "Set Default Programs" app in Windows 8. Then I ran the super ProcMon.exe tool from Sysinternals.com <Thanks Mark!>
    After filtering out the junk, I could see some *interesting* writes to the registry:
    [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.jpg\UserChoice]
    "Hash"="57y87/ogggU="
    "ProgId"="PhotoViewer.FileAssoc.Jpeg"
    But the "Hash" part had me concerned. I did some internet searching for the hash, and came across a post and a pointer to a blog with some answers.  This is both good news and bad.
    Background:
    One of the problems with Windows XP is that any program can come in and party on the entire system. No, I don't want you to put a shortcut on the desktop, install a crappy IE Toolbar, and change the default file association for *.jpg files to your app, I
    just wanted to play a stupid game. Since Windows 7, Microsoft has been attempting to block that functionality from the stupid applications, and give them back to the user. Take note of the last line in the ITaskbarList3 interface:
       Applications cannot programmatically pin themselves to the taskbar. That functionality is reserved strictly for the user.
    Of course that sucks for us IT Pros who may wish to create *default* working environments for corporate images, but there are some tricks we can do.
    Solution:
    This blog appears to have the answer:
    http://blogs.technet.com/b/mrmlcgn/archive/2013/02/26/windows-8-associate-a-file-type-or-protocol-with-a-specific-app-using-a-gpo-e-g-default-mail-client-for-mailto-protocol.aspx
    New for Windows 8 is a dism command: /Get-DefaultAppAssociations that allows you to export a control case from a known good computer. Microsoft the supports importing the exported xml file via GPO. For example, before I changed the file association, .AVI
    was pointing to the Modern App, after the change the /export-DefaultAppAssociations shows change to the new app:
    From:
    <Association Identifier=".avi" ProgId="AppXhjhjmgrfm2d7rd026az898dy2p1pcsyt" ApplicationName="Video" />
    To:
    <Association Identifier=".avi" ProgId="VLC.avi" ApplicationName="VLC media player" />
    I am still doing some investigation to see if a GPO is required, or if you can inject the association into a local user account. Also, if you do have some Modern Windows 8 Touch Tablets, it would recomend keeping most of the Modern App defaults in place,
    perhaps seperate GPO's for Desktops/Laptops vs Tablets?
    -k
    Keith Garner - keithga.wordpress.com

  • Setting Default Preferences for All Users in Crystal Reports Server 2008 v1

    We are currently looking to set the default preferences in the CMC for all of our users.
    I did locate this page Link: [How to set default preferences for all users in Infoview 3.1/CRS 2008]
    The first part of the thread did seem promising but I am unable to find the sample .jsp code that people recommended.
    I would assume that this scenario is common enough that someone knows a way to set universal preference defaults.
    Thank you

    I thought I could just run it too but when I attempt to I get a Windows Script Host error:
    Script: C:\User Prefs.vbs
    Line: 1
    Char: 1
    Error: Expected statement
    Code: 800A0400
    Source: Microsoft VBScript compilation error.
    I noticed the first most line seems to be markup for a web interface though I am not familiar with vbs so I may be wrong.  I used the publishing wizard to put the script on the CMC to attempt to run it through the CMC but it still does not work.

  • How to set default language for Portal?

    Hi All,
    We use EP6.
    Default language is not defined and therefore is being set by the browser's language.
    Where do I set default language for all users?
    (I don't want that the users will be able to change it by themselves by browser/EU role).
    I tried to set the "request.mandatorylanguage" and
    "request.mandatorycountry" in prtDefault.properties but it didn't help.
    Thanks,
    Omri

    Hi Omri,
    are those to parameters
    request.defaultlanguage=...
    request.defaultcountry=...
    set in the prtDefault.properties, and the J2EE Server restarted after the change?
    Check out this thread and the link given there for more info: HOW to define the default language in the portal
    Hope this helps,
    Robert

  • How can I set a password for firefox so that everyone have to enter the password before executing firefox

    My younger sister executed my firefox just at this afternoon(she originally use IE), and she saw something that can't be seen. How can I set a password for firefox so that everyone have to enter the password before executing firefox?

    Also see this for an English version of Profile Password:
    *Profile Password: http://nic-nac-project.de/~kaosmos/profilepassword-en.html#PPF
    It is an extension to protect the profile with a password, but being an extension that protection can easily be bypassed by starting Firefox in [[Safe mode]].<br />
    So do not rely on it.<br />
    If you want to protect content then you have to use methods supported by the OS like a separate user account with a password or an encrypted file system.

  • How to set raw format for canon powershot a1100 is ? ,,according to the specs online it can.

    how to set raw format  for canon powershot  a1100 is ? ,,according to the specs online it can.

    It requires the Canon Hacker's Developement Kit (CHDK). It runs off of your SD card and does not harm your camera. Download a program called Stick-
    http://zenoshrdlu.com/stick/stick.html
    Follow the directions and you will be able to shoot in RAW along with some other deatures not available on your camera previously.

  • HT201304 I purchased an in-app set of tokens for Buster Bash Pro and it does not show up in the game. It has been 24 hours. What do I do now?

    I purcahsed an in-app set of tokens for Buster Bash Pro and it does not appear in my game. What do I do now?

    You could try contacting the store support staff at http://www.apple.com/emea/support/itunes/contact.html they are very good at resolving problems.

  • Why when i set up folders for my photos do they also appear in the photo library can I only have them appear in the folders???

    Why when i set up folders for my photos do they also appear in the photo library can I only have them appear in the folders and not duplicated in the photo library???

    Not sure about the missing photos from the Photo Stream section of 'Recent', however to stop photos populating the events, turn off Automatic Import (iPhoto Preferences > Photo Stream)

  • Error Message: The syntax of the value for prompt 'p_phone_num' is incorrect. Please correct the syntax and try again.

    Post Author: helpwithcr
    CA Forum: General
    " The syntax of the value for prompt 'p_phone_number' is incorrect. Please correct the syntax and try again."
    I am getthing this error while I tried to pass the value from an oracle package to the web when the the crystal report viewer kicks in.
    I found the source of the error. Its just a paranthesis that I used with the phone number inside the function.... The function looks like this
    function phone_number
    return varchar2
    is
    begin
    return '(123) 456 - 789';
    end phone_number;
    I really dont want that paranthesis to go. Its the format that everyone wanted. But they dont want that to be static on the report also
    Please help
    Thanks
    helpWithCr

    Sir, you are a legend!!! 
    Many thanks for putting me on the right track... 
    Here's where I went wrong and how I fixed it.
    First I installed the Azure Pack: MySQL Extension on the MySQL server.
    This was wrong, it needs to be installed on the WAP server/s.
    So I installed the extension on the WAP server and it still didn't work.
    So I uninstalled the extension from the MySQL server and it still didn't work.
    So I also installed the MySQL Connector/Net on the WAP server and it worked.
    This eventually fixed it. 
    What I will say is that in the documentation it doesn't mention installing the MySQL Connector/Net from the web platform installer on the WAP server (unless I have completely missed this)?
    Thanks again :-)
    Microsoft Partner

  • When printing from aperture my margins are unequal, even if i set my margins they come out bigger one side  and not the other. i am using a macbook pro running osx lion and printing with a canon pro 9000

    when printing from aperture my margins are unequal, even if i set my margins they come out bigger one side  and not the other. i am using a macbook pro running osx lion and printing with a canon pro 9000.
    please can anbody help or advise?

    You didn't mention any color calibration being done on your monitor.  This is an essential part of any color-correct workflow.  What are you using to calibrate your monitor (and your printer)?
    Print profiles (for soft-proofing as well as printing) are for specific combinations of paper & printer.  The nine you have are each, most likely, for a common paper (perhaps mfr'd by Canon) to be used with your printer.
    I don't know what you mean when you say "I choose a high standard print option".
    Have you read the User Manual chapter on printing?
    Printing Your Images
    There is also a good appendix on calibration:
    Calibrating Your Aperture System

  • In firefox, whenever i have my mouse over the page (not the toolbar section), any selection i have moves. For example - a text entry box and the cursor keeps returning to the start of the box. This is only in firefox, everything else works fine (IE and Ch

    I have an issue with FF. Whenever I have my mouse on the page (not the toolbar area) any selection I make gets altered in the following way:-
    Text boxes - The cursor keeps moving to the left.
    "Radio" buttons - Selection keeps moving up.
    This is only happening in FF, I am not seeing this behaviour in Chrome or IE.
    == This happened ==
    Every time Firefox opened

    Start Firefox in [[Safe Mode]] to check if one of your add-ons is causing your problem (switch to the DEFAULT theme: Tools > Add-ons > Themes).
    See [[Troubleshooting extensions and themes]] and [[Troubleshooting plugins]]
    If it does work in Safe-mode then disable all your extensions and then try to find which is causing it by enabling one at a time until the problem reappears.
    You can use "Disable all add-ons" on the [[Safe mode]] start window to disable all extensions.
    You have to close and restart Firefox after each change via "File > Exit" (Mac: "Firefox > Quit"; Linux: "File > Quit")

  • How can I stop auto update for the OS (not the apps)?

    Is there a way to stop the phone (mine is samsung note 3) from updating the OS (not the apps)? It works fine with the current version, and I have had/heard about issues with OS upgrades basically messing up the phone.

        srinik1, we want you to have the best wireless experience on your device. There's no way to restrict your device from receiving this update. You will continue to receive alerts to advise you to update the software on your device until you complete it. Should you have any issues with your device after updating, please feel free to reach out to us for assistance. We're here to help.
    LasinaH_VZW
    Follow us on Twitter @VZWSupport

  • Set default value for full name based on usename

    I have an LOV which as the full name of the user, for example 'John Smith'.
    I would like to set the value of this LOV to the full name of the user, based on a match with username. So when JSMITH is logged in, I would like the default value of the LOV to be 'John Smith'.
    I have an page process anonymous block which gets the right short username:
    DECLARE
    p7_assigned_to varchar2(20);
    BEGIN
    select person_name into p7_assigned_to
    from ht_people
    where v('APP_USER')=flow_user;
    END;
    How do I then set the default value of the LOV based on the return value of this block?

    Where do you use the LOV? Is it being used in a Select list? If so, you will have a place to enter the default value. Edit the Select list, and you will see a place where you can enter Default value.
    Ravi

Maybe you are looking for

  • Export data on pdf-form to Excel

    I would need help for exporting data from pdf-form to Execl spreadsheet the basic idea is that a pdf-form would be the user interface to collect the data with text boxes / drop-downs (such as "Vendor", "Purchase order number", "Date", "Text" etc.) an

  • Seeing a lot more app crashes since upgrading t4.2.1?

    I have been seeing a lot more apps just quit without explanation since the upgrade. Interestingly enough, most of them are apps that I acquired after upgrading iOS and they are supposedly tested and compatible with 4.2.1. Anyone else having this prob

  • Split file in various messages

    I have an interface that reads a file and send to the BW. But the file is very large. As talked with SAP, they sent me split the file in various messages. Does anyone know how I can do this? Thank you.

  • ITunes More Expensive Than Retail

    I was about to purchase a new album, Brown Street by Joe Zawinul, at the iTunes store when I realized that the price was a dollar more than the retail CD. The iTunes version isn't the "plus," no copy protection version. Why would they price it above

  • Adding users without OID

    I have an oinstance of Oracle files in which I do not want to use SSO and OID. I want to add users directly to iFiles and direct the users to the iFiles login screen. I have not found a way to add users to iFiles without using OID. Does anyone have a