Make an if statement generic

Hi,
I have to use if statement three times for three different jComboBoxes. I was wondering if there was a way I could achieve this so I do I have to repeat my if statement 3 times.
Could I use a loop?? or since the if statement is small how could I write a generic if statement that would work with any combobox??
Here is my awesome code!! haha
int id;
if (jComboBoxDirectory.getSelectedIndex() == 0)
id= 1;
else if (jComboBoxDirectory.getSelectedIndex() == 1)
id = 2;
else if (jComboBoxDirectory.getSelectedIndex() == 2)
id = 3;
else
id = 4;
Thanks in advance!

int getID(JComboBox jcb) {
return jcb.getSelectedIndex() + 1;I've created this method but how would I call it?? When I tried doing jComboBoxDirectory.getID I get an error that says It cannot find method getID??
Am i suppose to create a new object first?
Or I can just try one of these alternatives....
Message was edited by:
mattv6603

Similar Messages

  • Need to make collection Query statement by sccm 2012 sp1 for Count of Licenses by License Status

    I want to make collection Query statement by sccm 2012 sp1 for all windows activated and all non-activated windows.
    Ahmed Sherif

    Have a look at the Software Licensing Product attribute classes when creating a Query - remember to choose
    System Ressource when creating the Query. You would have to enable this class to be collected during Hardware Inventory. Go to
    Client Settings -> Hardware Inventory ->
    Set Classes -> Select Software Licensing Product.
    This Class is part of the Asset Intelligence classes so you could enable it from there as well.
    Another way to accomplish is to use Compliance Settings to get this information.
    Create a Configuration item that query the Win32_WindowsProductActivation WMI Class, if you are using XP and the
    SoftwareLicensingProduct class for later os´s
    Add this Configuration Item to a Baseline ad deploy it to your Collections as needed.
    When the Baseline has been evaluated you can use this information to create query
    Machines reported as compliant is actived and machines reported as Non-Compliant is not activated.
    You can read about the Win32_WindowsProductActivation WMI Class here:
    http://msdn.microsoft.com/en-us/library/aa394520(v=vs.85).aspx
    and the SoftwareLicensingProduct here:
    http://msdn.microsoft.com/en-us/library/cc534596(v=vs.85).aspx

  • Adobe, please make a formal statement about "free" CS2

    Folks, we have heard the whole gambit of ideas and discussions concerning Adobe's "giveaway" of CS2.
    To my knowledge, there has only ever been ONE SINGLE post about CS2 NOT being released for free - and that post was in a FORUM. InDesign Secrets picked up on that one post and repeated what was said there.  On Adobe's CS2 download page, there is NOTHING said one way or the other.  Forum statements are always on a personal level - they are NOT a professional solution for official announcements, and should not be regarded as such.
    Adobe, could you please be so kind as to issue a formal statement? 
    There are many people out there who would use CS2 if it were released for free - folks who will never purchase the newer versions - folks who normally use only freeware.  It would be a great benefit to those folks, and it would increase your popularity, and you might even make sales with those people once they get used to your products. 
    I, myself have a license for CS3 Premium, CS4 Standard, InDesign CS2, but I would recommend CS2 to other folks to use instead of GIMP or other freeware.  In fact, when the word went out, I was surprised and pleased and wrote to my friends.  Then I had second thoughts and had to tell them "never mind - I was misled".  Now, after reading the posts in this here forum, I am somewhat bewildered and confused.
    Please make a formal statement about this!

    I do not agree with your examples they can’t be used in this case.
    The shop and speed examples just don’t make sense. The digital nature of this whole situation alone makes comparisons like shops or driving-speed-limits impossible. When you enter a shop and take something the object is moved, in this case there is nothing moved! (that’s just one point, there many others but that would make this post too long).
    Also realise that the knife cuts both ways.
    Ignorance of law applies to both user and provider.
    If the user did wat he/she could to make sure that it seemed legit than they have done their part.
    If adobe did to make sure then the user/visitor of the site can not simply grab the stuff, than the visitor places him/herself in in “illegal situation”.
    If adobe gave the public the false presumption that content could be downloaded for free (NOT moved / stolen) then Adobe is also at fault and put themselves in a position where they can’t just make a statement that illegal activity has taken place on the user’s part.
    To my knowledge A EULA is NOT intended when you have a license.
    Even though literlally means “End User License Agreement” ,  it initially can’t be tied with a purchase. That will become clear AFTER you read the EULA. If you want the requirement that an initial purchase is mandatory than you must inform the user before he/she opens the EULA. Adobe has not properly informed the public on the downloadpage.
    (You can not use the forum for that)
    And what about freeware tools? And promotion based sites which from time to time give away software. They all have EULA’s a EULA is also to inform the user of the circumstances he/she can use the software.
    If it is not clear on the website (downloadpage) than how is the user supposed to know if he/she can download and install?
    - First off, the site which promoted this are respected sites. And still there are sites wich have not done any retration
    (and see the points below about notification and retraction).
    - Then you have the downloadpage which has no form of restriction/ID authentication and the serials are right there.
    - I installed and read the EULA and at that point it seemed al legit.
    And you still have the other points which you still can’t place under “ignorance of law” when the user has done it’s part by checking the below
    There was and still is no notification on the adobe download site
    Serials are displayed on the adobe download site
    The EULA literally states "obtained" not "purchased"
    Everything can be registered and will show up in your "My Adobe" profile
    No adobe ID is needed to reach the adobe downloadpage
    Adobe admitted that the whole thing could be seen as an giveaway
    Adobe only used the forum to communicate that it was not intended as an giveaway, but as an way for owners with genuine CS2 license to reinstall because of the de-activation of authentication servers. BUT they never stated that downloading and using this version without a previous CS2 license is illegal.
    · IF it is illegal to download and install then adobe would state that literally asap (right at the moment they explained in the forum that this is not for non CS2-license holders). Now there is only silence and adobe forum moderators are not responding to issue directly (an sort of "edict" from the adobe management not to discuss until further notice?)
    · Days after this fiasco adobe hasn't taken any precautions to avoid further downloading/misunderstanding. (they still left the page as is, they even removed the requirement of an adobe ID to reach the page)
    You cannot use the shop or speed example in this case, pro or against adobe.
    The software world is totally different.
    There are enough examples where older versions are given away as form promotions, and there even promotions which began “silent’ and then went viral.
    And realise that the UK law doesn’t apply for the rest of the world, Adobe realises this and therefore hasn’t made an official statement yet. Not just a forum statement which led to some retractions within certain sites.
    The assumption of “Consent of the copyright owner” was given on the moment when the downloadpage went up AND no form of notification was given.
    Adobe still hasn’t informed me properly through email that download and install of the CS2 is only valid for users who have a previous genuine license.
    ”...Where copyright exists, the owner is not required to tell people - it's an automatic right....”
    I do not believe this, you must always supply enough/proper information or else how is the public to know?
    And I still have these questions
    Where is stated on the downloadpage that it is intended for CS2 license holders?
    http://www.adobe.com/downloads/cs2_downloads/index.html
    · Why is that page accessible for everyone without an adobe ID?
    Why Can the content be directly downloaded without even going to the downloadpage without any form of ID authentication.
    Why is the EULA not customised for this?
    Why is there still no notification on the download page?
    Why am I able to register it and it shows up in my "My Adobe"?
    Why have the users who have registered this with their full and valid address and email information not received any mail about this
    Why is the forum the only communication channel to about this? When and Where will be the official statement? Will this be outside the forum. If not, why not use the website homepage and email adresses of the registered users?
    Why are there still no takedowns issued on the sites which still promote this as free?
    Knowing that there was no form of proper notification (and still none), how are the people who downloaded, installed and registered this to know that this was not some form of promotion?

  • Can't make simple 'IF' statement work in MS Query!?

    I have read the existing threads on the subject but can't seem to make a simple 'IF' statement work in MS Query with a single table. I always get the following error:
    Returns error message:
    "Incorrect syntax near the keyword 'if'
    Incorrect syntax near ','.
    Statement(s) could not be prepared.
    Here's my query (simplified, but not much):
    select *
    from table t
    where t.modifieddate > if(t.active=0, date1, date2)
    Just to see if I could get AN if statement to work, I've also tried:
    SELECT t.active, if(t.active=0,2,3)
    FROM CdmsTimeSheet.dbo.Registrations t
    And
    SELECT t.active, if(t.active='0','2','3')
    FROM CdmsTimeSheet.dbo.Registrations t
    And
    SELECT t.active,
    FROM CdmsTimeSheet.dbo.Registrations t
    where datemodified>if(t.active='0',3/1/2014,1/1/2014)
    and
    SELECT t.active,
    FROM CdmsTimeSheet.dbo.Registrations t
    where datemodified>if(t.active='0',#3/1/2014#,#1/1/2014#)
    I've been using excel/ms query for many years but not in the last year or two and am wondering if this was somehow removed? I tried using decode but then get a "not built-in function" error.
    Please help! Thanks

    Not sure what kind of database you are using. In SQL Server, you should use 'Case when' Statement Or 'IIF' function instead of if.
    e.g.
    select
    top (10) BusinessEntityID,iif( BusinessEntityID=1 , 'true' , 'false') as test
    from HumanResources.Employee
    order by BusinessEntityID
    Wind Zhang
    TechNet Community Support

  • How do you make the down state last a few seconds?

    I have an assignment due next week where you click something and a little text box pops up telling you what that item is. I also made it so the item changes colour.
    However, right now I've just got it so that you hover your cursor over it, it fades a bit, then you click it and it changes colour and the textbox shows up. The textbox and colour doesn't stay for a few seconds; you need to hold your mouse over it to make it stay.
    So, in short, I want it so the down state stays for a few seconds and then goes back to normal.
    I downloaded and installed the Flash CS6 trial to complete this, and I'm not sure if it's limited.
    At College they only have CS5.5, so I can't use any tools that go beyond CS5.5.
    I 'have' Flash CS5.5 but that was on my old computer (Which broke) and I'm waiting for my new one to come.

    How I would do it...
    1) make 2 seperate MC, one is the buttonMC (convert it to button symbol and just leave the hit spot)  and another is the buttongraphic (a movieclip) itself
    2) animate the buttongraphic (the MC), lets say frame one is its original state, frame two is how the hit/click would look like and frame ten is how it would look like when hover. that give you 10 frames for animation for each action
    3) name the button instance "button" and the graphic "gaphic"
    4) on the button, give it this code:
    on(press) {tellTarget("graphic") {gotoAndPlay(2);}}
    on(rollOver) {tellTarget("graphic") {gotoAndPlay(10);}}
    Hopefully this will help you out.

  • How to make front panel as Generic

    Hi all ,
    I need to know that how to do front panel reuse.
    Here i am using two front panel to do some work .
    But both the front panel do the same work ,
    I need to use create one front panel make them as generic .
    I C#  can able to do front panel generic .
    In labview how to do it .
    It helps me lot ..
    Thanks in advance .,
    Attachments:
    fp.vi ‏11 KB

    You can group the controls as a Cluster and make a type-def of it. That's probably what you're after.
    /Y
    LabVIEW 8.2 - 2014
    "Only dead fish swim downstream" - "My life for Kudos!" - "Dumb people repeat old mistakes - smart ones create new ones."
    G# - Free award winning reference based OOP for LV

  • Does anyone know how to make my following statement dynamic?

    hello experts,
    In my statement I am getting data for 3 months, however this is static It doesn't give business users the ability to pick the dates they want for the 3 months. So, I want to make it where if one picks a date, lets say Feb 12 to May 12, he will get the 3 months data or if he/she want datfor Feb 15 to May 15th then they can see that.. Below is my static statement, how do I tweak it to be dynamic
    FILTER("Fact - Project Cost"."Cost" USING ("GL Calendar"."Fiscal Date" >=timestampadd(SQL_TSI_MONTH, -3, current_date) and "GL Calendar"."Fiscal Date"<=current_date))
    many thanks as always
    Edited by: 994621 on May 15, 2013 2:07 PM

    Use this and also set "GL Calendar"."Fiscal Date" as Is Prompted
    FILTER("Fact - Project Cost"."Cost" USING ("GL Calendar"."Fiscal Date" <=timestampadd(SQL_TSI_MONTH, 3, "GL Calendar"."Fiscal Date") and "GL Calendar"."Fiscal Date">="GL Calendar"."Fiscal Date"))

  • The computer is not seeing the usb connection to my canon Pixma IP 90 the USB port states Generic US

    my computer shows generic usb hub and does not recognize my canon Pixma IP 90 printer when pluged into the usb port how to configure the usb port

    you're in HP forum ....hehehe
    not Canon...
    Although I am working on behalf of HP, I am speaking for myself and not for HP.
    Love Kudos! If you feel my post has helped you please click the White Kudos! Star just below my name : )
    If you feel my answer has fixed your problem please click 'Mark As Solution' and make it easier for others to find help quickly : )
    Happy Troubleshooting : )

  • How can I make an "active state" in a menu (made as pin object)?

    I just made what this video shows
    http://tv.adobe.com/watch/muse-feature-tour/muse-pin-objects-to-the-browser-window/
    BUT I would like to change the title color when the page scroll to the anchor (see screenshot)
    I tried with the "state panel" and i doesn't work
    Thanks a lot
    Sebastián

    Not possible yet.

  • Finding a bumper (stinger?) that makes the right statement

    I am taking a break from listening to hundreds of 5 to 7 second long audio clips trying to find just the right beginning to go with my employer's logo for a telecommunications technical training series. I have the graphic design from the company web site, and I have separated the text and the logo on to different layers of a Photoshop file. I will probably keep it simple, but I can always take it into After Effects if I can't get what I want in Premiere Pro.
    Finding the right audio is turning out to be a lot harder than I thought it would be. Before I started the search, I thought I had a general idea of what I was looking for. Something a bit cinematic, like a dramatic start to a trailer. But having listened to so many already, I can barely remember what I had in mind to begin with. I don't think I am going to use a music bed under the voiceover. No real point to that.
    I would like something complementary to go at the end of each training video, so that makes it even harder. They really have to complement each other. Which eliminates some of the ones I rather liked.
    By the time I am done, I will have spent more time on the first five seconds and the last five seconds, than on the entire middle part of the first few videos combined.
    Oh well. Back to my search.

    Sounds like time for a break to refresh yourself.  Do you have another project to work on for a short while?
    Yes. I started working on the text and images for the first lesson. And the script. And for now, I have a bit of audio I can use if nothing better comes along.
    The first lesson is about an acronym that people in my business use every day, but I recently discovered that not everyone has a clue as to what it actually means or what it looks like. The acronym is MPOE which stands for Minimum Point Of Entry. It is where the telephone company drops the circuit in the building for the customer to use. I used Premiere Pro for the Intro but I am using After Effects to provide the text for my voiceover. Nothing fancy, but you know how After Effects is. You start out simple and then there is always something a little better, and a little better, and you finally have to stop.
    I have to keep fighting with myself. I don't want to spend a lot of time getting fancy. I did take the time to call up a color wheel so that the color of the text complements the color of the logo. Nether of which are particularly attractive colors.
    This is my first pass at a simple intro. The purple text is actually a title in the lesson specific project not a part of the basic intro. Like I said, nothing fancy, but this stuff is going to be played on a laptop or office desktop. Not on a HDTV.
    I took a different track and went with a sound effect instead of music. I don't know if I will keep it, but I might. I just want something recognizable that people will associate with my tutorials.
    The goal is to put together a bunch of tutorials and release them once or twice per week along with a BLOG post. So I will probably get at least two done before I release the first one. That way I can put a teaser in the first one about what I am going to talk about in the second one. A new BLOG requires a way to get people to return. And as boring as the topic might seem to you, if you heard the acronym every day, you would probably be inclined to watch the lesson. You know?
    I kind of like the little pop as the topic shows up on the screen. As I said, just something to make it easily identifiable as one of mine.

  • How to make this select statement faster?

    this statement is really taking long time to process.
    in bseg table as vbeln is not primary key or seconday key, i guess thz the reason it is taking so much time ,,,
    can anyone help me to sort this out... ??
    any fun mod to get the data of bseg cluster table by giving vbeln?/
    or any other conditions to reduce the processing time?
    clear t_vbrkvbrp.
    sort t_vbrkvbrp by vbeln.
    loop at t_vbrkvbrp.
    at new vbeln.
    select bukrs belnr vbeln
           from bseg
           into corresponding fields of table t_temp
           where bukrs = t_vbrkvbrp-bukrs
            and vbeln = t_vbrkvbrp-vbeln.
    endat.
    endloop.
    SELECT bukrs belnr buzid koart shkzg dmbtr vbeln hkont kunnr werks
           FROM bseg
           INTO TABLE t_bseg
           for all entries in t_temp
           WHERE hkont IN s_hkont
           AND bukrs = t_temp-bukrs
           AND belnr = t_temp-belnr
           AND buzid = ' '
           AND koart = 'S'
           AND shkzg = 'H'.
    i need to get the g/l account number for the above condition type so i have to use bseg table
    Message was edited by:
            shahid mohammed syed

    Shahid,
    Usually BSEG SELECTs are slow as it is a Clu8ster table. More over you are not passing the PKeys in the WHERE condition. That's alcso one reason for slow retrieval. You can also use the table BSIS (Accounting: Secondary Index for G/L Accounts) for the G/L accounts. But first of all, I suggest you cnange your where condition as below:
    SELECT bukrs belnr buzid koart shkzg dmbtr vbeln hkont kunnr werks
    FROM bseg
    INTO TABLE t_bseg
    for all entries in t_temp
    WHERE  bukrs = t_temp-bukrs
    AND belnr = t_temp-belnr
    AND buzid = ' '
    AND koart = 'S'
    AND shkzg = 'H'
    <b>AND hkont IN s_hkont.</b>
    Not much diff. I just re-ordered the condition based on the order of BSEG fields... Lemme know if it helps.
    Regards,
    Karthik
    Message was edited by:
            Karthik

  • Make DropdownBox initial state to show blank

    Hi!
    I need to set the initial value selected of sap.ui.commons.DropdownBox to be blank before user interaction, but without adding any empty items.
    Is this possible? If yes then how?
    Kind regards for your help
    Janis

    Hi Janis,
    There are two options:
    1) play with DOM elements of your list/select
    2) make a fake dropdown, kind of button which will call a popover with List inside, see code example here: http://jsbin.com/jujog/1/edit?html,js,output
    Please note, that FIORI applications are using 2nd approach.
    Regards,
    Vladimirs

  • Trying to make an sql statement returning 'owner, tablename, num_rows, measuredate'

    Hi, I would like to create a table with the following collumns:
    "OWNER|TABLENAME|NUM_ROWS|MEASURE_DATE"
    I can get owner, tablename and measure_date (sysdate) from
    dba_tables easily with a
    select owner, tablename, sysdate
    from dba_tables
    , but I am having trouble getting the num_rows for each table
    seperately.
    dba_tables.num_row is not an option because I am not running
    statistics on this server and can't (rather: I am told not to.
    So somehow I have to add the result of
    select count(*) from " an individual table", dynamically.
    But I am not sure how.
    Eventually the table would have to look like:
    JOHN EMP 433 12-JAN-01
    JOHN EMP 476 12-JAN-01
    MARGE LOC 198 13-JAN-01
    All help is very much appreciated,
    Mike

    HI guy's !
    Thanx for all the suggestions, I have tried them all out and its
    almost there. However your suggestions display the output on the
    screen and I would like to insert the rows into table so to be
    able to readout table growth history. I tried to alter your
    statements with a create table as select ( and here your plsql)
    but this doesnt seem to work. I am sorry that I do not know
    pl/sql. Can anyone assist me in completing the code with an
    insert into a table?
    Mohit Dubey: I am getting an ORA-00952 table or view does not
    exist with your code, do I need to edit smth I overlooked?
    Suresh: Your code works, but as mentioned above I would like to
    get the code into table instead of on the screen, could you help
    me with that? I apologize for not knowing plsql.
    Barbara: Your code works fine, but it does an update on the
    table. Therefore, I cannot query the history of the number of
    rows tables. Could you change it to do an insert instead of an
    update? I tried to but failed miserably.
    Again; thanx all for your suggestions! Now I just need a final
    push as I myself am unable to alter the codes into an insert
    statement.
    Mike

  • Make an update statement from a proc

    That is, how is possible to call an update statement from
    within a procedure?
    I have tried
    execute update TT_Livraison set ...
    without success.
    Any idea?

    In a procedure, you just include the SQL statement
    CREATE OR REPLACE PROCEDURE foo ...
    AS
    BEGIN
      UPDATE <<some table>>
         SET ...
    END;Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

  • Help! How do i make a button state maintain when there are other buttons on the page?

    I need to have the down state of pressed buttons stay in that state when there are multiple buttons being pressed on the same html page...

    Hello and welcome to the forum,
    Not sure if I understand well, but think you are bumping into the Quiz scope... I have been trying to explain this in a blog post, with other functionalities of Question and Score slide:
    Question Question Slides
    Lilybiri

Maybe you are looking for