I want to display the quote (character) into a text in netbeans Swing form. But it shows only last character. Any help would be appreciated.

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                         
        // TODO add your handling code here:
        String t = encodeText.getText();
        String text = t.toUpperCase();
        int[]textnum = new int[text.length()];


        for(int i=0; i<text.length(); i++) {
            if(text.charAt(i)>64 && text.charAt(i)<91) {
                textnum[i] = text.charAt(i)-65;
            } else if(text.charAt(i) == 32) {
                textnum[i] = 26;
            }
        }


        int[] g = new int[27];
        Random random = new Random();

        for(int i=0; i<g.length; i++) {
            g[i] = i;
            // System.out.println(g[i]);
        }

        for(int i=0; i<50; i++) {
            int e = random.nextInt(26);
            int f = random.nextInt(26);

            int temp = g[e];
            g[e] = g[f];
            g[f] = temp;
        }

        int[] encoded = new int[textnum.length];

        for(int i=0; i<textnum.length; i++) {
            encoded[i] = g[textnum[i]];
        }

        for(int i=0; i<encoded.length; i++) {
            char alphabet =  (char) (encoded[i] + 65);
            if(alphabet == 91) {
                alphabet = 32;
                }
            String c = Character.toString(alphabet);
            jTextArea1.setText(c);
        }

        }

Edited 3 Years Ago by mike_2000_17: Fixed formatting

you always declare a new

char alphabet =  (char) (encoded[i] + 65);

insude for block declare once time before for block

alphabet = alphabet + (char) (encoded[i] + 65); 
//or same
alphabet += (char) (encoded[i] + 65);

what yre you tried with broken Html syntax

#
String c = Character.toString(alphabet);
jTextArea1.setText(c);

put that outSide for block

<div> <div class="quote"> <div class="quote_header"> Quote ... </div> <blockquote class="quote_body"> String c = Character.toString(alphabet);
jTextArea1.setText(c);
} </blockquote> </div> </div> }

this part got messed up when i was creating thread actuall; there is no html code or part in program. it is just java.#

This article has been dead for over six months. Start a new discussion instead.