How to add an array of integers to JList?

I know it should be easy, but I can't see a simple way to add an array of integers to a JList.
int[] per_ints = tempbean.getPercents();
//missing wrapper
JList list2 = new JList(per_ints);//wont work because JList will not take int[]

what you should do is convert the int to string and then populate the list...
int[] per_ints = tempbean.getPercents();
Integer perI[] = new Integer[per_ints.length];
for (int z = 0; z< per_ints.length; z++){   
perI[z] = new Integer(per_ints[z]);
JList list2 = new JList(Integer.toString(perI));
i think this should work...but if not try to convert tempbean.getPercent() to string and making that array a string array...basically store string in the list some how....probably not the best or simplest way..but i think it should work

Similar Messages

  • How to add byte[] array based Image to the SQL Server without using parameter

    how to add byte[] array based Image to the SQL Server without using parameter.I have a column in table with the type image in sql and i want to add image array to the sql image column like below:
    I want to add image (RESIM) to the procedur like shown above but sql accepts byte[] RESIMI like System.Drowing. I whant that  sql accepts byte [] array like sql  image type
    not using cmd.ParametersAdd() method
    here is Isle() method content

    SQL Server binary constants use a hexadecimal format:
    https://msdn.microsoft.com/en-us/library/ms179899.aspx
    You'll have to build that string from a byte array yourself:
    byte[] bytes = ...
    StringBuilder builder = new StringBuilder("0x", 2 + bytes.Length * 2);
    foreach (var b in bytes)
    builder.Append(b.ToString("X2"));
    string binhex = builder.ToString();
    That said, what you're trying to do - not using parameters - is the wrong thing to do. Not only it is insecure due to the risk of SQL injection but in the case of binary data is also inefficient since these hex strings are larger than the original byte[]
    data.

  • How to convert an array of Integers into String

    So how can an array of integers be converted into a string?
    As I do not have a javac with me now, I hope you guys could help.
    Can it be done this way:
    int [] value = new int[] {2,3,4,5,6,7}
    String strValue = "";
    for (i=0; i<value.length-1; i++)
    strValue += value;

    Instead of working with Strings, I would suggest you use a StringBuffer. It will improve memory utilization.
    Like this:
    int [] values = new int[] {2,3,4,5,6,7};
    StringBuffer sbTmp = new StringBuffer();
    final int size = values.length;
    for (i = 0; i < size; i++) {
    String intStr = Integer.toString(values);
    sbTmp.append(intStr);
    String strValues = sbTmp.toString();

  • How to add an Array within an array?

    Hi friends can any body guides me how to add array within array.
    Actually i am getting Array from server side and i have to append one more node(Array) in same array and send it back to them.
    here is the structure of my array that i am getting from server side.
    temp = Array (@4445e09)   
        [0] = mx.utils.ObjectProxy (@4314821)   
            Mylanguages = Array (@4445b69)   
                [0] = Object (@449ac91)   
                    Mylanguage = "English"   
                    Mylanguage_code = "EN"   
                    Mylanguage_id = "1"   
                    selected = "Y"   
                length = 1   
            currentpage = "1"   
            definition_id = "20"   
            delete_record = "Y"   
            edit_record = "Y"   
            insert_record = "Y"   
            numberofpages = "1"   
            numberofrecords = "1"   
            object = Object (@4432449)   
            productgroups = Array (@43cea51)   
            type = null   
            uid = "111111"   
        length = 1
    I have to add an array similar to like Mylanguages  containing object which contain some info like some ids. and my array becomes
    ttemp = Array (@4445e09)   
        [0] = mx.utils.ObjectProxy (@4314821)   
            Mylanguages = Array (@4445b69)   
                [0] = Object (@449ac91)   
                    Mylanguage = "English"   
                    Mylanguage_code = "EN"   
                    Mylanguage_id = "1"   
                    selected = "Y"   
                length = 1   
            currentpage = "1"   
            definition_id = "20"   
            delete_record = "Y"   
            edit_record = "Y"   
            insert_record = "Y"   
            numberofpages = "1"   
            numberofrecords = "1"   
            object = Object (@4432449)   
            productgroups = Array (@43cea51)
           AddedNOde= Array (@4445b69)   
                [0] = Object (@449ac91)   
                    id= "10"   
                    tempId= "100"   
                    Mylanguage_id = "1"   
                length = 1           
            type = null   
            uid = "111111"   
        length = 1   
    please tell me how it possible.
    Thanks in Advance
    Regards
    Vineet osho

    Hi Vineet,
    You can simply add another Array as shown below:
    for each(var obj:Object in temp)
         obj.AddedNOde = YourNewArray;
    By doing above NewArray is added to  all the objects of temp Array.
    Thanks,
    Bhasker
    Message was edited by: BhaskerChari

  • How to add an array of data in Citadel database

    I have an array of data which I want to directly put it in the Citadel Database. Normally the write tag VI writes one value at a time. How can this be done ?

    It depends on what you really want. Could you be a little more specific? Does each point have its own separate timestamp? If so, you could simply put the "Write Tag.VI" inside a FOR LOOP and insert values one after another. This would give a separate timestamp to each value. I have attached a simple VI that shows how to do this.
    Or are you looking to record some type of vector, where you log a complete array of data at each interval? I don't think this is possible (I'm using DSC 6.02) unless the data-type is a bit-array, in which case you would simply use "Write Data (bit array).vi".
    Another option, depending on what you are aiming for, would be to create your own "VI-based Device Server" and use the VIs on the palette submenu call
    ed "DSC Server Development". With your own Device Driver you can write multiple datapoints to the input queue simultaneuosly. In this way, you can write more than one point at a time... but that doesn't mean that each time interval will contain an array of data. Assuming that the data is analog, the data will still be logged to Citadel "one after another" so that when you look at it with the HTV, you will see one curve of analog values.
    Attachments:
    Write_array_to_citadel.vi ‏17 KB

  • Object array - how to add items?

    Hello!
    I have little problem, how to add item to array, to get something like this:
    Object[][] someObject = {
    {"1", "2"},
    {"4","5"}
    };From this:
    Object[][] someObject = {
    {"1", "2"}
    };? Thanks in advance!

    Once you allocate an array like that, you can't
    resize it.
    Object[][] someObject = {
    {"1", "2"}
    };creates an array with size [1][2]. You can't makeit
    any larger. You can create a new Object[][]
    with the new size, copy the elements into the new
    array, then add your new objects in the newposition.
    or even better use arraylistExcept that he's using this for a JTable, so the best he could do is a Vector. Yuck. :)

  • How to add a 2D result array to the result database?

    I am using Teststand 3.5 and I am about to create a Labview VI that will measure the gain response of a receiver. This VI will output it as an 2D-Array and I would like to save it to my access result database, to be able to use that data for displaying a graph in my excel report.
    I am new to teststand and I already know how to add a 2D-array to a report but don't really know how to add this information to the database. I read the provided manuals and searched the forums but didn't find anything that was really helpful. AFAIK I can add numerics and strings to the database just by adding a string value or numeric limit test but when it comes to arrays (especially 2D), I have no idea how to do that. I only know (or guess) that I have to add a new  table to my database, edit the schema and the Database.seq.
    I appreciate any help!
    Stephan

    Stephan,
    Sometimes forum posts make you research a particular functionality of TestStand and lead you to discover how powerfull TestStand can be.  This is one of these cases.  I thought that in order to save 2D arrays in TestStand we would have to customize many different aspects of the application only to learn that the functionality is fully implemented already!
    First, you will have to create a new step type that contains a 2D array in the Step.Result properties.
    Second, in order to save a 2D array into a database, use the Binary Column Type in your table.  To do this, create a new table with the following properties:
    Type: Recordset
    Command text: "SELECT * from [Table Name]"
    Apply to: Step Result
    Types to Log: [Step type with which you are acquiring your 2D array]
    Lock Type: Optimistic
    The rest of the properties can be left with their default values.  Once you have your table, add an ID column as your primary key, and a second column that will contain the 2D array.  This column should have the following properties:
    Type: Binary
    Size: 1.5 times the size of your array in bytes
    Expected Properties: Logging.StepResult.[Property Containing the Array]
    Expression: Logging.StepResult.[Property Containing the Array]
    The rest of the properties can be left with their default values.  In order to see the values stored in the database, open the Database Viewer to the particular table and right click on the field which will show a value of "Binary Data".  Right click on the value and select Evaluate Data.  The View Binary Data window will let you see all the values stored in the array.
    Regards,
    Santiago D

  • How to add gaussian white noise to array of one's and negative one's ?

    how to add gaussian white noise to array of one's and negative one's ?
    Solved!
    Go to Solution.

    Is it this that your are trying to accomplish:
    TO:
    Here's the code to do that.
    Michel

  • How to add array of file types to file dialog box

    Hi
    I just want to know how to add array of file types in file dialog box vi. I know that multiple file type can be added to filedialog vi in the pattern Input string separated by semicolon (eg *.vi;*.doc;*.jpeg;*.xls). But i want file dialog which is shown in the below picture.
    I think that file dialog vi call user32.dll but i don't have that header file to call that dll.
    Waiting for your esteemed response.
    Thanks & Regards
    Samuel J
    System Engineer
    Captronic Systems Pvt Ltd
    Bangalore, India.

    I'm not sure how (or even if) it can be achieved using the LabVIEW built-in open dialog, but a .NET call to openfiledialog (http://msdn.microsoft.com/en-us/library/system.windows.forms.openfiledialog.aspx) can do what you're looking for. The .NET functions are better documentented that simple user.dll calls, so it might be easier to implement.
    Shaun

  • Constructing a linked list from an array of integers

    How do I create a linked list from an array of 28 integers in a constructor? The array of integers can be of any value that we desire. However we must use that array to test and debug methods such as getFirst(), getLast(), etc...
    I also have a method int getPosition(int position) where its suppose to return an element at the specified position. However, I get an error that says cannot find symbol: variable data or method next()
    public int getPosition(int position){
         LinkedListIterator iter=new LinkedListIterator();
         Node previous=null;
         Node current=first;
         if(position==0)
         return current.data;
         while(iter.hasMore()){
         iter.next();
         if(position==1)
         return iter.data;
         iter.next();
         if(position==2)
         return iter.data;
         iter.next();
         if(position==3)
         return iter.data;
         iter.next();
         if(position==4)
         return iter.data;
         iter.next();
         if(position==5)
         return iter.data;
         iter.next();
         if(position==6)
         return iter.data;
         iter.next();
         if(position==7)
         return iter.data;
         iter.next();
         if(position==8)
         return iter.data;
         iter.next();
         if(position==9)
         return iter.data;
         iter.next();
         if(position==10)
         return iter.data;
         iter.next();
         if(position==11)
         return iter.data;
         iter.next();
         if(position==12)
         return iter.data;
         iter.next();
         if(position==13)
         return iter.data;
         iter.next();
         if(position==14)
         return iter.data;
         iter.next();
         if(position==15)
         return iter.data;
         iter.next();
         if(position==16)
         return iter.data;
         iter.next();
         if(position==17)
         return iter.data;
         iter.next();
         if(position==18)
         return iter.data;
         iter.next();
         if(position==19)
         return iter.data;
         iter.next();
         if(position==20)
         return iter.data;
         iter.next();
         if(position==21)
         return iter.data;
         iter.next();
         if(position==22)
         return iter.data;
         iter.next();
         if(position==23)
         return iter.data;
         iter.next();
         if(position==24)
         return iter.data;
         iter.next();
         if(position==25)
         return iter.data;
         iter.next();
         if(position==26)
         return iter.data;
         iter.next();
         if(position==27)
         return iter.data;
         iter.next();
         if(position==28)
         return iter.data;
         if(position>28 || position<0)
         throw new NoSuchElementException();
         }

    How do I create a linked list from an array of 28 integers
    in a constructor? In a LinkedList constructor? If you check the LinkedList class (google 'java LinkedList'), there is no constructor that accepts an integer array.
    In a constructor of your own class? Use a for loop to step through your array and use the LinkedList add() method to add the elements of your array to your LinkedList.
    I get an error that
    says cannot find symbol: variable data or method
    next()If you look at the LinkedListIterator class (google, wait for it...."java LinkedListIterator"), you will see there is no next() method. Instead, you typically do the following to get an iterator:
    LinkedList myLL = new LinkedList();
    Iterator iter = myLL.iterator();
    The Iterator class has a next() method.

  • How to add objects to panel from another class?

    Hi this is what i am trying to do. I have a drag and adrop tool working where the users and select objects on a small panel and drag them to another panel called the tpan. What i want to do is create another class, which creates objects and now i want to display these objects on the tpan. So say i have a class DisplayTpan(), this class is used to display the objects which have been dragged from the small panel, and objects on this panel have mouselisteners attached, so that these objects can be moved around on the tpan. I have created another class called creatObj(), and from this class i want to add objects to the tpan. The DisplayTpan class extends a Jpanel, would this be he case for the CreateObj() class? In the CreateClass i have made a call to DisplayTpan t = new DisplayTPan();
    t.add(object);
    But this does not add the object to the panel, any ideas on how it should be done?
    Problem number two i have is say, I have two objects created on that oanel, i now want to draw a line t connect the two objects, this is just simply a call to the drawLine function but how would it be possible to add a ,mouselistener to that line, so it can be extended moved around etc? Any help much appreciated thanks.

    As for your first problem...too confusing...too tired...mb tomorrow it will make sense :)
    Fer the second...no need to add a mouse listener to each line. There are a couple options that spring to mind, the easiest I can think of is just check to see if the mouse click intersects with any of the lines (bit of geometry).
    The second, ugly but a hella allot more accurate and better (me thinks), is to create a bounding box around the line, so the user doesn't have to click right right on the line. I created this bounding box by painting the pixels with a special key to correspond to that line. The other nice thing about this key is the fact that the lookup is quick.
    The first step was the create a array of integers the size of the surface. Whenever a line is drawn on the graphical surface, do a corresponding line in the integer array, and create the bounding box inside this invisible array. Now whenever the user clicks just do a lookup into this array and check to see which line was selected...then go to town.
    If you want a more detailed explination, i'll post some code later.

  • Functions to read and display an array of integers

    Hi guys,
    I am trying to implement with a class called Sort a function to read in an array of integers from a file and a function to display that array.
    public class Sort
         public static int[] read(String file) throws IOException
            /* Create Reader object to read contents of file */
            BufferedReader br = new BufferedReader(new FileReader(file));
            /* Read file and store lines in ArrayList */
            ArrayList<Integer> list = new ArrayList<Integer>();
            /* Variable */
            String in;
            /* While not equal to null reads data from file */
            while ((in = br.readLine()) != null)
                /* Adds data from file to ArrayList */
                list.add(Integer.parseInt(in));
            /* Converts ArrayList into an array */
            int[] array = new int[list.size()];
            for(int i = 0; i < list.size(); i++)
                /* Get array elements */
                array[i] = list.get(i);
            /* Returns array */
            return array;
        public int display()
            for (int i = 0; i < list.size(); i++)
                System.out.println(list.get(i));
    }I am having one of those moments when you forget everything, I need help with display the array in a seperate function, will someone help me please?
    Thanks!

    I know that its just implementing it.
    I have:
    public void display()
            for(int i = 0; i < array.length; i++)
                System.out.println(array);
    But I'm lost on how to make this work, i.e it says "cannot find array variable". I've not done Java for a while and feel like I have forgot everything!
    Edited by: mbruce10 on Nov 15, 2009 1:31 AM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • How do i use array to store a readfile information?

    currently i m facing with this problem, i have a set of .txt file data which look like below:
    6 6 3 10 3 5
    6 8 4 10 8 6
    10 17 1 11 1 1
    7 18 3 10 3 5
    8 19 1 11 1 1
    10 20 2 11 1 5
    7 20 4 10 8 6
    8 22 2 11 1 5
    10 25 4 10 8 6
    10 26 7 11 1 8
    8 27 8 12 1 11
    8 28 7 11 1 8
    10 30 9 9 8 11
    8 31 11 12 3 12
    10 32 10 11 1 12
    now i'm using while ((text = in.readLine()) != null) to read this set of data.
    how do i can store this set of data into array form as below??
    int [ ][ ] data = new String [100][6];
    //6 6 3 10 3 5 1st row
    data[0][0] = ( "6" );
    data[0][1] = ( "6" );
    data[0][2] = ( "3" );
    data[0][3] = ( "10" );
    data[0][4] = ( "3" );
    data[0][5] = ( "5" );
    //6 8 4 10 8 6 2nd row
    data[1][0]= ("6");
    data[1][1]= ("8");
    data[1][2] = ( "4" );
    data[1][3]= ("10");
    data[1][4]= ("8");
    data[1][5] = ( "6" );

    Well using the String.split() method you may be able to turn each line into an array of String numbers. So if you want an array of integers, you'll need to convert each index with Integer.parseInt().

  • How to add selected values from table(selected using checkbox)to table?

    Hi All,
    i have created simple page with search panel with table in table i have created one column as check box for selecting.
    here what my requirement is i need to do search multiple times to add some roles to from some different categories.here whenever i searched i ll get some roles into table there i ll select some role and i ll click add buttion. whenever i click add i need to add those roles into some other table finally i ll submit added roles.
    here i followed one link http://www.oracle.com/technetwork/developer-tools/adf/learnmore/99-checkbox-for-delete-in-table-1539659.pdf
    i used same code and able to see selected row in console, as object array how to add these into table.
    please help me out
    Thanks in advance
    siva shankar

    Thank you for a quick reply
    i used the same thing before i go for table check box concept.here what i observed is when i search i am getting some results i am able to shuttle.but if i search again the shuttle is refreshing with new values even not available list its refreshing selected list. IF dont want refresh selected ones.
    my usecase after make some searches I will select some roles from different categories at finally i ll submit.
    i hope you understand me requirement. please suggest me is this requirement is possible in shuttle component? if yes please guide me.
    thanks
    Siva Sankar

  • How to add a default value in a site column for every item in a document library

    HI
    i created a content type with some site columns ,
    and included in a Document library.
    Process ( content type)
    -ProcessNo
    -ProcessName
    after that i uploaded 100 Documents but not  added value in a site column process name.
    now  how i add a default value in a site column for every document in a document library 
    adil

    HI
    i get below error when i change the script 
    PS C:\scripts> C:\Scripts\updatedefaultvalue.ps1
    Cannot index into a null array.
    At C:\Scripts\updatedefaultvalue.ps1:8 char:7
    + IF($i[ <<<< "Title"] -eq $null)
        + CategoryInfo          : InvalidOperation: (Title:String) [], RuntimeExce
       ption
        + FullyQualifiedErrorId : NullArray
    $web = Get-SPWeb http://tspmcwfe:89/
    $list = $web.Lists["test"]
    $item = $list.Items | Where { $_["Name"] -eq "Emc" }
    foreach($i in $items)
    IF($i["Title"] -eq $null)
             $i["Title"] = "test"
           $i.Update()
    adil
    Why are you piping a where in the items? Do you only want to add the "test" to ones matching
    a name?
    If you have ISE installed on your server I recommend you put your code in there and debug it. 
    If this is helpful please mark it so. Also if this solved your problem mark as answer.

