Display Values in JcomboBox

Hi,
I am new to java.Can anyone Plz help me.I have a JcomboBox. I want to display all the ItemId from the database in that JComboBox. It is printing all the itemid to the Consol .but Only the last record is displaying in the JcomboBox. Can anyone plz tell me what to do.
The code is:-
public String selectItemID(){
          String itemNo = null;
          try {
               statement = dbConnection.prepareStatement("select ItemId from ItemDetails");
               ResultSet itemNumberResult = statement.executeQuery();
     while(itemNumberResult.next())
                    itemNo = itemNumberResult.getString(1);
                    System.out.println("itemNo " +itemNo);
                    //return itemNo ;
          } catch (SQLException e) {
               // TODO Auto-generated catch block
               e.printStackTrace();
          return itemNo;
itemno=new JComboBox();
DbActivity dbconnection = new DbActivity();
     String result= dbconnection.selectItemID();
     itemno.addItem(result);
     System.out.println("Result "+result);

public String selectItemID(){
returns only the last itemNo found and that is added to the Combobox. My suggestion would be to do this:public Vector selectItemID(){
Vector result = new Vector();
try {
statement = dbConnection.prepareStatement("select ItemId from ItemDetails");
ResultSet itemNumberResult = statement.executeQuery();
while(itemNumberResult.next())
String itemNo = itemNumberResult.getString(1);
System.out.println("itemNo " +itemNo);
result.add(itemNo); // add all found itemNos
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return result;
DbActivity dbconnection = new DbActivity();
Vector result= dbconnection.selectItemID();
itemno=new JComboBox(result); // construct Combo with Vector
//System.out.println("Result "+result);

Similar Messages

  • TableSorter + custom cell renderer: how to get DISPLAYED value?

    Hi!
    I have a JTable with a custom cell renderer. This renderer translates numerical codes, which are stored in the table model, into textual names. E.g. the table model stores country codes, the renderer displays the name of the country.
    Now, having a reference on the JTable, how can I get the DISPLAYED value, i.e. the country name? Is there some method like ....getRenderer().getText()?
    Thanx,
    Thilo

    Well, a renderer can be anything. It may be rendering an image not text so you can't assume a method like getText(). However, since you know the component being used to render the cell you should be able to do something like:
    TableCellRenderer renderer = table.getCellRenderer(row, column);
    Component component = table.prepareRenderer(renderer, row, column);
    Now you can cast the component and use get text.
    Another option would be to store a custom class on the table cell. This class would contain both the code and value. The toString() method would return the value. Whenever you want the code you would use the table.getValueAt(...) method and then use the classes getCode() method. Using this approach you would not need a custom renderer. This thread shows how you can use this approach using a JComboBox, but the concept is the same for JTable as well:
    http://forum.java.sun.com/thread.jsp?forum=31&thread=417832

  • Is it possible to easily view the actual (not displayed) value of a cell?

    Is it possible to easily view the actual value of a cell calculated by a formula, not the displayed value after it has been rounded off?
    For instance, if you enter the number 1.23456789 and display it rounded to 3 decimal places, you can still see the full, actual value in the formula bar:
    The problem arises when you reference that number in a formula: you can't see the underlying value (even though it's obviously known to Numbers):
    Is there a way to get the formula bar (or a tooltip) to show the full, unrounded value? Changing the display to more decimal places is not very convenient, especially on big spreadsheets. Maybe it could be done via AppleScript?
    A related issue arises when you try to look at the sum or average of a number: if the numbers being summed have the same number of rounded decimals, the sum displayed is rounded too. I find this very annoying: I want to see the actual value, not how my spreadsheet may be displaying it in that cell.
    Although, curiously, rounding to any number of decimals as long as they are not all the same displays the full, correct underlying values:
    Has anyone come up with workarounds for these issues?

    I did it with an AppleScript.
    Now any time I have a cell or cell range selected, I do one click (AppleScript menu > Display Value at Full Precision), and it shows me a popup alert that simply reads:
         rowname : columnname
         value
    Here's the script:
    tell application "Numbers"
              try
                        set selectedTables to (tables of sheets of front document whose selection range is not missing value)
                        repeat with selectedTable in selectedTables -- tables of each sheet
                                  if contents of selectedTable is not {} then -- the list is not empty, it's the selected sheet
                                            set selectedCells to cells of selection range of (get item 1 of selectedTable)
                                            repeat with i in selectedCells -- each selected cell
                                                      set {selectedRow, selectedColumn, selectedVal} to {row, column, value} of i
      --                                                  display alert "value of " & name of selectedRow & " : " & name of selectedColumn & " (" & address of selectedRow & ":" & address of selectedColumn & ")" message selectedVal
      display alert name of selectedRow & " : " & name of selectedColumn message selectedVal
                                            end repeat
                                            return
                                  end if
                        end repeat
              on error eMsg number eNum
      display alert eMsg
              end try
    end tell
    ( Props to Jacques Rioux who posted code to get me started at https://discussions.apple.com/thread/3964938 )

  • Change display value of "select list"

    Hi!
    I have a problem with a select list, I want to change the display value through an own pop up (page 5 of apex application) after I submit in it.
    The select list is based on a sql query:
    select A_NAME display_value, A_ID return_value
    from APPLICATIONS
    where a_application_type='GROUP'
    order by 1
    beside I have an link to open a pop up window:
    ... onClick="window.open ('f?p=&APP_ID.:5:&SESSION.::::', 'newWin',
    'scrollbars=no,status=no,width=500,height=270' ...
    On the pop up site there is a tree and a submit button which close the window and renew the original page:
    javascript:window.opener.location.reload();window.close();
    Through the tree I get the value (Group-ID) which I need.
    When I'm back on page 4 a "before header" renew page process links again on the side 4 and change the value of my select list. Afterwards the values have changed correctly but the display value is still the old one. It only change when i go on an other page of the apex application and come back.
    I don't know why it doesn't change immediately!?
    Thanks ahead

    I have done with a solution just in a nutshell of what u r looking for:
    1.create HTML region.
    Add two items : Select list with redirect(P6_X) and text field(P7_X)
    2. Select list is based on LOV query as :
    select empno d,empno r from emp ;
    Source value is Empno Type:DBcolumn.
    3.The text field Source type : SQL Query .
    Query : select ename from emp where empno = :P6_X
    Now select from the dropdown empno and it will populate the Ename value accordingly based on the query .
    U can have more than one text fields and populate those in the same way.....
    Cheers,
    ROSY

  • Display value and description of one field in alv grid

    Hi Folks,
       I want to display value and description of one field as one column in alv grid.
    for example iam having Xfield = 01,02,03.
    and 01 iam having text value as xxx,
    01 xxx
    02 yyy
    03 zzz
    Im report display the values are displaying as 01,02,03..
    but i want to display it as 01 xxx,02 yyy, 03 zzz.
    Please do needful.
    Thx.

    Hi, swetha
    You can do this with "concatenate".
    example:
    In you code check where you final internal table is getting filled up before that do this concatenate and then append it.
    data t_text type string.
    t_text = textfield
    CONCATENATE 'Xfield'
                     t_text
                      INTO wa_workarea SEPARATED BY space.
    cheers,
    Bhavana

  • Include a display value in HTML footer

    hi guys,
    I am trying to make a report and i included a HTML footer in the report for signatues ,now i have a value in the same page i want it to be included in the report besides the "rceptionest Signautre"it can be ??can i include a value from the page to be displayed in HTML footer ???anybody can help me
    this is the code
    <p align="left"> </p>
    <p align="left"> </p>
    <table border="0" width="696" id="table1" >
         <tr>
              <td width="315" style="border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-style: solid; border-bottom-width: 1px" style="text-align: left">
              <b>Patient Signature:            </b></td>
         <p align="left"> </p>
              <td width="371" style="border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-style: solid; border-bottom-width: 1px" style="text-align: left">
              <b> Receptionest Signature:</b></td>
         </tr>
    </table>

    Hi NightCabbage ,
    I have a report that it will be printed from the receptionest i included space at the bottom of the report in the page footer
    like this one Receptionest Signature
    by using HTML code as following :
    <p align="left"> </p>
    <p align="left"> </p>
    <table border="0" width="696" id="table1" >
         <tr>
              <td width="315" style="border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-style: solid; border-bottom-width: 1px" style="text-align: left">
              <b>Patient Signature:            </b></td>
         <p align="left"> </p>
              <td width="371" style="border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-style: solid; border-bottom-width: 1px" style="text-align: left">
              <b> Receptionest Signature:</td>
         </tr>
    </table>
    and i have a display value that displays the cashier name ,how can i add the the cashier name from the display value into the html code to be displayed besides the signature
    help me plesase,
    Thank you in Advance,
    Ahmed ,

  • Formatting display value in LOV

    I have an LOV whose display value is a concatenation of 2 database fields. That works fine. But I want to put a tab in between the
    2 fields, otherwise the values are displayed one right after the other, and the columns are out of alignment from one row to the next.
    In sqlplus, I can do:
    select CHR(9)||to_char(objecttype_id)||CHR(9)||objecttype_name from hdb_objecttype;
    And I get:
    12 acoustic velocity meter
    1 basin
    11 canal
    2 climate site
    3 confluence
    4 diversion
    10 hydro plant unit
    5 hydro power plant
    6 reach
    7 reservoir
    14 riverware dataobject
    When I do the same thing in my LOV query, I get
    12 acoustic velocity meter
    1 basin
    11 canal
    2 climate site
    3 confluence
    4 diversion
    10 hydro plant unit
    5 hydro power plant
    6 reach
    7 reservoir
    14 riverware dataobject
    I've tried lpad and rpad, also. With blanks as padding they produce the above results. If I use a character such as '.' they behave
    correctly, but I still don't have standard field widths because of the variance in character sizes.
    Why won't any of this formatting work, and how can I get it to?
    Thanks,
    Carol

    Hi, Carol,
    In addition to what Max said, you may be displaying this in a region where whitespace is compressed; in which case you would need to use non-breaking spaces in place of regular spaces:
    SELECT     REPLACE ( RPAD ( TO_CHAR (objecttype_id)
                     , 10
                     ) || objecttype_name
               , CHR (38) || 'nbsp;'      -- CHR (38) is ampersand
    ...Speaking of compressing whitespace, this site does it.
    So when you say
    CarolM2 wrote:
    In sqlplus, I can do:
    select CHR(9)||to_char(objecttype_id)||CHR(9)||objecttype_name from hdb_objecttype;
    And I get:
    12 acoustic velocity meter
    1 basin
    11 canal
    2 climate site
    3 confluence
    4 diversion
    10 hydro plant unit
    5 hydro power plant
    6 reach
    7 reservoir
    14 riverware dataobject
    When I do the same thing in my LOV query, I get
    12 acoustic velocity meter
    1 basin
    11 canal
    2 climate site
    3 confluence
    4 diversion
    10 hydro plant unit
    5 hydro power plant
    6 reach
    7 reservoir
    14 riverware dataobjectThey come out looking identical.
    When you post formatted text (such as the results above) on this site, type these 6 characters:
    (small letters only, inside curly brackets) before and after sections of formatted text, to preserve spacing.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Null display value in List of Values

    Hello
    In Page item ---> List of Value ---> Null display value I need to give a different value depending on language
    I tried using an item in the "Null Display Value" e.g. &P1_Display_value.
    This does not work ... I get " &P1_Display_value. " and not the value contained in the item
    Anyone come across this before?
    Thanks
    Pete

    Pete:
    The Query for the LOV could be modified to be something as below.
    Select displayy_val, return_val from lov_table
    union
    select '&P1_DISPLAY_VALUE.',null from dual
    order by 2 nulls firstVarad

  • To display value in html: textarea in struts

    Hello,
    I want to display value in <html:textarea> in struts application from my userdefine FormBean.
    i tried like this
    <html:textarea property="documentNumberList" value='"<bean:write name="QualityForm" property="displayDocumentNumber">" ></html:textarea>
    I am not getting success.
    I would be appriciate to you if anyone could let me know what is the solution of this problem ? or send me one example.
    Thanks
    Rajnish
    [email protected]

    Hi,
    That did'nt solve my problem. Actually i am trying to get the arraylist data one by one into different textareas. There are two arrays one is quesArray and the other quesIdArray. I need the quesIdArray in the individual text areas.How can i achieve this?
    I am using the following code to do that.
    <logic:iterate id="item" name="selectionCriteriaForm" indexId="index" property="quesArray">
    <tr><td><li><em><b><bean:write name="item"/> </em></li></b></td>          
    <td><html:textarea property="quesIdArray" cols="50" rows="2" name="selectionCriteriaForm" onkeyup="limitTextarea(answer<%=i %>,5,50)" />          
    <br></td></tr>
    <% i=i+1;
    %></td></tr>          
    </logic:iterate>
    Pls help me on this.
    Thanx in advance.

  • Display Display value in Red Color in Pop Up List of value Item

    Dear All,
    i have created an Pop up List of Value item.I need to display Display value in Red Color in Pop Up List of value Item.
    What should i pass in HTML Form Element Attributes .I have try using
    style="font-color:red";That code.
    How can i display Display Value in Red Color.
    Thanks

    Is this what you are looking for?
    http://apex.oracle.com/pls/apex/f?p=42778:12
    If so..
    * Go to Shared Components -> Templates -> Select Type as "Popup List of Values"
    * Edit Popup LOV template
    * See the class name being used for div under Result Set section. In My case, its t1PopupBody
    * Under Page Attributes -> Page HTML Head section append following CSS
    <style>.t1PopupBody a{color:red;}</style>* Apply Changes
    If its not working, then inspect the pop-up lov with firebug and update CSS definition accordingly.
    Regards,
    Hari

  • Display value in Bar chart conditionally

    I've a chart with Bar-Vertical Stacked type. In one bar 7/8 stacks are coming, some of value 1000 and some of very small values like 2, 5,6 etc. For each of these small bars when I'm displaying value in center position with markerTextPlace="MTP_CENTER", it becomes clumsy.
    In this case, I want to only show the slice in vertical bar but not to display value if value<10.
    How this condition can be checked to view value.
    Please suggest. Kind Regards.

    Can anyone please suggest.
    Regards.

  • How can I get dataTable to display values from the java layer?

    When I use the dataTAble in my JSP page it will only display values from my java layer if the facets tag has it's name set to "header". Why is this happening?
    If I set it to "header" and I look at the page source it actually has created the correct number of rows but it doesn't put the values between the <td> tags? It see's the length of my list but it doesn't pick the values out of the list.
    <h:dataTable var="data" value="#{NameBean.test}" border="1">
    <h:column>
    <f:facet name="header">
    <h:outputText value="Name"/>
    </f:facet>
    </h:column>
    <h:column>
    <f:facet name="header">
    <!-- <h:outputFormat styleClass="outputFormat" id="format1" value="#{NameBean.test}"></h:outputFormat>-->
    <h:outputText styleClass="outputText" value="#{NameBean.test}" style="" rendered="true" escape="false"/>
    </f:facet>
    </h:column>
    </h:dataTable>
    public List gettest()
              List li = new LinkedList();
              Object Developers[] = {"M@n00j", "sdsadas"};
              for( int i = 0; i < Developers.length; i++ )
                   li.add(Developers);
              return li;
    Thanks in advance to anyone that can help.
    -ls6v

    I've been able to get it working with some of those changes along with changes in the JSP. I think it's a setting or two in the JSP that'll allow the program to run correctly.
    I have a list and it's returned like what you suggested. A day or two ago I tried to move the outputtext outside of the facet tag but nothing would print, I know believe that's related to the following setting in the JSP:
    rows="0" in the <h:dataTAble tag
    Unfortunately the dataTAble isn't displaying the values correctly. It prints all of the values (Strings) in the list on each row and it make a new row for the number of items in the list.......... ???
    Here's what it's printing to the screen (the table):
    ===================
    == [asdasd], [sddfdfd] ==
    ===================
    ===================
    == [asdasd], [sddfdfd]==
    ===================
    what it should print:
    ============
    == [asdasd] ==
    ============
    ============
    == [sddfdfd] ==
    ============
    My code:
    public List gettest()
              List li = new ArrayList();
              li.add("asdasd");
              li.add("affffd");
              return li;
              }JSP
    <h:dataTable border="1" columnClasses="list-column-left"
        headerClass="list-header"
        rowClasses="list-row-odd"
        id="table"
        rows="0"
        value="#{NameBean.test}"
        var="data">
    <h:column>
    <f:facet name="header">
    <h:outputText value="test"/>
    </f:facet>
    <h:outputText value="#{NameBean.test}" style="" rendered="true" escape="false"/>
    </h:column>
    </h:dataTable>

  • Display values of a single field in a multiple rows in a table region

    Hi Tech-Gurus,
    I want to display values of a single field ( which is in a table region) in multiple rows and also need to restrict the values from decimal number. If i click save, then it will throw exception "Decimal not allowed".
    xxxxxx
    yyyyyy
    Reg.No
    1234
    5678
    7654
    I need to display the values of REG.NO in different rows like,
    1234
    5678
    7654
    and also need to validate as well against Decimal values.
    Please help me with the code how i will iterate ?

    Hi,
    I am assuming you are talking about displaying substrings from the Reg No in different rows. For this you would need to write a query which identifies the substrings and creates a separate row for each (ensure you choose values for all other columns in the table row). Kindly let me know if the understanding is incorrect.
    To validate against decimal value you can use the java code by checking the difference of the number and the number on which modulus has been applied. Hope that helps.
    Regards
    Sumit

  • How to display the "display values" in READ Only mode for a SHUTTLE

    Hi,
    I have a form item of type *'Shuttle'* and using the following LOV.
       select DEPTNAME d, DEPTNO r
        from  DEPTIn normal mode..it displays the department name and internally store the Deptno..
    Now I converted this item to Read Only mode using Read Only Condition Type
    the problem is as soon as it becomes read only...it displays the deptno....not the department name
                Department-   10:20:30How can I display the "display values" i.e the actual department name in read only mode..
                Department-   Department1:Department2:Department3Thanks,
    Deepak

    Hi,
    It seems feature. Shuttle is span tag when it is read only.
    Work around could be that
    you compute display as text item with LOV display value according shuttle session state and show shuttle and this item conditionally depend case
    Br, JAri

  • Is it possible to change the display value of a domain-based attribute?

    Hello,
    I've selected a domain-based attribute for one of the leaf member attributes in the same entity, aka parent id, since it's a self-referencing entity.  However, I cannot find a way to display anything but the code value in the drop-down (see below).
    Is there a way to change the display value so that I can choose the attribute from the entity from which I want the user to choose? In other words, I would like to display the hierarchy name instead of the code, which is really just the primary id.
    Thanks in advance!
    Ben Lezin

    1. In the explorer page, settings dialog, you can change the display format to show only name.
    2. We cannot use other freeform attribute as DisplayFormat, rather than Code Name. So there are 2 option here:
    a. Remove HierarchyName attribute and just use Name attribute. In the next release, we will allow give Name, Code attribute a displayname, so you can give Name display name as "HierarchyName" in the SQL Vnext release.
    b. Make a Business Rule to update Name when HierarchyName is changed.

Maybe you are looking for

  • Problem Creating APPLICATION Bean

    As you all know, JSF application bean are used to store information across all user sessions. When I create an application bean class with sun creator 2 release, my IDE freezes. And I have to restart creator and then it enters a slump again and the l

  • When is iPhone 6 shipping available in Hong Kong?

    Whenever I go on the apple store it says shipping is unavailable. Since I have a coupon and I can only use it online, I would like to know when is iPhone 6 shipping available. Thank you.

  • Video stretching bug

    Ever since the last ipod update (when they added the fullscreen option) my videos have been playing STRETCHED to wide screen dimensions. When I have the widescreen function enabled in the video settings menu it plays the fullscreen videos STRETCHED t

  • Join returns duplicate rows

    Hi All, I am joining 3 tables:OWOR, WOR1 and IBT1. Following is the query: SELECT OWOR.DOCNUM, OWOR.ITEMCODE, OWOR.CLOSEDATE, OWOR.DOCENTRY, WOR1.ISSUEDQTY, WOR1.DOCENTRY, IBT1.QUANTITY, IBT1.BATCHNUM FROM OWOR INNER JOIN WOR1 ON OWOR.DOCENTRY = WOR1

  • PIX515e dual-stack ipv4 & ipv6 over PPPoE

    Hi Everyone, In short: I am trying to get ipv4 and ipv6 over PPPoE running on my PIX515e. Heres a bit more info about my setup and the scenario: My internet provider (residential) has offered me a dual-stack service on my ADSL. I get a STATIC ipv4 ad