Do not print the array in its corresponding JTextField

0

The program is simple, you enter a series of numbers (2, 3, 4, 5), and by pressing the Swap Data button, the screen I want to look like this:

Arrangement1 (2, 3, 4, 5) Arrangement 2 (5, 4, 3, 2)

The case is that it puts it as seen in the image. I know that in the for the inversion process of array1 is done and then equal with array2 therefore they have the same values. So how can I do it so that it is as I need it? Each arrangement (the original) in its space Arrangement 1 and the inverse in Arrangement 2.

This is only a small part of the entire code. If necessary I can put everything

 private void dibujarArregloIntercambiar(int n)
    {
        panel1.setVisible(false);
        panel2.setVisible(false);
        panel.setVisible(false);

        panel1.removeAll();
        panel2.removeAll();
        panel.removeAll();

        // tfArreglo1, tfArreglo2 y panel1, panel2


        int max=arreglo1.length-1;
        for(int i=arreglo1.length-1;i>=0;i--) // for para invertir el arreglo.
        {
            arreglo2[max-i]=arreglo1[i];    
     //     System.out.println(arreglo2[max-i]);
     //     System.out.println(arreglo1[i]);

            tfArreglo2[max-i] = new JTextField(2);
            tfArreglo2[max-i].setText(arreglo2[max-i]);
            panel1.add(tfArreglo1[i]);

            tfArreglo2[i] = new JTextField(2);
            panel2.add(tfArreglo2[i]); 
        }

        // Hacer visibles los panels 1 y 2
        panel1.setVisible(true);
        panel2.setVisible(true);

        // Adicionar los panels 1 y 2 al panel de visualizacion
        panel.add(new JLabel("Arreglo 1 "));
        panel.add(panel1);

        panel.add(new JLabel("Arreglo 2 "));
        panel.add(panel2);

        panel.add(bIntercambiar);
        panel.add(bOrdenar);
        panel.add(bBuscar);
        panel.setVisible(true);

        // Adicionar panel de visualizacion al JFrame
        add(panel);
        setVisible(true); 
    }
    
asked by Cruzhn 17.08.2018 в 23:53
source

0 answers