Maybe you are looking for

  • SSL Errors - Sometimes

    Hello, Sometimes when I visit our online order form I get the SSL errors "This website does not supply identity information" and "The connection to this website is not fully secure (images)." However, if I reload the page, the errors disappear and th

  • Control, Service and I/O Domains

    I was wondering what others have been doing regarding the setup of Control, Service and I/O Domains. I assume most combine the Control and Service Domain? The I/O Domain is another story or not? If my system has 2 I/O buses do you have 2 I/O Domains?

  • Converting purchased Lost movie from my APPLE to my PC.

    Can anyone help? I use a Apple computer and a windows computer. I purchase the first and second seasons of LOST on my Apple computer. I would like to play them on my PC. IS THIS POSSIBLE WITHOUT PURCHASING FROM MY PC? Seems like I should be able to c

  • HT1688 messed up messages after update

    My phone is not typing messages correctly after the update.  It has at least a 15 second delay and some times it take minutes to type messages.  Is there anything to do to correct this? It is very frusterating. 

  • Funnel slice is not filled fully

    All Experts, I have a problem in Funnel graph. Please chk http://www.2shared.com/photo/YxNVsnwu/funnel.html My funnel is not filling the entire slice here. How to do this ? Please advice.. Data for funnel is Stage Actual Target abc     304     683 pq