How can I create multi-dimensional arrays of controls?

I'm building a VI that will have hundreds of on/off buttons, 24 on each of 8 tabs.  I can deal with them programmatically in an array, like this:
and then find which one was pushed with some XOR'ing:
But what if I want two rows of 12 buttons?  Can I make a 2D array of buttons somehow?  Or a 1D array of buttons on two rows for cosmetic reasons?
What if I want to put 24 buttons on each of 8 tabs?  Can I make a 24x8 array of controls somehow?  Or a 12x2x8?
Thanks,
-Jordan
Solved!
Go to Solution.

jordanglassman wrote:
and then find which one was pushed with some XOR'ing:
I would strongly recommend to replace the XOR with a not equal. Same outcome, but less nerdy. It is also much more universal! For example if you ever need to do this on an array of numerics to see which element got changed (I often do!), the XOR will no longer work as well (with integers, you'll end up with bitwise comparisons and numeric results, and with DBLs you'll end up with coercions and unpredictable results because bits are lost).
LabVIEW Champion . Do more with less code and in less time .

Similar Messages

  • How can I use two dimensional array ?

    Could some one show me how to use two dimentional array ?
    I am know how to right a single ...but not two dimentional....please help,
    Thanks,
    Flower
    public class Exam5
    public static void main(String[] args)
    int[][] numbers =
         {     {1,2,3,4,5,6,7,8,9,10},
    {1,2,3,4,5,6,7,8,9,10} };
    for(int i = 1; i < 11; ++i)
    System.out.println(i + "\t" + i * 2 + "\t" + i * 3 + "\t" + i * 4 + "\t" + i * 5 +
    "\t" + i * 6 + "\t" + i * 7 + "\t" + i * 8 + "\t" + i * 9 + "\t" + i * 10);
    Display #
    1     2     3     4     5     6     7     8     9     10
    2     4     6     8     10     12     14     16     18     20
    3     6     9     12     15     18     21     24     27     30
    4     8     12     16     20     24     28     32     36     40
    5     10     15     20     25     30     35     40     45     50
    6     12     18     24     30     36     42     48     54     60
    7     14     21     28     35     42     49     56     63     70
    8     16     24     32     40     48     56     64     72     80
    9     18     27     36     45     54     63     72     81     90
    10     20     30     40     50     60     70     80     90     100

    First, try not to ask someone to do your homework for you and then tell them they are wrong. The code posted may not have been exactly what you were looking for, but it was not wrong because it did exactly what the poster said it would do - print out the multiplication table.
    Second, in the future if you ask specific questions rather than posting code and hoping someone will fix it for you, you may one day be able to complete the assignments on your own.
    Here is code that prints what you want and uses a two dimensional array. Please ask questions if you do not understand the code. You will never learn if you just use someone else's code without taking the time to examine or understand it.
    public class MultiTable{  
        public static void main(String[] args)   { 
            int rows = 10;
            int columns = 10;
            int [][] numbers = new int [rows] [columns];
            for(int j = 0; j < rows; j++)   // for each of 10 rows
                for(int k = 0; k < columns; k++)    // for each of 10 columns
                    numbers[j][k] = (j+1) * (k+1);  // calculate row+1 * col+1
            for (int j = 0; j < rows; j++)  // for each of 10 rows
                for (int k = 0; k < columns; k++)   // for each of 10 columns
                    System.out.print(numbers[j][k]+" ");    // print out result
                    if (numbers[j][k] < 10)     // for single digit numbers
                        System.out.print(" ");  // print extra space for better formatting
                System.out.println();       // skip to next line
    }

  • How can I do two dimensional arrays?

    I am a C++ programmer and in C++ I am able make a two dimensional array and input the values that correspond to those cells.
    After I saw the proposals that you (experts) made I am going to share a little of the classified information that I was working for the undefeatable XO game.
    First step:My idea was to make a two dimensional array(in C++ we use the following syntex for two dimensional array{array[i][j]})
    I was wondering if I am able to make a two dimensional array using LABVIEW .
    Second step: Store the values of X or O inside the 2D array.And use maybe boolean variables(in C++ we use inaddition to that if statement).
    My second question :What can I do inorder to minimize the number of boolean vaariables?(also if statements in C++)
    Jupiter
    extinct when hell froze over

    This is a subroutine I use to check for a winner in a XO game.
    While playing, the main code replaces default 0's by 1's inside the 2D array of a single player.
    Then the main code calls this VI with the 2D array of that player and check for a winning game.
    Any board size is ok as long as you have equal number of cols & rows.
    So, enter 1's at any location in the "Score" 2D array and the code will check for a winning game.
    As you can see I don't use any boolean variables, except the return value of this VI (read function) 
    So to answer your second question; I minimized the use of boolean variables to 0 1! Is that ok for you?
    Attachments:
    TTT-Check4Winner.vi ‏20 KB

  • How can I create a buffer, array or pipeline that stores the last 5000 dates of a voltage measurement with PCI6036 & SCXI1104C and continously drops the last date and inserts the latest date (scanrate 200 or 2000Hz)?

    I develope a porgramm for continious monitoring. If the voltage of a channel exceeds or is lower than the upper or lower limit of tolerance the actual date must be stored and additionally the dates being stored 10sec before and after this event. Can somebody give some advice how to create the buffer to keep the dates 10s before the error event? Thank U.

    I've written you a quick array buffer vi. I'm not sure if it'll be fast enough though.. Try it and see! I've used the loop numbers in my array, but i'm sure you can feed in the dates instead.
    Attachments:
    Array_buffer.vi ‏26 KB

  • How can I create a single array from three arrays? Please Help!

    I have three arrays:
    Dates[2002-10-29 2002-10-30 2002-10-31 ...]
    OCodes[AC AD AE ...]
    LCodes[A01 A02 A03 ...]
    I would like to combine the above three arrays and write out to an array
    The new array would look like:
    NewArray[ 2002-10-29 AC A01, 2002-10-29 AC A02, 2002-10-29 AC A03,
    2002-10-29 AD A01, 2002-10-29 AD A02, 2002-10-29 AD A03,
    2002-10-29 AE A01, 2002-10-29 AE A02, 2002-10-29 AE A03 ......,
    2002-10-31 AC A01, 2002-10-31 AC A02, 2002-10-31 AC A03....,
    2002-10-31 AE A01, 2002-10-31 AE A02, 2002-10-31 AE A03...]
    Thanks in advance!

    String [ ] newArray = new String [Dates.length];
    for (int counter = 0; counter < Dates.length; ++ counter)
    StringBuffer buf = new String Buffer();
    buf.append(Dates[counter] + " ");
    buf.append(OCodes[counter] + " ");
    buf.append(LCodes[counter]);
    newArray[counter] = buf.toString(0;
    }

  • How can you create a multi-page pdf document in photoshop elements 13?

    I previously had pse 11 and was able to create multi-page documents as pse files. However, pse 13 does not allow. How can I create multi-page pdf files from pse 13?

    Alas, for one of those mysterious adobe reasons, it's gone in recent versions. Only multipage file you can make is a photobook.

  • Best practice in JSTL with multi-dimensional arrays

    Hi,
    I'm working in a project and I'm trying to convert some code into JSTL way, I have a first.jsp that calls addField(String, String) from fieldControl.jsp:
    (first.jsp)
    <%@page contentType="text/html"%>
    <%@page pageEncoding="UTF-8"%>
    <%@ include file="fieldControl.jsp" %>
    <html>
    <head><title>JSP Page</title></head>
    <body>
    <%! String[][] list1;
    %>
    <%
    list1 = new String[2][2];
    list1[0][0]="first_1";
    list1[0][1]="first_2";
    list1[1][0]="second_1";
    list1[1][1]="second_2";
    for (int i=0;i<list1.length;i++){
    String html;
    html = addField (list1[0], list1[i][1]);
    out.println(html);
    %>
    </body>
    </html>
    (fieldControl.jsp)
    <%@page contentType="text/html"%>
    <%@page pageEncoding="UTF-8"%>
    <%@ page language="java" %>
    <%! public void addField(String name,String label)
    return ...
    Now for JSTL I've this example from "JSTL pratical guide for JSP programmers" Sue Spielman:
    <%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
    <html>
    <head>
    <title>
    Display Results
    </title>
    </head>
    <body>
    <%-- Create a HashMap so we can add some values to it --%>
    <jsp:useBean id="hash" class="java.util.HashMap" />
    <%-- Add some values, so that we can loop over them --%>
    <%
         hash.put("apples","pie");
         hash.put("oranges","juice");
         hash.put("plums","pudding");
         hash.put("peaches","jam");
    %>
    <br>
    <c:forEach var="item" items="${hash}">
    I like to use <c:out value="${item.key}" /> to make <c:out value="${hash[item.key]}" />
    <br>
    <br>
    </c:forEach>
    </body>
    </html>
    and my problem is :
    1st - how to use the multi-dimensional array in this way (<jsp:useBean id="hash" class="java.util.HashMap" />) ? because if I use it like this
    <% String[][] list1;
    list1 = new String[2][2];
    list1[0][0]="first_1";
    list1[0][1]="first_1";
    list1[1][0]="second_1";
    list1[1][1]="second_2";%>
    <c:out value="${list1}" />
    <c:out value="${list1.lenght}" />
    I get nothing,
    also tryed <c:set var="test" value="<%=list1.length%>" /> and got "According to TLD or attribute directive in tag file, attribute value does not accept any expressions"
    2nd hot to make the call to the method addField?
    Thanks for any help, I really want to make this project using JSTL, PV

    When you are using JSTL, it is best to not put data inside the JSP. Put it inside JavaBeans. Then make calles to the methods in those JavaBeans.
    So you should get used to JavaBeans and their requirenments.
    Access JavaBeans only through 2 types of methods: getters and setters.
    Getters are used to "get" values (properties) from the bean, and always have the form
    public Type getPropertyName(void)
    That is, they are public, return some value, start with the exact string "get" end with the name of the property (first letter of the property name capitalized) and have a void (empty) argument list.
    For example, this is a good signature to get HTML from a bean:
    public String getHtml()
    Setters are used to assign values to a bean. They always have the form
    public void setPropertyName(Type value)
    That is, they are public, do not return anything, start with the string "set", end with the name of the property (first letter capitalized), and take a SINGLE parameter.
    public void setHtml(String value)
    Also, JavaBeans must have a no argument constructor and need to be Serializable.
    The way I would approach this would be to create a JavaBean that holds the two dim array for you, and has a getter that returns a list of all the formatted html.
    package mypack;
    import java.util.List;
    import java.util.ArrayList;
    public class DataFormatterBean implement java.io.Serializable {
      private String[][] list;
      public DataFormatterBean() {
        list = new String[2][2];
        list[0][0]="first_1";
        list[0][1]="first_2";
        list[1][0]="second_1";
        list[1][1]="second_2";
      public List getHtml() {
        List outputHtml = new ArrayList(list.length);
        for (int i = 0; i < list.length; i++) {
          String html = addField(list[0], list[i][1]);
    outputHtml.add(html);
    return outputHtml;
    private addField(String a, String b) { .. do work .. }
    Then, the JSP would look like this:
    <jsp:useBean id="dataFormatter" class="mypack.DataFormatterBean"/>
    <c:forEach var="htmlString" items="${dataFormatter.html}">
      <c:out value="${htmlString}"/>
    </c:forEach>Once you start thinking in terms of having JavaBeans do your work for you JSTL is so much easier... and it gets even easier when you start to delve into custom tags.

  • How can I (neatly) control mouse click events in a multi-dimensional array?

    Hello everyone!
         I have a question regarding the use of mouse clicks events in a multi-dimensional array (or a "2D" array as we refer to them in Java and C++).
    Background
         I have an array of objects each with a corresponding mouse click event. Each object is stored at a location ranging from [0][0] to [5][8] (hence a 9 x 6 grid) and has the specific column and row number associated with it as well (i.e. tile [2][4] has a row number of 2 and a column number of 4, even though it is on the third row, fifth column). Upon each mouse click, the tile that is selected is stored in a temporary array. The array is cleared if a tile is clicked that does not share a column or row value equal to, minus or plus 1 with the currently targeted tile (i.e. clicking tile [1][1] will clear the array if there aren't any tiles stored that have the row/column number
    [0][0], [0][1], [0][2],
    [1][0], [1][1], [1][2],
    [2][0], [2][1], [2][2]
    or any contiguous column/row with another tile stored in the array, meaning that the newly clicked tile only needs to be sharing a border with one of the tiles in the temp array but not necessarily with the last tile stored).
    Question
         What is a clean, tidy way of programming this in AS3? Here are a couple portions of my code (although the mouse click event isn't finished/working correctly):
      public function tileClick(e:MouseEvent):void
       var tile:Object = e.currentTarget;
       tileSelect.push(uint(tile.currentFrameLabel));
       selectArr.push(tile);
       if (tile.select.visible == false)
        tile.select.visible = true;
       else
        tile.select.visible = false;
       for (var i:uint = 0; i < selectArr.length; i++)
        if ((tile.rowN == selectArr[i].rowN - 1) ||
         (tile.rowN == selectArr[i].rowN) ||
         (tile.rowN == selectArr[i].rowN + 1))
         if ((tile.colN == selectArr[i].colN - 1) ||
         (tile.colN == selectArr[i].colN) ||
         (tile.colN == selectArr[i].colN + 1))
          trace("jackpot!" + i);
        else
         for (var ii:uint = 0; ii < 1; ii++)
          for (var iii:uint = 0; iii < selectArr.length; iii++)
           selectArr[iii].select.visible = false;
          selectArr = [];
          trace("Err!");

    Andrei1,
         So are you saying that if I, rather than assigning a uint to the column and row number for each tile, just assigned a string to each one in the form "#_#" then I could actually just assign the "adjacent" array directly to it instead of using a generic object to hold those values? In this case, my click event would simply check the indexes, one at a time, of all tiles currently stored in my "selectArr" array against the column/row string in the currently selected tile. Am I correct so far? If I am then let's say that "selectArr" is currently holding five tile coordinates (the user has clicked on five adjacent tiles thus far) and a sixth one is being evaluated now:
    Current "selectArr" values:
           1_0
           1_1, 2_1, 3_1
                  2_2
    New tile clicked:
           1_0
           1_1, 2_1, 3_1
                  2_2
                  2_3
    Coordinate search:
           1_-1
    0_0, 1_0, 2_0, 3_0
    0_1, 1_1, 2_1, 3_1, 4_1
           1_2, 2_2, 3_2
                  2_3
         Essentially what is happening here is that the new tile is checking all four coordinates/indexes belonging to each of the five tiles stored in the "selectArr" array as it tries to find a match for one of its own (which it does for the tile at coordinate 2_2). Thus the new tile at coordinate 2_3 would be marked as valid and added to the "selectArr" array as we wait for the next tile to be clicked and validated. Is this correct?

  • How can I create a array with all files from a directory

    How can I create a array of files or varchar with all files from a directory?

    I thought the example could be improved upon. I've posted a solution on my blog that doesn't require writing the directory list to a table. It simply returns it as a nested table of files as a SQL datatype. You can find it here:
    http://maclochlainn.wordpress.com/2008/06/05/how-you-can-read-an-external-directory-list-from-sql/

  • How can I create a variable size array?

    How can I create a variable size array?

    ok then how can i create a new vector object?If you don't know that, you need to go back to your text book and study some more. Or read the tutorial on the basics of Java: http://java.sun.com/docs/books/tutorial/java/index.html
    After reading that you can move on to: http://java.sun.com/docs/books/tutorial/collections/index.html
    Anyway, the answer to your question is, of course:
    Vector v = new Vector();(But you should probably use ArrayList instead of Vector.)

  • How to achieve Multi Dimensional array in Oracle

    Hi,
    Pls give me a solution to achieve the Multi dimensional Array concept in Oracle.
    I've used Nested table concept in which I did not find any Equivalent for the array structure in COBOL given below
    01 customer_record.
    &nbsp&nbsp&nbsp03 telephone_number occurs 3 times.
    &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp05 country_code pic 999.
    &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp05 area_code pic 999.
    &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp05 local_number occurs 2 times.
    &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp08 prefix pic 999.
    &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp08 subscriber_number pic 999.
    Thanks in Advance
    Regds,
    Arkumar

    What about VARRAYs and user defined objects?

  • Populating ADF Table from Multi-Dimensional Array

    Hello!
    I'm trying to populate an ADF table from a multi-dimensional array.
    Let's say that my array is
    String [] [] myArr = new String [3][5].
    On my page backing bean, I have a private attribute called tmpArr like this...
    String [] [] tmpArr;
    ...which I will initialize later after I know the proper dimensions. The dimensions will come from a multimap that contains a key and and another array (for the key's value) containing values for the key. So once I know the dimensions I initialize my array with...
    tmpArr = new String [x][y] where x and y are the dimensions (counters).
    Now I have my multidimension array. On an jsp page I have an ADF table, and I'm setting the value for the table to the array (the table's value property is bound to the backing bean's tmpArr attribure).
    Like so:
    <af:panelForm id="availableOptions"
    binding="#{myBackingBean.availableOptionsValues}">
    <af:table emptyText="No items were found" rows="10"
    value="#{myBackingBean.tmpArr}" var='myArr'>
    Now I need to know how to do the following:
    1) Set the table's columns based on the number of attributes on the array.
    2) Set the table's rows based on the array's length.
    3) Set each table cell value to values on the array's 2nd dimension. I'm assuming that ADF takes care iterating through the array, and that I should do something like...
    <af:outputText value="#{myArr[][0]}"/>
    <af:outputText value="#{myArr[][1]}"/>
    etc...
    However, this isn't working...
    javax.faces.el.ReferenceSyntaxException: myArr[][0]
    ...bla bla bla...
    Was expecting one of:
    <INTEGER_LITERAL> ...
    <FLOATING_POINT_LITERAL> ...
    <STRING_LITERAL> ...
    "true" ...
    "false" ...
    "null" ...
    "not" ...
    "empty" ...
    <IDENTIFIER> ...
    Is there a blog or resource (article, book, etc) that shows how this is done? Anyone has done this and would like to share how?
    Thank you.

    This is in fact possible. I'm not sure about the "best practice" around doing this but there is a couple of ways to do this.
    You can either create a managed bean then right click on it and use the wizard to create a data control or you can do it as per below
    The a table will convert an array into a collection.
    Once you have created an array and generated the accessors in a bean you can then reference the mutli-dimensional array from a table as per below.
    <af:table value="#{pageFlowScope.PageBean.sessionArr}" var="row" rowBandingInterval="0" id="t1" varStatus="status">
    <af:column sortable="false" headerText="col1" id="c1">
    <af:outputText value="#{pageFlowScope.PageBean.sessionArr[status.index][0]}" id="ot1"/>
    </af:column>
    </af:table>
    String [][] sessionArr = new String[5][2];
    public void setSessionArr(String[][] sessionArr) {
    this.sessionArr = sessionArr;
    public String[][] getSessionArr() {
    sessionArr[0][0]="rice";
    sessionArr[1][0]="water";
    return sessionArr;
    EDIT: For either of the above methods the managed bean must have a scope of pageFlow or longer.
    Cheers,
    Aaron
    Edited by: Aaron Rapp on Oct 6, 2011 3:28 PM

  • Multi-dimensional arrays in Cocoa

    Oh, dear. After spending the best part of 12 hours entering 2,000+ elements of a multi-dimensional array into a 'plist', I then start looking on the net for reasons why my C-style code won't compile and read that I can only use single-dimensional arrays?
    WHAT? Arrrrrgghhh! ^#&}@!
    Looking at both array types in a 'plist' they look like:
    // one-dimensional...
    <array>
    <array>
    <string>Aberayron</string>
    </array>
    <array>
    <string>Abergavenny</string>
    </array>
    <array>
    <string>Aberystwyth</string>
    </array>
    </array>
    // ...and multi-dimensional
    <array>
    <array>
    <string>Aberayron</string>
    <string>XXVII</string> // pre-1852 style
    <string>11b</string> // modern style
    </array>
    <array>
    <string>Abergavenny</string>
    <string>XXVI</string>
    <string>11a</string>
    </array>
    <array>
    <string>Aberystwyth</string>
    <string> XXVII </string>
    <string>11b</string>
    </array>
    </array>
    but apparently I can't access the other column elements using say:
    [aTextField setStringValue: [anArray objectAtIndex: [counter][2]]];
    What makes it even more frustrating is that when my app is launched, the runlog quite happily displays the contents of the array as:
    'districts array' returned (
    (Aberayron, XXVII, 11b),
    (Abergavenny, XXVI, 11a),
    (Aberystwyth, XXVII, 11b),
    ....... etc. etc .........
    Can anyone (hopefully) tell me I misread all those 'net posts and suggest a simple way I can access this data using maybe, an offset of bytes in memory please?
    Ernie

    Ernie Thompson wrote:
    Oh sure, with the benefit of hindsight my beginners example had serious Cocoa syntax errors, but what was so wrong with the underlying idea on which my question was based?
    There wasn't anything "wrong", it was just in the wrong context. I'll explain...
    I am mindful of the efforts good people like yourself put into helping us 'newbies' here, and rather than waste your collective times posting every trivial question that we ourselves could solve in a few short minutes with an internet search, I spend a considerable amount of time doing just exactly that before I post. However, I constantly come across statements like:
    ...Since Obj-C, like C++, is a superset of C (and basically IS C...)... It's actually one of the
    major annoyances (to me anyway) of working in pure Obj-C code on this project: there is no direct
    support for multi-dimensional arrays... etc. etc..
    I completely understand your confusion. The Internet is stuffed full of information of all kinds. Not all of it is correct information, however. I'm not even sure the majority is correct.
    and that is just a tiny cross-section of comments. As I found myself doing on at least one previous occasion, I once again apologise for having been misled, Quite clearly, with arrays being supported in Obj-C (as you have demonstrated) -- while at the same time not being supported , and Obj-C being C -- while also not being C, learning Cocoa is clearly going to take a little more time than I initially anticipated.
    OK, I'll explain. Objective-C is a superset of C. Anything you can do in C, you can do in Objective-C. You can certainly create and use multidimensional arrays in Objective-C exactly how you wanted to originally. But that kind of array is a C array, such as:
    int arr[512];
    or
    double * matrix = malloc(sizeof(double) * 32 * 32);
    An "NSArray" is an entirely different thing. It is not a C array, it is an Objective-C object. Any time you have bracket characters, you are dealing with Objective-C objects. They have no built-in syntax other than:
    [receiver message: arg param2: arg2 param3: arg3 ... paramN: argN];
    If you really want to get confused, you could look at C++ or even Objective-C++. There, you can have arrays that really are arrays but are objects too. On second thought, you probably don't want to do that
    PS: Don't worry about wasting my time. I only post here so I can clear my mind from whatever I'm working on and give my subconscious an opportunity to find a fix for all the screw-ups I've done in my code.
    Message was edited by: etresoft

  • Setting up a multi dimensional array of objects

    Hey ya'll. How would i setup a multi dimensional array with this structure?
    TypeSave(Title, material(name, quantity))
    TypeSave[1](Lego Shop, material[1](Lego Blocks, 100))
                   material[2](Roof, 1))
    TypeSave[2](Lego Car, material[1](Door, 2))
              material[2](Gravy, 3, ounces))
    TypeSave will be saved as a serialised object to a file so i can load everything within it and keep the structures integrity.
    I'll have an add button that will add the name and quantity to the next empty position of "material" array. This will then be listed in a list box and allow me to save all the materials with a title to the TypeSave list in the next empty position.
    I'm getting mightily confused how to set up the classes and the array structure :(
    Any help would be greatly appreciated!

    private TypeSave t = new TypeSave();
    private void btnSaveItemActionPerformed(java.awt.event.ActionEvent evt) {                                             
            t.addItem(txtItemTitle.getText(), new Material(txtMaterialName.getText(),txtQuantity.getText()));
            t.saveToFile();
         * @param args the command line arguments
        public static void main(String args[]) {
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    new MainForm().setVisible(true);
        class Material implements Serializable {
         String name = null;
         String quantity = null;
         //To restrict default constructor
         private Material() {
         public Material(String name, String quantity) {
              this.name = name;
              this.quantity = quantity;
         public String getName() {
              return this.name;
         public String getQuantity() {
              return this.quantity;
         public String toString() {
              return "Name : " + this.name + "Quantity : " + this.quantity;
    class TypeSave implements Serializable {
         private Hashtable items = null;
         public TypeSave() {
              items = new Hashtable();
         public void addItem(String title,Material material) {
              ArrayList materials = (ArrayList) items.get(title);
              if(materials == null) {
                   materials = new ArrayList();
                   items.put(title,materials);
              materials.add(material);
         public Hashtable getItems() {
              return this.items;
         public ArrayList getItem(String title) {
              return (ArrayList)this.items.get(title);
            void saveToFile() {
        ObjectOutputStream oos = null;
            try
            oos = new ObjectOutputStream(new FileOutputStream("item.ser"));
            catch (IOException i)
              System.out.println( "Error opening file");
          try
            oos.writeObject(items);
            catch (IOException o)
                System.out.println("Error writing file");
          try
              if(oos != null)
              oos.close();
            catch (IOException x)
                System.out.println("Error closing file");
    }My save class was working, but i tried to merge it to test this code structure and now it's failing with excepion:
    "Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException"
    any ideas?

  • Binding arraylist, list, or multi-dimensional array to table in web dynpro

    Greetings,
    I like to ask if anyone knows how to bind data from an arraylist, list, or multi-dimensional array list to a table in web dynpro, your help is much appreciated.
    Thanks in advance.
    Cory

    Is there a way to create or cast a multi-dimensional
    array from a Collection or Vector ?
    ArrayList list = new ArrayList();
    list.add( new Object[4] );
    Object[] array2 = list.toArray(); // is only
    single dimension !
    Of course it is a single dimension array.
    Check the definition of the toArray() function, and the specification of arrays in general.
    toArray() returns a one dimensional array.
    In your case it will return an array of arrays. So array2[0] will be an array of 4 objects.
    That just happens to be a 2 dimensional array though you may (I haven't checked it) need some parentheses to call the elements.
    Try Object o = array2[0][1]; and if that doesn't work Object o = (array2[0])[1];

Maybe you are looking for