Store int values into dynamic array

Hello all,
I'm a newbie in JAVA whose want to store int values (coming from a resultset) into an dynamic array. I know that normally to create a "dynamic array" you'd better use a Vector, but it seems that I don't know how to use it correctly (throws me a exception as : Incompatible type for method. Can't convert int[] to java.lang.Object[]).
Thanks in advance
STF

I want to use the copyInto method of the vector, but it throw me an exception as ')' expected
I include a snip of my code below ;
Vector v= new Vector();
Vector vv=new Vector();
String[] labels=new String[v.size()];
Integer[] values=new Integer[vv.size()];
cont=rs.getInt("COUNT(CASE_ID_)");
vv.add(j,new Integer(cont));
log=rs.getString("ORIG_SUBMITTER");
v.add(j,new String(log));
v.copyInto(String[] labels);
vv.copyInto(Integer[] values);

Similar Messages

  • Pass the Sting value into date array

    Hi,
    i want to pass the stirng value into date array. how is it possible...
    eg.. i am getting the value as sting i.e String str = "10/31/2006";
    now i want to store this value into date array.. i.e new Date[]{date};
    i want to store that string as date.....
    plz help me

    Hi,
    i want to pass the stirng value into date array. how
    is it possible...
    eg.. i am getting the value as sting i.e String
    str = "10/31/2006";
    now i want to store this value into date array.. i.e
    new Date[]{date};
    i want to store that string as date.....
    plz help meUse java.util.SimpleDateFormat
    :)

  • Store XML node value into an array with node element name

    Hi,
    I have the following code that displays the node element with the
    corresponding node value. I want to store the values in an array in
    reference to the node name.
    i.e.
    XML (my xml is much bigger than this, 300 elements):
    <stock>
    <symbol>SUNW</symbol>
    <price>17.1</price>
    </stock>-----
    would store the following:
    *data[symbol] = SUNW;*
    *data[price] = 17.1;*
    Thanks in advance,
    Tony
    test.jsp
    Here's my source code:
    <html>
    <head>
    <title>dom parser</title>
    <%@ page import="javax.xml.parsers.*" %>
    <%@ page import="org.w3c.dom.*" %>
    <%@ page import="dombean.*" %>
    </head>
    <body bgcolor="#ffffcc">
    <center>
    <h3>Pathways Info</h3>
    <table border="2" width="50%">
    <jsp:useBean id="domparser" class="dombean.MyDomParserBean" />
    <%
    Document doc = domparser.getDocument("c:/stocks/stocks.xml");
    traverseTree(doc, out);
    %>
    <%! private void traverseTree(Node node,JspWriter out) throws Exception {
    if(node == null) {
    return;
    int type = node.getNodeType();
    switch (type) {
    // handle document nodes
    case Node.DOCUMENT_NODE: {
    out.println("<tr>");
    traverseTree
    (((Document)node).getDocumentElement(),
    out);
    break;
    // handle element nodes
    case Node.ELEMENT_NODE: {
    String elementName = node.getNodeName();
    //if(elementName.equals("MOTHER-OCC-YRS-PREVIOUS")) {
    //out.println("</tr>");
    out.println("<tr><td>"+elementName+"</td>");
    NodeList childNodes =
    node.getChildNodes();     
    if(childNodes != null) {
    int length = childNodes.getLength();
    for (int loopIndex = 0; loopIndex <
    length ; loopIndex++)
    traverseTree
    (childNodes.item(loopIndex),out);
    break;
    // handle text nodes
    case Node.TEXT_NODE: {
    String data = node.getNodeValue().trim();
    //if((data.indexOf("\n")  <0) &#38;&#38; (data.length() > 0)) {
    out.println("<td>"+data+"</td></tr>");
    %>
    </table>
    </body>
    </html>
    {code}
    *MyDomParserBean.java*
    Code: package dombean;
    {code:java}
    import javax.xml.parsers.*;
    import org.w3c.dom.*;
    import java.io.*;
    public class MyDomParserBean
    implements java.io.Serializable {
    public MyDomParserBean() {
    public static Document
    getDocument(String file) throws Exception {
    // Step 1: create a DocumentBuilderFactory
    DocumentBuilderFactory dbf =
    DocumentBuilderFactory.newInstance();
    // Step 2: create a DocumentBuilder
    DocumentBuilder db = dbf.newDocumentBuilder();
    // Step 3: parse the input file to get a Document object
    Document doc = db.parse(new File(file));
    return doc;
    {code}
    Edited by: ynotlim333 on Sep 24, 2007 8:41 PM
    Edited by: ynotlim333 on Sep 24, 2007 8:44 PM
    Edited by: ynotlim333 on Sep 24, 2007 8:45 PM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    I still need to store it in an array because its 300 elements in the XML stocks.
    I've done the following but its not working, i'm getting error codes. I think its an easy fix. I'd also like to pass a String instead of a .xml document b/c my xml is stored inside a DB. Any suggestions on that?
    <html>
    <head>
    <title>dom parser</title>
    <%@ page import="javax.xml.parsers.*" %>
    <%@ page import="org.w3c.dom.*" %>
    <%@ page import="org.*" %>
    </head>
    <body bgcolor="#ffffcc">
    <center>
    <h3>Pathways Info</h3>
    <table border="2" width="50%">
    <jsp:useBean id="domparser" class="org.MyDomParserBean" />
    <%
    Document doc = domparser.getDocument("c:/stocks/stocks.xml");
    traverseTree(doc, out);
    %>
    <%!
            public String element_store = null;
            public String[] stock_data = new String[400];
            private void traverseTree(Node node,JspWriter out) throws Exception {
            if(node == null) {
               return;
            int type = node.getNodeType();
            switch (type) {
               // handle document nodes
               case Node.DOCUMENT_NODE: {
                 out.println("<tr>");
                 traverseTree
                 (((Document)node).getDocumentElement(),
                 out);
                 break;
              // handle element nodes
              case Node.ELEMENT_NODE: {
                String elementName = node.getNodeName();
                element_store = elementName;
                 //if(elementName.equals("MOTHER-OCC-YRS-PREVIOUS")) {
                   //out.println("</tr>");
                 NodeList childNodes =
                 node.getChildNodes();     
                 if(childNodes != null) {
                    int length = childNodes.getLength();
                    for (int loopIndex = 0; loopIndex <
                    length ; loopIndex++)
                       traverseTree
                       (childNodes.item(loopIndex),out);
                  break;
               // handle text nodes
               case Node.TEXT_NODE: {
                  String data = node.getNodeValue().trim();
                  if((data.indexOf("\n")  <0) && (data.length() > 0)) {
                  out.println("<tr><td>"+element_store+"</td>");
                  out.println("<td>"+data+"</td></tr>");
                  stock_data[element_store]=data;
    %>
    </table>
    </body>
    </html>

  • Store multiple values into a variable

    I was wondering if it was possible to store multiple values into one varaible. Something along the lines of...
    Oracle: 10g
    --Table xSample (this is obviously a dumbed down version of the table for the sake of showing what I want to accomplish
    S_ID   YEAR
    1         2009
    2         2009
    3         2009
    4         2009
    --Query
    select     s_id
    into       pID
    from      xSample
    where    year = 2009;Basically the reason I was trying to figure out how to store multiple values into a variable is b/c I was going to use that variable (pID) as a parameter and have it's values passed dynamically when the proc was called. The values would go into a query that would look something like:
    select *
    from cust_data
    where person_id in (pID)
    aka
    select *
    from cust_data
    where person_id in (1,2,3,4)Not sure if this is possible, but if anyone knows of a way I could accomplish this that would be great.
    Edited by: user652714 on Dec 23, 2009 9:37 AM

    Here's a basic idea building a comma seperated list, then consuming it in another query (taking the in list approach from Tom's post, linked earlier).
    create table xsample (s_id number not null, year number);
    insert into xsample select level, 2009 from dual connect by level <=4;
    commit;
    declare
       --4000 should be lots ... hopefully?
       v_parameter_list varchar2(4000);
    begin
      --create the comma seperated list
      select
        substr(max(sys_connect_by_path(s_id, ',') ), 2, 4000)
      into
        v_parameter_list
      from
        select s_id, row_number() over(order by 1) as rn
        from xsample
        where year = 2009
      start with rn = 1
      connect by prior rn = rn - 1;
      --consume the comma seperated list
      for x in
        with data as
          select
            trim( substr (txt,
            instr (txt, ',', 1, level  ) + 1,
            instr (txt, ',', 1, level+1)
            - instr (txt, ',', 1, level) -1 ) ) as token
          from
            select ','||v_parameter_list||',' txt
            from dual
          connect by level <= length(v_parameter_list)-length(replace(v_parameter_list,',',''))+1
        select *
        from xsample
        where s_id in (select * from data) 
      loop
        dbms_output.put_line('next item = ' || x.s_id);
      end loop;
    end;
    /

  • (Urgent help needed) how to read txt file and store the data into 2D-array?

    Hi, I have a GUI which allow to choose file from the file chooser, and when "Read file" button is pressed, I want to show the array data into the textarea.
    The sample data is like this followed:
    -0.0007     -0.0061     0.0006
    -0.0002     0.0203     0.0066
    0     0.2317     0.008
    0.0017     0.5957     0.0008
    0.0024     1.071     0.0029
    0.0439     1.4873     -0.0003
    I want my program to scan through and store these data into 2D array.
    However for some reason, my source code issues errors, and I don't know what's wrong with it, seems to have a problem in StringTokenizer though. Can anybody help me?
    Thanks in advance.
    import java.io.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.util.StringTokenizer;
    public class FileReduction1 extends JFrame implements ActionListener{
    // GUI features
    private BufferedReader fileInput;
    private JTextArea textArea;
    private JButton openButton, readButton,processButton,saveButton;
    private JTextField textfield;
    private JPanel pnlfile;
    private JPanel buttonpnl;
    private JPanel buttonbar;
    // Other fields
    private File fileName;
    private String[][] data;
    private int numLines;
    public FileReduction1(String s) {
    super(s);
    // Content pane
         Container cp = getContentPane();
         cp.setLayout(new BorderLayout());     
    // Open button Panel
    pnlfile=new JPanel(new BorderLayout());
         textfield=new JTextField();
         openButton = new JButton("Open File");
    openButton.addActionListener(this);
    pnlfile.add(openButton,BorderLayout.WEST);
         pnlfile.add(textfield,BorderLayout.CENTER);
         readButton = new JButton("Read File");
    readButton.addActionListener(this);
         readButton.setEnabled(false);
    pnlfile.add(readButton,BorderLayout.EAST);
         cp.add(pnlfile, BorderLayout.NORTH);
         // Text area     
         textArea = new JTextArea(10, 100);
    cp.add(new JScrollPane(textArea),BorderLayout.CENTER);
    processButton = new JButton("Process");
    //processButton.addActionListener(this);
    saveButton=new JButton("Save into");
    //saveButton.addActionListener(this);
    buttonbar=new JPanel(new FlowLayout(FlowLayout.RIGHT));
    buttonpnl=new JPanel(new GridLayout(1,0));
    buttonpnl.add(processButton);
    buttonpnl.add(saveButton);
    buttonbar.add(buttonpnl);
    cp.add(buttonbar,BorderLayout.SOUTH);
    /* ACTION PERFORMED */
    public void actionPerformed(ActionEvent event) {
    if (event.getActionCommand().equals("Open File")) getFileName();
         if (event.getActionCommand().equals("Read File")) readFile();
    /* OPEN THE FILE */
    private void getFileName() {
    // Display file dialog so user can select file to open
         JFileChooser fileChooser = new JFileChooser();
         fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
         int result = fileChooser.showOpenDialog(this);
         // If cancel button selected return
         if (result == JFileChooser.CANCEL_OPTION) return;
    if (result == JFileChooser.APPROVE_OPTION)
         fileName = fileChooser.getSelectedFile();
    textfield.setText(fileName.getName());
         if (checkFileName()) {
         openButton.setEnabled(false);
         readButton.setEnabled(true);
         // Obtain selected file
    /* READ FILE */
    private void readFile() {
    // Disable read button
    readButton.setEnabled(false);
    // Dimension data structure
         getNumberOfLines();
         data = new String[numLines][];
         // Read file
         readTheFile();
         // Output to text area     
         textArea.setText(data[0][0] + "\n");
         for(int index=0;index < data.length;index++)
    for(int j=1;j<data[index].length;j++)
    textArea.append(data[index][j] + "\n");
         // Rnable open button
         openButton.setEnabled(true);
    /* GET NUMBER OF LINES */
    /* Get number of lines in file and prepare data structure. */
    private void getNumberOfLines() {
    int counter = 0;
         // Open the file
         openFile();
         // Loop through file incrementing counter
         try {
         String line = fileInput.readLine();
         while (line != null) {
         counter++;
              System.out.println("(" + counter + ") " + line);
    line = fileInput.readLine();
         numLines = counter;
    closeFile();
         catch(IOException ioException) {
         JOptionPane.showMessageDialog(this,"Error reading File",
                   "Error 5: ",JOptionPane.ERROR_MESSAGE);
         closeFile();
         System.exit(1);
    /* READ FILE */
    private void readTheFile() {
    // Open the file
    int row=0;
    int col=0;
         openFile();
    System.out.println("Read the file");     
         // Loop through file incrementing counter
         try {
    String line = fileInput.readLine();
         while (line != null)
    StringTokenizer st=new StringTokenizer(line);
    while(st.hasMoreTokens())
    data[row][col]=st.nextToken();
    System.out.println(data[row][col]);
    col++;
    row++;
    closeFile();
    catch(IOException ioException) {
         JOptionPane.showMessageDialog(this,"Error reading File",
                   "Error 5: ",JOptionPane.ERROR_MESSAGE);
         closeFile();
         System.exit(1);
    /* CHECK FILE NAME */
    /* Return flase if selected file is a directory, access is denied or is
    not a file name. */
    private boolean checkFileName() {
         if (fileName.exists()) {
         if (fileName.canRead()) {
              if (fileName.isFile()) return(true);
              else JOptionPane.showMessageDialog(null,
                        "ERROR 3: File is a directory");
         else JOptionPane.showMessageDialog(null,
                        "ERROR 2: Access denied");
         else JOptionPane.showMessageDialog(null,
                        "ERROR 1: No such file!");
         // Return
         return(false);
    /* FILE HANDLING UTILITIES */
    /* OPEN FILE */
    private void openFile() {
         try {
         // Open file
         FileReader file = new FileReader(fileName);
         fileInput = new BufferedReader(file);
         catch(IOException ioException) {
         JOptionPane.showMessageDialog(this,"Error Opening File",
                   "Error 4: ",JOptionPane.ERROR_MESSAGE);
    System.out.println("File opened");
    /* CLOSE FILE */
    private void closeFile() {
    if (fileInput != null) {
         try {
              fileInput.close();
         catch (IOException ioException) {
         JOptionPane.showMessageDialog(this,"Error Opening File",
                   "Error 4: ",JOptionPane.ERROR_MESSAGE);
    System.out.println("File closed");
    /* MAIN METHOD */
    /* MAIN METHOD */
    public static void main(String[] args) throws IOException {
         // Create instance of class FileChooser
         FileReduction1 newFile = new FileReduction1("File Reduction Program");
         // Make window vissible
         newFile.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         newFile.setSize(500,400);
    newFile.setVisible(true);
    Java.lang.NullpointException
    at FileReductoin1.readTheFile <FileReduction1.java :172>
    at FileReductoin1.readFile <FileReduction1.java :110>
    at FileReductoin1.actionPerformed <FileReduction1.java :71>
    .

    1) Next time use the CODE tags. this is way too much unreadable crap.
    2) The problem is your String[][] data.... the only place I see you do anything approching initializing it is
    data = new String[numLines][];I think you want to do this..
    data = new String[numLines][3];anyway that's why it's blowing up on the line
    data[row][col]=st.nextToken();

  • How to insert values into an array of class

    Hello everyone,
    I need help in inserting values into an array of class, which i have read from a file.
    Length of the array is 5. I should insert values one by one into that array.
    If the array is full (if count = 5), then I should split the array into 2 arrays
    and adjust the values to left and right with median.
    I'm getting an ArrayBoundException .. can anybody help me out ?
    Thanks in advance
    Here is my code..........
    import java.util.*;
    import java.io.*;
    public class Tree
         static String second;
         static String first;
         static int count = 5;
         public void insert(int f1,int s1, int c)
              if(c!=0)
                   Record[] rec = new Record[4];
                   for (int i = 0; i < 5; i++)
                          rec[i] = new Record(); 
                   for(int i = 0; i<=4;i++)
                        rec.x = f1;
                        rec[i].y = s1;
              else
                   System.out.println("yes");
         public static void main(String[] args)
              Tree t = new Tree();
              try
                   FileReader fr = new FileReader("output.txt");           // open file
                   BufferedReader br = new BufferedReader(fr);
                   String s;
                   while((s = br.readLine()) != null)
                        StringTokenizer st = new StringTokenizer(s);
                        while(st.hasMoreTokens())
                             first = st.nextToken();
                             second = st.nextToken();
                        //     System.out.println("First-->"+first+" "+"Second-->"+second);
                        int fir = Integer.parseInt(first);
                        int sec = Integer.parseInt(second);
                        t.insert(fir, sec, count);                    
                   fr.close(); // close file           
              catch (IOException e)
    System.out.println("Can't read file");
    class Record
         public int x,y;

    Hi qwedwe.
    Record[] rec = new Record[4];
                   for (int i = 0; i < 5; i++)
                          rec[i] = new Record(); 
                     }Here is your error: you have an array of 4 Records, but you create and (try to) insert 5 Record-instances.... try:
    Record[] rec = new Record[c];
                   for (int i = 0; i < c; i++)
                          rec[i] = new Record(); 
                     }Regards,
    Norman

  • Covert an int value into a ninteger

    How do i convert an int value into an integer.Please help

    http://java.sun.com/j2se/1.5.0/docs/guide/language/autoboxing.html
    Since JDK 1.5, you can do the below:
    public class TestAB {
         public static void main(String[] args) {
              int i = 0;
              Integer a = ++i;
              System.out.println(a);
              i = 1 + a;
              System.out.println(i);
    }Message was edited by:
    John60

  • OpenScript script variables - can store multiple values or an array?

    Hello,
    I'm helping with a proof-of-concept for driving the Primavera P6 web services using OpenScript, and I'm having a bit of trouble using the script variables. One of the web services can return anywhere from 0 to many objects, and I was trying to save those object IDs into a script variable. The built-in "substitute variable" seemed to work great, but the variable only contains the last result, not all of them. Here's the line that's saving the value:
    http.solve("objIdsToDelete", "<ObjectId>(.+?)</ObjectId>", "", true, Source.Html, 0, EncodeOptions.None);
    Even if there are, for example, 5 <ObjectId> in the response, the variable only has the last result... Any suggestions on how I can tweak this (different regular expression?) to either store an array or a comma-separated list of all the values?
    Thanks!
    -Troy Newton

    Hi Troy,
    Sorry about my last answer. It wasn't too specific. So if you want to collect the whole array instead of a specific value (referenced by the index) you would change e.g.
    http.solve("formsload.loginsubmit_1",
                                  "FORM_SUBMIT_BUTTON':'(.+?)'", "", false, Source.Html,
                                  1, EncodeOptions.None);
    which would give you the second value from the array (remember that arrays are indexed from 0) to
    http.solve("formsload.loginsubmit_1",
                                  "FORM_SUBMIT_BUTTON':'(.+?)'", "", false, Source.Html,
                                  null, EncodeOptions.None);
    Notice the null, this will return an array to the coolection. You can then reference these by:
              String myStrings[]=getVariables().getAll("formsload.loginsubmit_1");
                        info("Number of elements in array is :" + myStrings.length);
                        for (int i=0;i<myStrings.length;i++)
                             info("Element Number " + i + ":" + myStrings [ i ] );
    This will result in an output like:
    0 Passed Comments: Number of elements in array is 2
    0 Passed Comments: Element Number 0: Submit Button
    0 Passed Comments: Element Number 1: Cancel
    I hope this helps.....
    Regards
    Wayne.
    Edited by: byrne_wayne on Nov 26, 2010 1:40 PM
    Edited by: byrne_wayne on Nov 26, 2010 4:42 PM

  • How does this program group and cluster these button values into an array?

    In the attached program, there are 6 buttons in a cluster and 1 individual button. These buttons control a bunch of different relays to control power to different components of a single device. Right now the program works in that I can control the 6 buttons, the LED turns on in the board and the power is being transmitted. What I do not understand is how it is doing this.  I ran the program with the highlight execution on and at the start of the read from array component, if say I pressed button 6 and hit ok, it reads #6, where did these get defined and labled? and if i wanted to add another button/relay how do i do this? If someone could explain step by step how this is grouping the relays on the board into an array and then controling them I would really appreciate it. Thanks.
    Solved!
    Go to Solution.
    Attachments:
    Cluster to Array.vi ‏85 KB

    The #6 your seeing is the number of elements in the array not a value for the array. 
    Now for some deeper explainations.   From the code it appears that exactly 1 of 6 valves may be used and an additional valve may be in one of two possible states.
    When the program is run the cluster of buttons is initiallized to all False.  and we enter the outer while loop where a sequence structure starts.  In the first frame of the sequence we initiallize a shift register to hold the current value of "Buttons." and this loop runs unthrottled (Add a wait for next ms multiple to this loop to prevent using 100% of the CPU!) 
    For each iteration the buttons are read and if a change has occured to any value buttons that were previously True are reset to False to prevent opening more than one valve.
    When the user presses OK or stop- the current "Buttons" value is passed to the next frame.  This frame convertsthe 7 boolean values to a integer where each valve is controlled by a seperate bit of the integer (Isolation is bit 6 and bits 0-5 each control a mixing valve)
    Now I'd strongly recommend reworking the DAQmx calls- it is pointless to initiallize the task each time you want to use it- Create the task in the initialzation case and wait until the user exits to destroy the task.  And well a sequence structures are frowned on- (there are better ways to do this)
    As far as adding a relay- right now the relays are associated to the hardware by their index position in the cluster (element 1 = bit 0 etc....) to add a new valve you would need to decide what bit you would use to drive it and code in that bits' value to write a 0 in that bit.  (hint the 40 constant is realy 0x40 right-click>visable items>show radix )
    Let me know if you need further elaboration
    Jeff

  • Can I store a value into a given row and channel?

    Hi all-
    My question is basic, but I can't seem to find the answer in any of the forums or help windows.
    Is there a way to store a variable into a particular row and cell number?For example, if i have a channel named [1]/ChannelB and the following:
    Dim A
    A= 12
    I want to store the value of 12 into row 7 of [1]/ChannelB... Is there a method for doing this?

    Hello,
    You can access individual cells in DIAdem with the ChDX variable.
    For instance, to store the value of A in row 7 of [1]/ChannelB you'd do this:
    Dim A
    A = 12
    chnval(7,"/ChannelB") = A
    Hope this helps,
         Otmar
    Otmar D. Foehner
    Business Development Manager
    DIAdem and Test Data Management
    National Instruments
    Austin, TX - USA
    "For an optimist the glass is half full, for a pessimist it's half empty, and for an engineer is twice bigger than necessary."

  • How to store the value into variable and access it in RMAN script

    I want to create a variable and dynamically assign a numeric value to it (may get the value may be from SQL )and access the value in RMAN script.
    Thanks...Raj

    Raj,
    We have been getting this type of request and it is not possible via RMAN to do that.
    BUT--You could write a sql/plus script to query your variable and produce the RMAN script with the new value.
    Just a suggestion.
    Tammy

  • How to insert new value into an array

    I have an already declared array (including the size) and want to write a method for inserting a new value. Do I have to re-declare the array to the new size? ie old size + 1, then add the new value or is there a java method for this. I can't find one.
    Thanks in advance....
    Mike

    Hi,
    there is no method for that. Look up class Vector. That class implements automatic growing of the Vector.
    Phil

  • How do I store the values in the @D array in the below mentioned VI? Only the last row in the Array is populated with values from the image.

    Hello Guys,
    I am trying to build a sinogram from 180 projection images and I am not able to store the summed values into the array as it is moving the values and then populating all the rows except for the last with ZERO.
    Thanks in advance.
    Attachments:
    sinogram.vi ‏53 KB

    Your loop runs only three times, so all you can possibly populate is 3 rows.
    Typically, you would initialize a shift register with the initialized array, then use replace array subset, feeding the modified array back into the shift register. However, in this case you could just autoindex the 1D array at the output tunnel to build the resulting 2D array.
    Sorry, I am not familiar with sinograms. Do you have a link describing the algorithm?
    LabVIEW Champion . Do more with less code and in less time .

  • How do i store value into my itunes account?

    i have never used an itunes music store gift certificate before, in fact i only made one purchase in itunes before, and that was because i was just playing with my itunes setting and didn't know there was no final confirmation stage to cancel a purchase.
    anyway, a friend of mine give me an one hundred dollar gift certificate, and i have no idea where to store the value into my itunes account. can someone please help me out with it?
    in addition, the way my name appeared on the gift certificate is a little different from how i had entered it in itunes. will that cause any problem?
    any assistance would be greatly appreciated. thanks.

    It will store it in your iTunes music store account
    The name/spelling does not matter.
    Open iTunes.
    Select Music Store.
    On the left side of the store under Account, select Gift Certificate, then Redeem.
    Enter the number on the Gift Certificate and then click Redeem.
    This amount will be added to your iTunes store account and you can use it whenever you want. You don't need to do it all at once either.

  • Storing a record set into an array

    Hello Again,
    Yet another road block in my destination to completing my program. I wanted to create a MultiColumn Combobox and needed to store my Database values into an array so I get get them into the Combobox. I'm having trouble getting this code to work properly. It seems that the the combobox wont accept the variable items maybe because it is outside the scope? I tried to move the code around to get it to work but it don't.
    here is the code.
    package pms;
    import java.awt.*;
    import javax.swing.*;
    import java.sql.*;
    public class Test3 extends JFrame {
        public static void main(String[] args) {
            new Test3();
        public Test3() {
            Container c = getContentPane();
            c.setLayout(new BorderLayout());
            c.setBackground(Color.gray);
            DBConnection db = new DBConnection();
            try {
                Connection conn = DriverManager.getConnection(db.connUrl);
                Statement sql = conn.createStatement();
                ResultSet rs = sql.executeQuery("SELECT * FROM Referrals ORDER BY Referral_Text");
                while (rs.next()) {
                    Item[] items = {
                        new Item(rs.getString(2), rs.getString(2)),};
                JComboBox jcb = new JComboBox(items);
                //Close connections.
                rs.close();
                sql.close();
                conn.close();
            } catch (SQLException e) {
                e.getStackTrace();
            jcb.setPreferredSize(new Dimension(24, 24));
            jcb.setRenderer(new ItemRenderer());
            c.add(jcb, BorderLayout.NORTH);
            setSize(200, 100);
            setLocationRelativeTo(null);
            setDefaultCloseOperation(EXIT_ON_CLOSE);
            setVisible(true);
    // The items to display in the combobox...
        class Item {
            String itemName = "";
            String itemValue = "";
            public Item(String name, String value) {
                itemName = name;
                itemValue = value;
    // The combobox's renderer...
        class ItemRenderer extends JPanel implements ListCellRenderer {
            private JLabel nameLabel = new JLabel(" ");
            private JLabel valueLabel = new JLabel(" ");
            public ItemRenderer() {
                setOpaque(true);
                setLayout(new GridLayout(1, 2));
                add(nameLabel);
                add(valueLabel);
            public Component getListCellRendererComponent(
                    JList list,
                    Object value,
                    int index,
                    boolean isSelected,
                    boolean cellHasFocus) {
                nameLabel.setText(((Item) value).itemName);
                valueLabel.setText(((Item) value).itemValue);
                if (isSelected) {
                    setBackground(Color.black);
                    nameLabel.setForeground(Color.white);
                    valueLabel.setForeground(Color.white);
                } else {
                    setBackground(Color.white);
                    nameLabel.setForeground(Color.black);
                    valueLabel.setForeground(Color.black);
                return this;
    }Thanks!

    He is telling you that there are two problems with your code.
    The first is that you are declaring the items array inside the while loop, which means its scope is too limited - it can't be accessed by the JComboBox which is declared later.
    The second is that you are recreating the items array for every record in your ResultSet. This implies that for every new record, the item(s) already stored will be removed from memory and replaced by the values of the latest record, leading to a single option for your combo box.
    Try instead creating an ArrayList object that you initialise right before the loop, and add items to it's collection as you move along. Then pass that ArrayList to the JComboBox in this way:
              try {
                   Connection conn = DriverManager.getConnection(db.connUrl);
                   Statement sql = conn.createStatement();
                   ResultSet rs = sql
                             .executeQuery("SELECT * FROM Referrals ORDER BY ReferItemText");
                   ArrayList<Item> items = new ArrayList<Item>();
                   while (rs.next()) {
                        items.add(new Item(rs.getString(2), rs.getString(2)));
                   JComboBox jcb = new JComboBox(items.toArray());
                   // Close connections.
                   rs.close();
                   sql.close();
                   conn.close();
              } catch (SQLException e) {
                   e.getStackTrace();
              }

Maybe you are looking for

  • Default save path using AXAcroPDF

    Hi, I'm using the AxAcroPDF component in a windows forms Application. I know that the default filename for the save dialog can be setup using AxAcroPDF.src("filename"); Is there an option to set the default path for the save dialog. Is there a way to

  • Mac book pro retina wireless drivers

    I have mbp retina early 2013 (i7, 2.4GHz, 256GB ssd). I wanted to use windows 7 on the same machine. so I installed it but the wireless card was not been recognized (i downloaded and installed bootcamp drivers but nothing). Do you have a solution?

  • Speed Ramping

    I want a clip to progressively slow down as the clip ends, I also want it to start slowing down from a point at which i can choose, Anyways I can do this?  Basically Im a new user to Adobe Premiere Pro as it is much better than Sony Vegas and I'm jus

  • 60i to 50i conversion, but not keeping original length?

    I'm sitting here with the raw footage for a music promo. Half is shot 50i, half is 60i. I need to end up in PAL, so I'm trying to figure out how to convert the 60i stuff to 50i. As all the 60i material has to be slowed down anyway, so I don't want to

  • Duplicate sound running on slideshow

    Hi, I know this is another sound issue but I have gone through many pages in the discussion forum and not seen this issue. I have a presentation which in Inspector has no 'Builds' and in Document /Audio (I have dragged from Media / Audio) a mp3 file