Using JTextField as an array.

Hi I would like some help with createing a JTextField array. I cant seem to find anything wrong with my code but it keeps giving me an Error.
Error Message: java.lang.ArrayIndexOutOfBoundsException
This is what my code looks like.
//Declare Component
JTextField Length[];
for(int i = 0; i < 5; i++)
Length[i] = new JTextField("", 5);
c.gridx = i;
c.gridy = 0;
panMiddle.add(Length, c);
Please let me know what im doing wrong.

You seem to have several things in error. Here is one way to do this. It creates an array of 4 JTextFields. A frequent beginner's mistake is to initialize the array but to forget to initialize the individual items, something that must be done if the items are objects (i.e., are not primative types such as int).
public class MyClass extends JPanel
    private JTextField[] textFieldArray = new JTextField[4]; //array declared and initialized
    public MyClass()
        for (int i = 0; i < textFieldArray.length; i++)
            textFieldArray[i] = new JTextField(12); //init each array item here
            panMiddle.add(textFieldArray); // add it to my form here.
Message was edited by:
petes1234

Similar Messages

  • How can I use two single-dimensional arrays-one for the titles and array

    I want to Use two single-dimensional arrays-one for the titles and one for the ID
    Could everyone help me how can i write the code for it?
    Flower
    public class Video
    public static void main(String[] args) throws Exception
    int[][] ID =
    { {145,147,148},
    {146,149, 150} };
    String[][] Titles=
    { {"Barney","True Grit","The night before Christmas"},
    {"Lalla", "Jacke Chan", "Metal"} };
    int x, y;
    int r, c;
    System.out.println("List before Sort");
    for(c =0; c< 3; ++c)
    for(r=0; r< 3; ++ r)
    System.out.println("ID:" + ID[c][r]+ "\tTitle: " + Titles[c][r]);
    System.out.println("\nAfter Sort:");
    for(c =0; c< 3; ++c)
    for(r=0; r< 3; ++ r)
    System.out.println("ID:" + ID[c][r]+ "\tTitle: " + Titles[c][r]);

    This is one of the most bizarre questions I have seen here:
    public class Video
    public static void main(String[] args) throws Exception
    int[] ID = {145,147,148, 146,149, 150};
    String[] Titles= {"Barney","True Grit","The night before Christmas", "Lalla", "Jacke Chan", "Metal"};
    System.out.println("List before Sort");
    for(int i = 0; i < Titles.length; i++)
       System.out.println("ID:" + ID[i]+ "\tTitle: " + Titles);
    System.out.println("\nAfter Sort:");
    for(int i = 0; c < Titles.length; i++)
    System.out.println("ID:" + ID[i]+ "\tTitle: " + Titles[i]);
    Generally you don't use prefix (++c) operators in you for loop. Use postfix (c++).
    Prefix means that it will increment the variable before the loop body is executed. Postfix will cause it to increment after.

  • Use of multi-dimensional arrays in forms - forms debugger crash

    Hello All readers,
    have an issue with use of multi-dimensional arrays in forms when debugging and/or calling another form post array-population.
    USING VERSIONS: oracle forms 9.0.4, Jinitiator 1.3.1.17, oracle db 10.1
    the following code snippet works from a when-button-pressed trigger when called without the debugger. when called with the debugger it crashes when any element of the multi-dimensional associative array is accessed/populated/read. In addition, if i populate the multi-dimensional array then call a form (a msgbox form to display the arrays content as a string) it crashes too.
    declare
    type datasource_rec is record (field varchar2(32), val varchar2(3999));
    type datasource_arr is table of datasource_rec index by binary_integer;
    type datasource_arr_arr is table of datasource_arr index by binary_integer;
         l_arr datasource_arr_arr;
         procedure poparr(i_arr out datasource_arr_arr) is
              idx binary_integer := 1;
              iidx binary_integer := 1;
         begin
              while (idx <= 10) loop
                   iidx := 1;
                   while (iidx <= 10) loop     
                        i_arr(idx)(iidx).field := 'field'||to_char(iidx)||':'||to_char(idx); --# debugger crashes here with JVM aborting... message (which crashes forms builder too)
    i_arr(idx)(iidx).val := 'test value';
                   iidx := iidx+1;     
                   end loop;
              idx := idx+1;
              end loop;
         end;
         procedure printarr is
              idx binary_integer := l_arr.first;
              iidx binary_integer;
              l_msg varchar2(4000);
              l_response pls_integer;
         begin
              while (idx is NOT null) loop
                   iidx := l_arr(idx).first;
                   while (iidx is NOT null) loop
                        l_msg := l_msg||chr(10)||l_arr(iidx)(idx).field||' = '||l_arr(iidx)(idx).val;
                   iidx := l_arr(idx).next(iidx);
                   end loop;
              idx := l_arr.next(idx);
              end loop;
              alerts.info('see console for full printout: '||chr(10)||l_msg);
    --l_response := msgbox.show(l_msg); --calls another modal form to display a long message, which crashes the runtime with a java console message*
         r$debug.print(l_msg);
         end;
    begin
         poparr(l_arr);
         printarr;
    end;
    The java console does not print anything useful when both forms builder and the runtime crash/hangs as a result of the debugger being attached (except displaying a "JVM aborting" message) but when the runtime alone crashes as a result of calling another form after popping the MD array it prints:
    oracle.forms.net.ConnectionException: Forms session <28> aborted: unable to communicate with runtime process.
         at oracle.forms.net.ConnectionException.createConnectionException(Unknown Source)
         at oracle.forms.net.HTTPNStream.getResponse(Unknown Source)
         at oracle.forms.net.HTTPNStream.doFlush(Unknown Source)
         at oracle.forms.net.HTTPNStream.flush(Unknown Source)
         at java.io.DataOutputStream.flush(Unknown Source)
         at oracle.forms.net.StreamMessageWriter.run(Unknown Source)
    has anyone else encountered this problem and found a solution/workaround? is their some sort of memory limitation for forms-side handling of (multi-dimensional) arrays?+
    many thanks
    ps: i get similar problems when a) populating the array from a server/db-side packaged procedure (crashes with java console message as above even when not debugging) b) using server/db-side packaged types for the array.

    Hello All readers,
    have an issue with use of multi-dimensional arrays in forms when debugging and/or calling another form post array-population.
    USING VERSIONS: oracle forms 9.0.4, Jinitiator 1.3.1.17, oracle db 10.1
    the following code snippet works from a when-button-pressed trigger when called without the debugger. when called with the debugger it crashes when any element of the multi-dimensional associative array is accessed/populated/read. In addition, if i populate the multi-dimensional array then call a form (a msgbox form to display the arrays content as a string) it crashes too.
    declare
    type datasource_rec is record (field varchar2(32), val varchar2(3999));
    type datasource_arr is table of datasource_rec index by binary_integer;
    type datasource_arr_arr is table of datasource_arr index by binary_integer;
         l_arr datasource_arr_arr;
         procedure poparr(i_arr out datasource_arr_arr) is
              idx binary_integer := 1;
              iidx binary_integer := 1;
         begin
              while (idx <= 10) loop
                   iidx := 1;
                   while (iidx <= 10) loop     
                        i_arr(idx)(iidx).field := 'field'||to_char(iidx)||':'||to_char(idx); --# debugger crashes here with JVM aborting... message (which crashes forms builder too)
    i_arr(idx)(iidx).val := 'test value';
                   iidx := iidx+1;     
                   end loop;
              idx := idx+1;
              end loop;
         end;
         procedure printarr is
              idx binary_integer := l_arr.first;
              iidx binary_integer;
              l_msg varchar2(4000);
              l_response pls_integer;
         begin
              while (idx is NOT null) loop
                   iidx := l_arr(idx).first;
                   while (iidx is NOT null) loop
                        l_msg := l_msg||chr(10)||l_arr(iidx)(idx).field||' = '||l_arr(iidx)(idx).val;
                   iidx := l_arr(idx).next(iidx);
                   end loop;
              idx := l_arr.next(idx);
              end loop;
              alerts.info('see console for full printout: '||chr(10)||l_msg);
    --l_response := msgbox.show(l_msg); --calls another modal form to display a long message, which crashes the runtime with a java console message*
         r$debug.print(l_msg);
         end;
    begin
         poparr(l_arr);
         printarr;
    end;
    The java console does not print anything useful when both forms builder and the runtime crash/hangs as a result of the debugger being attached (except displaying a "JVM aborting" message) but when the runtime alone crashes as a result of calling another form after popping the MD array it prints:
    oracle.forms.net.ConnectionException: Forms session <28> aborted: unable to communicate with runtime process.
         at oracle.forms.net.ConnectionException.createConnectionException(Unknown Source)
         at oracle.forms.net.HTTPNStream.getResponse(Unknown Source)
         at oracle.forms.net.HTTPNStream.doFlush(Unknown Source)
         at oracle.forms.net.HTTPNStream.flush(Unknown Source)
         at java.io.DataOutputStream.flush(Unknown Source)
         at oracle.forms.net.StreamMessageWriter.run(Unknown Source)
    has anyone else encountered this problem and found a solution/workaround? is their some sort of memory limitation for forms-side handling of (multi-dimensional) arrays?+
    many thanks
    ps: i get similar problems when a) populating the array from a server/db-side packaged procedure (crashes with java console message as above even when not debugging) b) using server/db-side packaged types for the array.

  • Using ArrayDescriptor for long array

    I have a array of long for example long[] a.
    I want to use preparedStatement to set array
    i.e prepareStatemt.setArray(1, arrayOflong);
    How will i use oracle ArrayDescriptor to get arrayOflong parameter for my prepareStatement i read the JDBC session on oracle site but i don't understand as i am database expert.

    Keep the computer plugged in whenever possible.
    If you keep the computer always plugged in, make sure that twice a month
    run it on battery until battery level drops to about 50-40%.
    Maximize Runtime / Tips for maximizing your battery charge
    http://support.apple.com/kb/HT1446
    More about batteries:
    http://www.apple.com/batteries/notebooks.html

  • From JTextField into string array

    hello,
    Me and my friend are currently doing a cryptography project for UNI. We are required to read in a word from the JTextField into an array. the problem is the whole word seems to be going into the array as one element. Is there any way to read in each letter in the word into a seperate element of the array??

    Well you can always read the value in the textfield, convert it to a character array and then as you transfer each character to your string array you add a blank string to it, so then it becomes a string.
    Example:
    String sentence = "hello, I am a really loooooooooong string";
    String[] stringArray = new String[sentence.length()];
    char[] charArray = sentence.toCharArray();
    for (int count = 0; count < sentence.length(); count++)
         stringArray[count] = charArray[count] + "";I hope this helps.

  • How to use a Time - Voltage Array to Control a Analog Voltage Output using DAQmx Write VI

    I have an array of Time values associate with Voltage values that I want to use to control a Anolog Votage Out Device (PXI-6251) using DAQmx.  The array contains 1,000 elements.  The time values are NOT evenly spaced, the rate changes through the array.  The array is output once, timed to other processes.
    My problem is I haven't been able to locate a reference on how to handle the timing variability in the array.  If time was equally spaced I could use a loop....
    The attached showes the array, first row is time (ms) and the second row is voltage (volts).
    Can someone point me in the right direction?
    David
    Attachments:
    TimeVoltage.png ‏11 KB

    David,
    if you have only Base version of LabVIEW, this will be a time consuming task.
    If you have either Full or Professional, you will find interpolation-functions in the mathematic palette.
    I am not sure which ones serves you best,  but i'd startexperimenting with Interpolate 2D.
    hope this helps,
    Norbert 
    [Edit]: You could also use a polynominal fit on your voltage values. You will get a function describing the voltage over time. But you will have to modify this function to take care of the variation of time spacing. If you have a function describing your voltage over your (nonconstant) timestamps, you can simply create values for constant timeslices for your voltage.
    Message Edited by Norbert B on 11-06-2008 10:21 AM
    CEO: What exactly is stopping us from doing this?
    Expert: Geometry
    Marketing Manager: Just ignore it.

  • Using Event Structures with Array of Clusters

    Using LabVIEW 8.5
    Hi all,
    I'm trying to convert an existing application to one that can be used
    through a touch screen. I updated the UI and added an event structure
    to listen for mouse ups on controls that require a HMI keyboard or
    numpad to show up. Although I've been programming for a while, I'm new
    to LabVIEW and am struggling with a problem:
    Is there any way to have an event case listen to an event within
    arrays? I've seen a few examples on the forums, but they all start with
    breaking up the arrays into individual variables. Using the variables,
    they build arrays. This seems pretty tedious, and I'm pretty sure I
    can't apply it to one of my arrays. Essentially, I just want to know
    which cluster in which array the user has clicked on, so I can open the
    HMI keyboard or numpad and send the text to that cluster. In my watered down app (Array of Clusters.vi), I've put 3 arrays of clusters and a few stand-alone controls to give you guys an idea of what I'm taking about.
    BTW, I'm using the HMI Keyboard and Numpad built by the Beta Community (http://decibel.ni.com/content/docs/DOC-1062) and modified it to add a "Clear" button to the keyboard and numpad. Please let me know if I implemented this in the best way.
    Thanks for the help,
    Kunal
    Message Edited by bhatiak on 08-04-2008 03:55 PM
    Attachments:
    Array of Clusters4.llb ‏274 KB

    My old tic tac toe example shows how to determine which square of a 2D array has been clicked.
    http://forums.ni.com/ni/board/message?board.id=170&view=by_date_ascending&message.id=247044#M247044
    You probably can adapt some of it for the arrays on the right. If the array can be scrolled, you also need to account for the "indexvals" offset.
    The Layers controls is easiest, because you only show one element. Just read the "index vals" property to get the array element and parse the coordinates to get the cluster element.
    btw: the small while loop on the right serves no purpose at all and acts just as a CPU burner. You can delete it without any change in functionality. Is there anything else to it?
    LabVIEW Champion . Do more with less code and in less time .

  • How can I use a 1 double array for this

    I would like to use one double array where I am using 2 single arrays, can this be done?
    thanks
    import java.text.NumberFormat;
    import java.util.Locale;
    class Mortgage3
              public static void main(String[]argv)
              //Variables
              //allows for currency format
              NumberFormat formatter = NumberFormat.getCurrencyInstance(Locale.US);
              double prin;                              
              double month_payments;
              double monthlyinterest;   
                    //standard integer
              int months;     
                    //array for the different interest rates
                    double[] interest = {0.0535,0.055,0.0575};
              //array for the different terms
                    int[] term = {7, 15, 30};
                    for (int i = 0; i < 3; i++)
              //values for the variables
              prin = 200000;        //principle amount of the mortgage
                    monthlyinterest = (interest[i] / 12);          //monthly interest
              months = (term[i] * 12);               //total amount of months in the 30 yr term
              //monthly payment calculation
              month_payments = (prin * monthlyinterest) / (1-Math.pow(1 + monthlyinterest, - months));           
              System.out.println("\n\n\t For a loan amount of " + formatter.format(prin));
              System.out.println("\t With an annual interest rate of " +interest[i] * 100+ "%,");
              System.out.println("\t your payments will be " +formatter.format(month_payments)+ " per month");
                    System.out.println("\t for a term of "+term[i]+ " years or " +months+" months.");
    }

    I would like to use one double array where I am using 2 single arrays, can this be done?It can, but why not write a Rate class or other data structure more suited to the purpose?

  • XI/PI: jdbc receiver using stored procedure with arrays

    The company needs an interface to search for header data and detail to a legacy system.
    This interface from ERP  to legacy system is synchronous and uses stored procedure.
    The definition of the stored procedure is as follows:
    PROCEDURE
    Generar_Detalle_Vtas_Pagadas
        (p_cvendedor                 IN bdc_vendedores.cvendedor%TYPE,
        p_fdesde                   IN DATE,
        p_fhasta                     IN DATE,
        v_encabezado_ct           OUT encabezado_ct,
        v_detalle_vtas_pagadas_ct OUT detalle_vtas_pagadas_ct,
        err_num                 OUT NUMBER
    Data types used in stored procedure:
    TYPE encabezado_ct AS OBJECT
    ( CREGION         NUMBER(22),
      XREGION         VARCHAR2(50),
      CMERCADO        NUMBER(22),
      XMERCADO        VARCHAR2(50),
      CTVENDEDOR      VARCHAR2(5),
      XCTVENDEDOR     VARCHAR2(50),
      XDENOMINACION   VARCHAR2(15))
    TYPE detalle_vtas_pagadas_ct AS OBJECT
    (     CITEM           VARCHAR2(10),
          XIDENTIFICADOR  VARCHAR2(15),
          XCONTRATO       VARCHAR2(15),
          XVALOR          VARCHAR2(30),
          CCUENTA         VARCHAR2(15),
          FACTIVACION     DATE,
          XDOMINIO        VARCHAR2(30),
          CCED            VARCHAR2(20),
          XCLIENTE        VARCHAR2(161),
          CCPO            VARCHAR2(60) )
    As shown, this has three input parameters varchar and date respectively and has three output parameters, two of which are defined with a data
    type such as table and the other number.
    The problem is to define the signature of the stored procedure in XI when defining the data type request, the message type and mapping system
    legacy because the data type is not supported (tables: detalle_vtas_pagadas_ct,encabezado_ct  )

    FORM 2:
    defined as an array, but the error tells me that we need to define the attribute either input or output
    <?xml version="1.0" encoding="UTF-8"?>
         <ns0:MT_VtasPagadas_VYC xmlns:ns0="urn:VentasPagadas:VE_ALTASDEDCALIDAD_SD_VYC">
          <VtasPagadasRequest><Generar_Detalle_Vtas_Pagadas action="EXECUTE">
             <table>vyc.Vyc_Pack_Reportes_Sap.Generar_Detalle_Vtas_Pagadas</table>
             <p_cvendedor type="VARCHAR"></p_cvendedor>
             <p_fdesde type="DATE"></p_fdesde>
             <p_fhasta type="DATE"></p_fhasta>
             <v_encabezado_ct>
                 <CREGION isOutput="1" type="NUMERIC">X</CREGION>
                 <XREGION isOutput="1" type="VARCHAR">X</XREGION>
                 <CMERCADO isOutput="1" type="NUMERIC">X</CMERCADO>
                 <XMERCADO isOutput="1" type="VARCHAR">X</XMERCADO>
                 <CTVENDEDOR isOutput="1" type="VARCHAR">X</CTVENDEDOR>
                 <XCTVENDEDOR isOutput="1" type="VARCHAR">X</XCTVENDEDOR>
                 <XDENOMINACION isOutput="1" type="VARCHAR">X</XDENOMINACION>
            </v_encabezado_ct>
            <v_detalle_vtas_pagadas_ct>
                 <CITEM isOutput="1" type="VARCHAR">X</CITEM>
                 <XIDENTIFICADOR isOutput="1" type="VARCHAR">X</XIDENTIFICADOR>
                 <XCONTRATO isOutput="1" type="VARCHAR">X</XCONTRATO>
                 <XVALOR type="VARCHAR">X</XVALOR>
                 <CCUENTA isOutput="1" type="VARCHAR">X</CCUENTA>
                 <FACTIVACION isOutput="1" type="DATE">X</FACTIVACION>
                 <ICTA isOutput="1" type="VARCHAR">X</ICTA>
                 <CCED isOutput="1" type="VARCHAR">X</CCED>
                 <XCLIENTE isOutput="1" type="VARCHAR">X</XCLIENTE>
                 <CCPO isOutput="1" type="VARCHAR">X</CCPO>
            </v_detalle_vtas_pagadas_ct>
            <err_num isOutput="1" type="NUMERIC">X</err_num>
         </Generar_Detalle_Vtas_Pagadas>
      </VtasPagadasRequest></ns0:MT_VtasPagadas_VYC>
    Edited by: ymonasterio on Mar 31, 2010 4:48 PM

  • Use column in 2d array as page number for 3d array

    I have a 2D array coming from a database containing (I simplify a bit for this example)
    column 0: plot number
    column 1: x values
    column 2: corresponding y values
    to be able to process everything and later put it in a graph, i would like to convert it into a 3d array where the page number is the plot number (so column 0) from my original array. I tried two different approaches you can see in the attachment, both give unwanted results:
    1. the resulting array contains two pages with only x2 and y2 for each plot
    2. the resulting array contains two pages with only x1 and y1 for each plot
    What am i doing wrong here?
    As a second difficulty the order in the example 2d array is logical (x1 of plot 1, x1 of plot 2, x2 of plot1.....) .
    The order in the actual array might just as well be as the example in the second attachment
    Thanks!
    Attachments:
    bad order.PNG ‏2 KB
    Move column to page.PNG ‏18 KB

    Attached (LV 8.0) is something I quickly whipped up using the above 2 assumptions as being true. I did not fully test this, so be sure to put it through its paces.
    Your solutions centered on using Insert Into Array. The reason this won't work is because your first x/y pair could be from plot 1 (the second page). But, you cannot insert a second page into an empty array.  I opted for pre-creating the 3D array and then using Replace Array Subset. 
    OK, I posted this before I got the notification that you answered my questions. Given that, then how is one supposed to know the order of the X/Y pairs? Obviously, your example used strings for demonstration. Presumably the real values will be numbers. In this case, how is one supposed to know where to place the new X/Y pair?
    Corollary: Arrays must be rectangular. This means that if plot 0 has 3 XY pairs, but plot 1 has 5, then the 3D array MUST have 5 rows for each page. This means you will have empty rows on page 0. Given this, you are better off creating an array of clusters. Each cluster would contain your XY pairs as a 2D array, and each one can have different number of rows, as shown in this figure:
    Message Edited by smercurio_fc on 03-11-2009 10:43 AM
    Attachments:
    2D Array to 3D Array.vi ‏17 KB
    Example_VI_FP.png ‏5 KB

  • Use of args with array

    Hello,
    Pls can anyone tell me what this particualr line in the program below means:
    double earthWeight = Double.parseDouble(args[0]);
    The code is within the main method. Does it mean that every argument that is passed to the main method should be parsed as Double or what? Also why the use of array? I mean the (args [0]) stuff?
    Please any help will be hugely appreciated. Thank u in advance.
    The full program is below.
    public enum Planet {
    MERCURY (3.303e+23, 2.4397e6),
    VENUS (4.869e+24, 6.0518e6),
    EARTH (5.976e+24, 6.37814e6),
    MARS (6.421e+23, 3.3972e6),
    JUPITER (1.9e+27, 7.1492e7),
    SATURN (5.688e+26, 6.0268e7),
    URANUS (8.686e+25, 2.5559e7),
    NEPTUNE (1.024e+26, 2.4746e7),
    PLUTO (1.27e+22, 1.137e6);
    private final double mass; // in kilograms
    private final double radius; // in meters
    Planet(double mass, double radius) {
    this.mass = mass;
    this.radius = radius;
    private double mass() { return mass; }
    private double radius() { return radius; }
    // universal gravitational constant (m3 kg-1 s-2)
    public static final double G = 6.67300E-11;
    double surfaceGravity() {
    return G * mass / (radius * radius);
    double surfaceWeight(double otherMass) {
    return otherMass * surfaceGravity();
    public static void main(String[] args) {
    double earthWeight = Double.parseDouble(args[0]);
    double mass = earthWeight/EARTH.surfaceGravity();
    for (Planet p : Planet.values())
    System.out.printf("Your weight on %s is %f%n",
    p, p.surfaceWeight(mass));
    Petite

    Hello,
    Pls can anyone tell me what this particualr line in
    the program below means:
    double earthWeight = Double.parseDouble(args[0]);
    Does it mean that every argument that is passed to the main method
    should be parsed as Double or what? Also why the use
    of array? I mean the (args [0]) stuff? Not quite. The first element in the args array will be parsed into a Double. The args array holds the values of the command-line arguements that are supplied during runtime of an application.
    java Planet 234234.967
    that fills args[0] with that number as a String. Then when the main method executes it parses that value as a Double and assigns it to earthWeight (NOTE: I made that number up. It isn't Earth's weight -.-)

  • Binary search tree in java using a 2-d array

    Good day, i have been wrestling with this here question.
    i think it does not get any harder than this. What i have done so far is shown at the bottom.
    We want to use both Binary Search Tree and Single Linked lists data structures to store a text. Chaining
    techniques are used to store the lines of the text in which a word appears. Each node of the binary search
    tree contains four fields :
    (i) Word
    (ii) A pointer pointing to all the lines word appears in
    (iii) A pointer pointing to the subtree(left) containing all the words that appears in the text and are
    predecessors of word in lexicographic order.
    (iv) A pointer pointing to the subtree(right) containing all the words that appears in the text and are
    successors of word in lexicographic order.
    Given the following incomplete Java classes BinSrchTreeWordNode, TreeText, you are asked to complete
    three methods, InsertionBinSrchTree, CreateBinSrchTree and LinesWordInBinSrchTree. For
    simplicity we assume that the text is stored in a 2D array, a row of the array represents a line of the text.
    Each element in the single linked list is represented by a LineNode that contains a field Line which represents a line in which the word appears, a field next which contains the address of a LineNode representing the next line in which the word appears.
    public class TreeText{
    BinSrchTreeWordNode RootText = null;// pointer to the root of the tree
    String TextID; // Text Identification
    TreeText(String tID){TextID = tID;}
    void CreateBinSrchTree (TEXT text){...}
    void LinesWordInBinSrchTree(BinSrchTreeWordNode Node){...}
    public static void main(String[] args)
    TEXT univ = new TEXT(6,4);
    univ.textcont[0][0] = "Ukzn"; univ.textcont[0][1] ="Uct";
    univ.textcont[0][2] ="Wits";univ.textcont[0][3] ="Rhodes";
    univ.textcont[1][0] = "stellenbosch";
    univ.textcont[1][1] ="FreeState";
    univ.textcont[1][2] ="Johannesburg";
    univ.textcont[1][3] = "Pretoria" ;
    univ.textcont[2][0] ="Zululand";univ.textcont[2][1] ="NorthWest";
    univ.textcont[2][2] ="Limpopo";univ.textcont[2][3] ="Wsu";
    univ.textcont[3][0] ="NorthWest";univ.textcont[3][1] ="Limpopo";
    univ.textcont[3][2] ="Uct";univ.textcont[3][3] ="Ukzn";
    univ.textcont[4][0] ="Mit";univ.textcont[4][1] ="Havard";
    univ.textcont[4][2] ="Michigan";univ.textcont[4][3] ="Juissieu";
    univ.textcont[5][0] ="Cut";univ.textcont[5][1] ="Nmmu";
    univ.textcont[5][2] ="ManTech";univ.textcont[5][3] ="Oxford";
    // create a binary search tree (universities)
    // and insert words of text univ in it
    TreeText universities = new TreeText("Universities");
    universities.CreateBinSrchTree(univ);
    // List words Universities trees with their lines of appearance
    System.out.println();
    System.out.println(universities.TextID);
    System.out.println();
    universities.LinesWordInBinSrchTree(universities.RootText);
    public class BinSrchTreeWordNode {
    BinSrchTreeWordNode LeftTree = null; // precedent words
    String word;
    LineNode NextLineNode = null; // next line in
    // which word appears
    BinSrchTreeWordNode RightTree = null; // following words
    BinSrchTreeWordNode(String WordValue)
    {word = WordValue;} // creates a new node
    BinSrchTreeWordNode InsertionBinSrchTree
    (String w, int line, BinSrchTreeWordNode bst)
    public class LineNode{
    int Line; // line in which the word appears
    LineNode next = null;
    public class TEXT{
    int NBRLINES ; // number of lines
    int NBRCOLS; // number of columns
    String [][] textcont; // text content
    TEXT(int nl, int nc){textcont = new String[nl][nc];}
    The method InsertionBinSrchTree inserts a word (w) in the Binary search tree. The method Create-
    BinSrchTree creates a binary search tree by repeated calls to InsertionBinSrchTree to insert elements
    of text. The method LinesWordInBinSrchTree traverses the Binary search tree inorder and displays the
    words with the lines in which each appears.
    >>>>>>>>>>>>>>>>>>>>>>
    //InsertionBinTree is of type BinSearchTreeWordNode
    BinSrchTreeWordNode InsertionBinSrchTree(String w, int line,                                             BinSrchTreeWordNode bst)
    //First a check must be made to make sure that we are not trying to //insert a word into an empty tree. If tree is empty we just create a //new node.
         If (bst == NULL)
                   System.out.println(“Tree was empty”)
         For (int rows =0; rows <= 6; rows++)
                   For (int cols = 0; cols <= 4; cols++)
                        Textcont[i][j] = w

    What is the purpose of this thread? You are yet to ask a question... Such a waste of time...
    For future reference use CODE TAGS when posting code in a thread.
    But again have a think about how to convey a question to others instead of blabbering on about nothing.
    i think it does not get any harder than this.What is so difficult to understand. Google an implementation of a binary tree using a single array. Then you can integrate this into the required 2-dimension array for your linked list implemented as an array in your 2-d array.
    Mel

  • Using a function and array to remove stage instances

    I'm trying to figure out the best way to handle this.
    I have an array of items I want to be looked through and removed if a specific function is running and if the stage contains them.
    removalArray = [axScene, bridgeScene];
    public function Removal(event:Event) {
                trace("cheese");
                for (var i:uint = 0; i>removalArray.length; i++) {
                    if (stage.contains(removalArray[i])) {
                        removeChild(removalArray[i]);
                        removeEventListener(Event.ENTER_FRAME, Removal);
                        addEventListener(Event.ENTER_FRAME, CampScene);
                    } else {
                        removeEventListener(Event.ENTER_FRAME, Removal);
                        addEventListener(Event.ENTER_FRAME, CampScene);/**/
    addEventListener(Event.ENTER_FRAME, Removal);
    I'm able to get trace("cheese"); to work at its current position, but the function does not seem to like my "for" and "if" statements because putting trace("cheese") amongst them does not work.
    As always, help is appreciated, and let me know if you need more info.
    EDIT: Perhaps I should also note I am able to get
    if (stage.contains(axScene)) {
                    removeChild(axScene);
                    } else if (stage.contains(bridgeScene)) {
                        removeChild(bridgeScene);
                        } else {
                            null;
    to work correctly in that function.
    EDIT2: Would this have something to do with addChild only being able to remove one instance at a time? I can't imagine that's it since this suppose to be run through a loop.

    You appear to have an unhealthy obsession with using the ENTER_FRAME event. 
    I'm sure you're right, but realize that I'm learning by the seat of my pants and am not great with logic and stuff that doesn't happen chronological. (I'm 26, and graduated with a degree in graphic design.) If I find something that works I'm going to keep using that until I find a better way, and thus far ENTER_FRAME has been all I've had. (I can find tons of AS3 information online, but a lot of it is forum posts seems to be lacking useful context for my purposes.)
    For what it's worth (if you remember another post I did that had a ton of event listeners), I've started using more booleans and gotten rid of a lot of listeners adding and removing.
    What you might try doing instead of creating all manners of them is to have just one and within that one you manage your objects using conditionals.
    So something like this?
    if (campSceneOnStage == true) {
         addChild(campScene)
         } else if (campSceneOnStage == false) {
              removeChild(campScene);
    EDIT: Although this would keep adding a campScene instance, wouldn't it?
    EDIT2: Could I write something like this, have one constant event listener (addEventListener(Event.ENTER_FRAME, Scenes)...
    public function Scenes(event:Event) {
                if (campSceneOn == true) {
                    addChild(campScene);
                    if (stage.contains(campScene)) {
    and use a line to tell the function to temporarily stop listening if campSceneOn = true and campScene is on the stage?
    Would "null" work?
    Also, is there an equivalent to "stage.contains" that looks to see if the stage does not contain?
    That ENTER_FRAME listener is being removed as fast as it was added, whether or not there is something in the array to remove.
    So the even though the intention is to only have the removeEventListener only occur if something is found in the array to remove, the script "skips over" that and removes the event listener even if it doesn't "use" the for loop or if statements?

  • How can I use JTextField as JTable cell editor while using AbstractTableMod

    I use this code but can not edit field
    import javax.swing.table.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.awt.*;
    import javax.swing.text.*;
    public class Main extends JFrame {
    JTable table;
    MyTableModel tableModel;
    public Main() {
    super("Colored JTable Demonstration");
    tableModel = new MyTableModel(10, 5);
    table = new JTable(tableModel);
    DefaultTableCellRenderer colorRenderer = new DefaultTableCellRenderer() {
    public void setValue(Object value) {
    if (value instanceof ColoredItem) {
    Color fcolor = ((ColoredItem) value).getForeground();
    Color bcolor = ((ColoredItem) value).getBackground();
    this.setForeground(fcolor);
    this.setBackground(bcolor);
    setText(((ColoredItem) value).getValue());
    table.setDefaultRenderer(Object.class, colorRenderer);
    //table.setDefaultEditor(Object.class, new DefaultCellEditor(new JTextField()));
    //Set up real input validation for the integer column.
    TableCellEditor editor = new DefaultCellEditor(new JTextField()) {
    public Component getTableCellEditorComponent(JTable table,
    Object value, boolean isSelected, int row, int column) {
    super.getTableCellEditorComponent(table, value, isSelected,row, column);
    JTextField myField = (JTextField) getComponent();
    //myField.setDocument(new ValidDocument());
    return myField;
    //if(value==null) return null;
    //return null;
    int numbercolumn = table.getColumnCount();
    for(int i = 0; i< numbercolumn ; i++){
    table.getColumnModel().getColumn(i).setCellEditor(editor);
    // table.getColumnModel().getColumn(i).setCellRenderer(new ColorRenderer());
    //table.validate();
    JScrollPane scrollPane = new JScrollPane(table);
    getContentPane().add(scrollPane, BorderLayout.CENTER);
    JPanel radioPanel = new JPanel(new GridLayout(1, 5));
    JRadioButton redRadio = new JRadioButton("Red");
    JRadioButton greenRadio = new JRadioButton("Green");
    JRadioButton blueRadio = new JRadioButton("Blue");
    JRadioButton yellowRadio = new JRadioButton("Yellow");
    JRadioButton blackRadio = new JRadioButton("Black");
    // Group the radio buttons.
    ButtonGroup group = new ButtonGroup();
    group.add(redRadio);
    group.add(greenRadio);
    group.add(blueRadio);
    group.add(yellowRadio);
    group.add(blackRadio);
    radioPanel.add(redRadio);
    radioPanel.add(greenRadio);
    radioPanel.add(blueRadio);
    radioPanel.add(yellowRadio);
    radioPanel.add(blackRadio);
    RadioListener radioListener = new RadioListener();
    redRadio.addActionListener(radioListener);
    greenRadio.addActionListener(radioListener);
    blueRadio.addActionListener(radioListener);
    yellowRadio.addActionListener(radioListener);
    blackRadio.addActionListener(radioListener);
    // add radiopanel to container
    JPanel panel = new JPanel(new GridLayout(2, 1));
    panel.add(new JLabel("Select color for selected cell:"));
    panel.add(radioPanel);
    getContentPane().add(BorderLayout.SOUTH, panel);
    addWindowListener(new WindowAdapter() {
    public void windowClosing(WindowEvent e) {
    System.exit(0);
    class ValidDocument extends PlainDocument {
    public void insertString(int index, String s, AttributeSet a)
    throws BadLocationException {
    if ((s == null) || (s.length() == 0)) {
    return;
    StringBuffer t = new StringBuffer(getLength() + s.length());
    t.append(getText(0, index));
    t.append(s);
    t.append(getText(index, getLength() - index));
    if(s.equals("1") && t.toString().equals("1")){               
    super.insertString(index, s, a);
    if(s.equals("0") && t.toString().equals("0")){
    super.insertString(index, s, a);
    if(s.equals(".") && t.toString().equals("0.")){
    super.insertString(index, s, a);
    if(s.equals("5") && t.toString().equals("0.5")){
    super.insertString(index, s, a);
    if(s.equals("b") && t.toString().equals("b")){
    super.insertString(index, s, a);
    //if (super instanceof ColoredItem) {
    // Color fcolor = ((ColoredItem) value).getForeground();
    // Color bcolor = ((ColoredItem) value).getBackground();
    // this.setForeground(fcolor);
    // this.setBackground(bcolor);
    //super.setText(t.toString());
    System.out.println("hehe");
    class RadioListener implements ActionListener {
    public void actionPerformed(ActionEvent ae) {
    int row = table.getSelectedRow();
    int column = table.getSelectedColumn();
    ColoredItem ci = (ColoredItem) tableModel.getValueAt(row, column);
    if (ae.getActionCommand().equals("Red"))
    ci.setBackground(Color.red);
    else if (ae.getActionCommand().equals("Green"))
    ci.setBackground(Color.green);
    else if (ae.getActionCommand().equals("Blue"))
    ci.setBackground(Color.blue);
    else if (ae.getActionCommand().equals("Yellow"))
    ci.setBackground(Color.yellow);
    else if (ae.getActionCommand().equals("Black"))
    ci.setBackground(Color.black);
    System.out.println(ci.getValue());
    // necessary to cause a fireTableCellUpdated event
    tableModel.setValueAt(ci, row, column);
    private class ColoredItem {
    private String value;
    private Color foreground;
    private Color background;
    public ColoredItem(String value, Color foreground, Color background) {
    this.value = value;
    this.foreground = foreground;
    this.background = background;
    public void setValue(String value) {
    this.value = value;
    public void setForeground(Color foreground) {
    this.foreground = foreground;
    public void setBackground(Color background) {
    this.background = background;
    public String getValue() {
    return value;
    public Color getForeground() {
    return foreground;
    public Color getBackground() {
    return background;
    class MyTableModel extends AbstractTableModel {
    String [] columnNames;
    ColoredItem [][] data;
    MyTableModel(int rows, int columns) {
    columnNames = createColumnElements(columns);
    data = createTableElements(rows, columns);
    public int getColumnCount() {
    return columnNames.length;
    public int getRowCount() {
    return data.length;
    public String getColumnName(int col) {
    return columnNames[col];
    public Object getValueAt(int row, int col) {
    return data[row][col];
    public Class getColumnClass(int c) {
    return getValueAt(0, c).getClass();
    public void setValueAt(ColoredItem value, int row, int col) {              
    data[row][col] = value;
    //System.out.println((ColoredItem)value.getValue());
    //temp.setValue((ColoredItem)value.getValue());
    fireTableCellUpdated(row, col);
    private String[] createColumnElements(int columns) {
    String[] data;
    data = new String[columns];
    for (int i=0; i<columns; i++) {
    data[i] = new String("Column " + i);
    return data;
    private ColoredItem [][] createTableElements(int rows, int columns) {
    ColoredItem [][]data;
    data = new ColoredItem[rows][];
    for (int i=0; i<rows; i++) {
    data[i] = new ColoredItem[columns];
    for (int j=0; j<columns; j++) {
    data[i][j] = new ColoredItem("", Color.black, Color.white);
    return data;
    public boolean isCellEditable(int rowIndex, int columnIndex) {
    return true;
    public static void main(String []args) {
    Main main = new Main();
    main.pack();
    main.setVisible(true);
    }

    JTextField jtxf=new JTextField();
         private void setColumns() {
    TableColumn column = null;
    if(this.getRowCount()>0){
    for (int i = 0; i < this.getColumnCount(); i++) {
    column = this.getColumnModel().getColumn(i);
              DefaultCellEditor dce = new DefaultCellEditor(jtxf);
              column.setCellEditor(dce);
              dce.setClickCountToStart(1);
    simply call this method in constructor it will help u

  • Using two dimensional character array in a Jolt-Tuxedo call

    Hi,
    I have a Tuxedo service that returns a two dimensional character array as follows:
    char airports[234][3] ;
    There are 234 rows and each row is a character array of 3 characters.
    When I call this service using Jolt, how can I access these in the Java program
    Can the getStringDef or getStringItemDef be used by any chance ?
    Thanks
    Bala.

    Hello Bala,
    R u using FML Buffers or Views???
    regards
    MS

Maybe you are looking for

  • My Mac was re-imaged, had purchased version of Cs5, now I only have my product key, how can I get it back on my fresh system?

    My hard drive was fixed up and as a result I lost all my applications including a purchased version of Cs5.  I don't have the physical disc anymore, but I do have the product key.  Can I reinstall suite, and how?

  • Flat files required for Universal Adapters HR Payroll

    Hi Folks we are implementing new HR Analytics using Universal adapters HR Payroll subject area. where can i get the Flat files which are designed and delivered for Universal Adapters which contains the Field names etc. i searched in web and found no

  • OIM 11gR2 - AD Organizational Unit provisioning

    hi, i can provision OIM organization to AD Organizational Unit. Its work fine with "Provision Resource to Organization" forms but i can't find any simple way (without six steps form) to add AD organizational unit to OIM organization. Have you any sug

  • Actual Cost Opening Balance Variation

    During deployment time rough opening balance amount given(Actual Cost)...now need to add the variation..if it is addition, v can use pre-approved expenditure(PAE) batches and pass the respective task value....but in case of negative values...how to g

  • Exp errors

    We perform a weekly export of our 8.1.7 database. This is done overnight at the weekend when the database is lightly used so we use consistent = 'Y'. This week we encountered some problems we have not had before. 1. A few of the tables are reported a