How can I fill a JComboBox with a ResultSet?

I want to fill a JComboBox with the data in ResultSet. What�s the better way to do this? Can I convert a RecordSet to a Vector and use the vector in JComboBox constructor?
Thanks for any help.
Renato

Prova cosi:
myComboBox = new JComboBox();
ArrayList items = new ArrayList();
ResultSet result = conn.executeQuery("SELECT BLABLA FROM BLABLA");
while (result.next())
items.add(result.getString(1));
result.close();
myComboBox.setModel(new DefaultComboBoxModel(items.toArray()));
E' molto pi� efficiente che aggiungere gli item alla combo uno alla volta.
G.M.

Similar Messages

  • How can i populate the Jcombobox with the data from my jpa list? Desperate

    I need to populate my jcombobox with data from my jpa. This is my first time trying this and i just need some sample or a quick solution to this. Thanks in advance
    <code>
    public static MyNames myNames() {
    EntityManagerFactory emf = Persistence.createEntityManagerFactory("JavaTrialsPU");
    EntityManager em = emf.createEntityManager();
    em.getTransaction().begin();
    Query q = em.createNamedQuery("MyNames.findAll");
    MyNames n = (MyNames) q.getResultList();
    return n;
    public static void myCombo() {       
    comboBox = new JComboBox(????--how can i make the jcombobox display my myNames() list--?????);
    frame.add(comboBox, BorderLayout.PAGE_START);
    </code>

    Implement toString() on your entity to return whatever you want to use as a label for the combobox.
    Your need for quick solutions is very destructive to your learning process. In stead take the time and read around a little. Swing happens to have an excellent tutorial with many example programs readily available for you to pick through:
    http://docs.oracle.com/javase/tutorial/uiswing/
    And PS: you need to use \ tags in this forum.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • How can I 'fill free space with songs' AND keep some memory free?

    I like the 'automatically fill free space with songs' option, but it leaves me with no room (or very little room) for taking photos and video.  How can I keep some memory free?
    Matthew

    You'll probably need to backup or clone the remaining OS X partition, definitely clone the bootcamp partition then erase and reformat the drive. You'll need a 3rd party app.
    Check out this thread:
    https://discussions.apple.com/message/9076113#9076113

  • Photoshop CS6 - How can javaScript fill blank layer with color?

    Hello,
    I'm a production artist and I work with PSD files that were created in Adobe Scene7 Image Authoring Tool. These PSDs contain a background layer along with 1-20 alpha channels. My script has to make new blank layers based on the number of alpha channels and then it has to fill the new layers with light gray. The RGB values are 161, 161, 161. I checked the PSCS6 JavaScript Reference pdf, but I don't see a method that would do this for artLayers. (Let me also say that I'm new to javaScript).
    Does anyone know how to fill a blank layer with these RGB values?
    Here's my script so far:
    #target photoshop 
    // declare variable to contain the active document
    var myDoc=app.activeDocument;
    // declare variable to contain the number of alpha channels, excluding the RGB channels
    var alphaChan = myDoc.channels.length - 3;
    // create loop to make new layers based on number of alpha channels and fill each layer with gray
    for (a=0; a<alphaChan; a=+1){
    myDoc.artLayers.add();
    if (myDoc.artLayers.length == (alphaChan + 1)) {
        break;

    var color = new SolidColor();
    color.rgb.red = 161;
    color.rgb.green = 161;
    color.rgb.blue= 161;
    myDoc.selection.fill(color);

  • How can I fill a path with a grid?

    Hi,
    I'm trying to fill some text that has been converted to outlines with a grid pattern (like graph paper). I need the grid to be made up of paths. Is this possible?

    Yes this is possible. This is a little easier with live text as all you have to do is select the 2 elements and do a CMD 7 (Mask). When your text is outlines select the text only, and do a command 8 (make compound), as an additional step prior.

  • How can I fill a pdf form with Excel?

    I have a pdf form and a set of Excel dates. How can I fill the form with this dates?
    Is there any way to transform excel dates into a fdf-File?
    Thank You for helping
    Hans

    I see. That's possible, in theory, but it requires using a complicated custom-made script.
    I would suggest using that Mail Merge option that's available in some versions of Excel to produce multiple single-page files, then flatten all of them (using an Action), and then merge them to a single file, to achieve the same result with much less effort.

  • How can I fill a table of objects from cursor with select * bulk collect???

    Hi All, I have a TYPE as OBJECT
    create or replace type dept2_o as object (
    deptno NUMBER(2),
    dname VARCHAR2(14),
    loc VARCHAR2(13));
    I can fill a table of objects from cursor with out select * bulk collect...., row by row
    declare
    TYPE dept2_t IS TABLE of dept2_o;
    dept_o_tab dept2_t:=dept2_t();
    i integer;
    begin
    i:=0;
    dept_o_tab.extend(20);
    for rec in (select * from dept) loop
    i:=i+1;
    dept_o_tab(i):=dept2_o(
    deptno => rec.deptno,
    dname => rec.dname,
    loc =>rec.loc
    end loop;
    for k IN 1..i loop
    dbms_output.put_line(dept_o_tab(k).deptno||' '||dept_o_tab(k).dname||' '||dept_o_tab(k).loc);
    end loop;
    end;
    RESULT
    10 ACCOUNTING NEW YORK
    20 RESEARCH DALLAS
    30 SALES CHICAGO
    40 OPERATIONS BOSTON
    But I can't fill a table of objects from cursor with select * bulk collect construction ...
    declare
    TYPE dept2_t IS TABLE of dept2_o;
    dept_o_tab dept2_t:=dept2_t();
    begin
    dept_o_tab.extend(20);
    select * bulk collect into dept_o_tab from dept;
    end;
    RESULT
    ORA-06550: line 6, column 39;
    PL/SQL: ORA-00947: not enough values ....
    How can I fill a table of objects from cursor with select * bulk collect???

    create or replace type dept_ot as object (
    deptno NUMBER(2),
    dname VARCHAR2(14),
    loc VARCHAR2(13));
    create table dept
    (deptno number
    ,dname varchar2(14)
    ,loc varchar2(13)
    insert into dept values (10, 'x', 'xx');
    insert into dept values (20, 'y', 'yy');
    insert into dept values (30, 'z', 'zz');
    select dept_ot (deptno, dname, loc)
      from dept
    create type dept_nt is table of dept_ot
    declare
       l_depts dept_nt;
    begin
       select dept_ot (deptno, dname, loc)
         bulk collect
         into l_depts
         from dept
       for i in l_depts.first .. l_depts.last
       loop
          dbms_output.put_line (l_depts(i).deptno);
          dbms_output.put_line (l_depts(i).dname);
          dbms_output.put_line (l_depts(i).loc);    
       end loop;
    end;
    /

  • How can I fill mask with pattern?

    Hi
    Would you please help me? How can a add pattern to a mask? I drew a motion mask on video clip and now I want to fill it with pattern that I made in Photoshop and saved as PSD, what should I do? How can I fill mask with specific pattern?
    Thanks for any help

    AE doesn't directly support a pattern-fill like PS, so here's a workaround (as Mylenium suggested):
    Create a PS document and create a layer filled with the pattern required.
    Import the layer/PSD to AE and place in timeline.
    Place a copy of the masked layer above the Pattern layer.
    On the pattern layer, set the Track Matte to Alpha Matte.
    Read more here:
    http://livedocs.adobe.com/en_US/AfterEffects/8.0/WS3878526689cb91655866c1103906c6dea-7cf9. html

  • How can I fill structure from the line with contetnt of a XML file inside?

    How can I fill structure from the line with contetnt of a XML file inside?
    I have array of lines with XML documents inside. All XML's have the same structure.
    I need to fill array of structures (with the same structure like given XML's) from data of these XML's.
    How can I do this? I am trying Transformation with ora:parseEscapedXML, but receive error: "XPath expression failed to execute.
    Error while processing xpath expression, the expression is "ora:processXSLT("Transformation_1.xsl", bpws:getVariableData("ProcessedFiles"))", the reason is javax.xml.transform.TransformerException: javax.xml.transform.TransformerException: Could not find function: parseEscapedXML.
    Please verify the xpath query."

    Ive posted the new code but now I'm getting a FileAlreadyExistException error. How do I handle this exception error correctly in my code?
    import java.io.IOException;
    import java.nio.file.FileAlreadyExistsException;
    import java.nio.file.Files;
    import java.nio.file.Paths;
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.DocumentBuilderFactory;
    import javax.xml.parsers.ParserConfigurationException;
    import org.w3c.dom.Document;
    import org.w3c.dom.Element;
    import org.w3c.dom.Node;
    import org.w3c.dom.NodeList;
    import org.xml.sax.SAXException;
    public class MyDomParser {
      public static void main(String[] args) {
      DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
      try {
      DocumentBuilder builder = factory.newDocumentBuilder();
      Document doc = builder.parse("ENtemplate.xml");
      doc.normalize();
      NodeList rootNodes = doc.getElementsByTagName("templates");
      Node rootNode = rootNodes.item(0);
      Element rootElement = (Element) rootNode;
      NodeList templateList = rootElement.getElementsByTagName("template");
      for(int i=0; i < templateList.getLength(); i++) {
      Node theTemplate = templateList.item(i);
      Element templateElement = (Element) theTemplate;
      System.out.println(templateElement.getAttribute("name")+ ".xml");
      for(int i=0; i < templateList.getLength(); i++) {
      Node theTemplate = templateList.item(i);
      Element templateElement = (Element) theTemplate;
      String fileName = templateElement.getAttribute("name") + ".xml";
      Files.createFile(Paths.get(fileName));
      System.out.println("File" + ":" + fileName + ".xml created");
      } catch (ParserConfigurationException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
      } catch (SAXException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
      } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();

  • How can I have two fields with the same name if it makes sense?

    Hello, folks :)
    I have a pretty hard time figuring out how I can have two text fields with the same binding name.
    The whole problem is that when I need two fields with the same binding name they are still differnent coz they have the same name but differnt indices.
    I should make a form filled at runtime by merging a pdf form file and an fdf file data file. And I have no choice to do it differently. And my form file needs some data like customerName, companyName twice in one form. But there's only one possible buinding name indexed zero.
    How can I create a field with absolutely the same name or is it just impossible due to possible name conflicts? And is there a workaround to this problem? I just need one piece of data repeated in different places.
    Thanks for your replies :)
    P.S. if u think that the problem is not clear enough let me know. I'll supply you with more details. But the general process can not be changed.
    One pdf should be mergred with an fdf with as the result of their merge a new filled and flattened form. I have no control over fdfs their are generated by Oracle and I can not fill the form using XML files coz this process should be integrated in a working application.

    I just thought about a really ugly workaround with a server-side script adding values to fdf files but it's a bit of work and tests and personally i think it's a bad idea :-(

  • How can I fill in a form, save the form such that it cannot be further altered, and email it as it was saved?

    How can I fill in a form, save the form such that it cannot be further altered, and email it as it was saved?  I created a form with 5 fields.  It is a form letter that is intended as a receipt for funds received.  I want to fill in the date, name, amount received, etc., save the form with inserted data fields so they can't be further altered, and be able to email it as a complete unalterable PDF document.  What I'm doing now, is filling in the fields, printing it, scanning it, and emailing it as an unalterable document.  The document was created on a Mac using Adobe Acrobat Pro version 10.1.13.  The document is filled in on a PC that only has Adobe reader on it, printed, scanned and emailed as an attachment. There must be a better way! 

    If you have access to a ASP.net Web Server, then the submission could be FLATTENED with FDFToolkit.net and emailed without client-side email software by only using Adobe Reader.
    For more information check out the following websites:
    http://www.pdfemail.net/examples/
    http://www.fdftoolkit.net/examples/

  • How can I fill a pdf form?

    how can I fill a pdf form?

    With Adobe Reader.  If you have any difficulties, please provide some details.

  • How can I make the popup with empty fileds and create new record?

    I would like to use a popup to create new record.
    I created a af:popup by drag and drop a VO from data control to jsff. then, I created a button and place a af:showPopupBehavior. I was able to popup window by click the button.
    however, the window filled with the information from the 1st record. and when I select a record in table and click popup, the popup is filled with that record.
    How can I make the popup with empty fileds and create new record by saving the popup?
    Thanks

    You can have edit and new buttons, in the PopupFetchEvent identify button source (using popupFetchEvent.getLaunchSourceClientId()) if new button clicked clear the binding using below code.
    If you want to see empty fields, in the popup PopupFetchEvent clear the input component bindings.
    resetBindingValue("#{bindings.<componentid>.inputValue}", null);
        public static void resetBindingValue(String expression, Object newValue) {
            FacesContext ctx = FacesContext.getCurrentInstance();
            Application app = ctx.getApplication();
            ExpressionFactory elFactory = app.getExpressionFactory();
            ELContext elContext = ctx.getELContext();
            ValueExpression valueExp = elFactory.createValueExpression(elContext,expression,Object.class);
            Class bindClass = valueExp.getType(elContext);
            valueExp.setValue(elContext,newValue);
        }

  • How can I fill my Organizer

    Good evening Creative Community,
    Sorry when my English is not so good because I'm German.:mansad:
    I have a question how can I fill my Zen X-fi 2 Organizer with the Creative Media Centrale.
    And my own Meaning to Creative Media Centrale is not so good and I find
    the Software for the Zen V Plus better because the Software of Zen V Plus is clearer
    and you can fill your player easyer than the software of the Zen X-fi 2.
    I hope you can help me and you can understand my english and what I mean.
    Nicolaj

    You can delete songs from your iTunes/computer hard drive after transferring them to the iPod, and for this you need to set your iPod to manage the songs manually.
    However, this is an extremely risky option because when (and not if) there comes a time to restore your iPod, which is a very common fix for iPod problems, then all the music would be erased. If you no longer have the music in iTunes (or any other back up), then all that music would be lost.
    What if the iPod were lost/stolen/needed repair? Again, the music would lost. I strongly recommend a back up, and if computer hard drive space is in short supply, you should seriously consider an external hard drive. They are not expensive, and the cost is well worth it when compared to the loss of all your precious music.
    At the very least back up your music to either cd or dvd before deleting it, particularly any purchased music/videos, as this would have to be bought again if it were lost. See this.
    Backing up your media in iTunes.

  • How can i fill the iTunes Connect ITIN?

    Hi,
    i am trying to sell the book on iBookstore but i can't find tge way how can i fill the ITIN on form.
    i am living in istanbul.
    i am non-US person.
    Any idea?
    Any help?
    Thanks.

    You would need to try to contact support for content providers, the standard support system at apple wouldn't be able to help much with this as they pretty much handle the consumer end of support and not the provider/developer, Only support for that I could find is available at http://www.apple.com/itunes/content-providers/

Maybe you are looking for

  • HT1695 How do I activate my daughters iPod Touch?

    My daughter just received an iPod Touch for Christmas, but I am not sure how to add it to my home network or to change my settings to include more guests. Can anyone help me?

  • MM Invoice TAX issue

    Dear Gurus, I am having problem with TAX Code, input Tax is not allowed to be posted to G/L accounts. When we use the amount split in MM invoice it picks the TAX Code automatically against each amount. Which is not required and it does not allow to p

  • Positioning Buttons Randomly

    I have 30 thumb (roll over) images to locate them on the document window at random positions. What tag is the best for my project?  AP Divs or Table? Please help me with your detail explanation. Appreciating in advance, Jong

  • Mac OS X Lion 10.7 black screen crashes (and SSD stalls again)

    Hi, I have downloaded and installed Mac OS X 10.7 Lion a couple of hours ago and I am facing blackscreen crashes every hour or so. Blackscreens seem to happen when I use new Lion features such as mission control, swipe between desktops, and document

  • IMac with built-in iSight, PC, Skype compatability

    I know this is a simple question, but I read a few months ago where macs had a few compatability problems with webcam communicating to PC's. If both are using Skype, is there a problem webcam audio/visual communicating between a PC and an iMac using