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);
        }

        }

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.#

I want to display alphabet from the program on textfield or label

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.