printing Random Unicode Characters in java through infinite FOR loopHow does the Java 'for each' loop work?Iterating through a Collection, avoiding ConcurrentModificationException when removing objects in a loopHow do I generate random integers within a specific range in Java?What's the simplest way to print a Java array?How do I break out of nested loops in Java?A 'for' loop to iterate over an enum in JavaLoop through an array in JavaScriptHow to change language at runtime in java swingWhy does this code using random strings print “hello world”?Why is executing Java code in comments with certain Unicode characters allowed?

How to I force windows to use a specific version of SQLCMD?

Should I assume I have passed probation?

El Dorado Word Puzzle II: Videogame Edition

Difference between shutdown options

Determining multivariate least squares with constraint

Typing CO_2 easily

Sound waves in different octaves

Given this phrasing in the lease, when should I pay my rent?

Why didn’t Eve recognize the little cockroach as a living organism?

How to make a list of partial sums using forEach

What is this high flying aircraft over Pennsylvania?

Telemetry for feature health

The Digit Triangles

Do I have to know the General Relativity theory to understand the concept of inertial frame?

Showing mass murder in a kid's book

If the only attacker is removed from combat, is a creature still counted as having attacked this turn?

Why is the sun approximated as a black body at ~ 5800 K?

What does "tick" mean in this sentence?

Overlapping circles covering polygon

Can I cause damage to electrical appliances by unplugging them when they are turned on?

Possible Eco thriller, man invents a device to remove rain from glass

Did I make a mistake by ccing email to boss to others?

Is there a distance limit for minecart tracks?

If A is dense in Q, then it must be dense in R.



printing Random Unicode Characters in java through infinite FOR loop


How does the Java 'for each' loop work?Iterating through a Collection, avoiding ConcurrentModificationException when removing objects in a loopHow do I generate random integers within a specific range in Java?What's the simplest way to print a Java array?How do I break out of nested loops in Java?A 'for' loop to iterate over an enum in JavaLoop through an array in JavaScriptHow to change language at runtime in java swingWhy does this code using random strings print “hello world”?Why is executing Java code in comments with certain Unicode characters allowed?













-1















I want to print random Unicode characters in a JFRAME in java by using an infinite for loop.



I am a newbie in java programming and i hope the answer is not too complex.



this is the code so far-



import java.awt.*;
import javax.swing.*;
import java.util.*;

public class Matrix extends JFrame
private static final int NUMBER_OF_REPS = 0;

public static void main(String[] args)
int a;

Random rand=new Random();

for(a=1;a>0;)

JLabel lbl=new JLabel();
lbl.setForeground(Color.GREEN);
lbl.setFont(new Font("MS Arial Unicode",Font.BOLD,12));
lbl.setText("\u30"+Integer.toHexString(rand.nextInt(96) + 160));


JFrame frame=new JFrame();
frame.setLocationRelativeTo(null);
frame.pack();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
frame.getContentPane().setBackground(Color.BLACK);

//error! lbl cannot be resolved to a variable
frame.getContentPane().add(lbl);
frame.getContentPane().setLayout(new FlowLayout());











share|improve this question



















  • 1





    it would be helpful if you provide details on something that you have tried

    – vembutech
    Nov 6 '14 at 15:40












  • General advice for new programmers: Break down your problem into smaller problems and focus on solving each independently. In this case, you can break it down into two problems: 1. Generate random Unicode characters with a for loop. 2. Create a JFrame and write text into it. Then, break down those problems into even smaller problems. This will help you learn in small steps and ask clear, concise questions. Good luck!

    – ZoogieZork
    Nov 6 '14 at 17:36











  • i searched for hours but couldn't find the specific answer i was looking for ;i wanted to create a program that would randomly generate and display unicode characters in a jframe using a loop.

    – Ujwal Kundur
    Nov 7 '14 at 16:07







  • 1





    lbl goes out of scope at the end of the for-loop. Rewrite your code so that you can move frame.getContentPane().add(lbl); inside the loop.

    – David Gorsline
    Nov 7 '14 at 16:52












  • how to i repetatively make new jlabels and add random characters in them using a loop?

    – Ujwal Kundur
    Nov 8 '14 at 3:46















-1















I want to print random Unicode characters in a JFRAME in java by using an infinite for loop.



I am a newbie in java programming and i hope the answer is not too complex.



this is the code so far-



import java.awt.*;
import javax.swing.*;
import java.util.*;

public class Matrix extends JFrame
private static final int NUMBER_OF_REPS = 0;

public static void main(String[] args)
int a;

Random rand=new Random();

for(a=1;a>0;)

JLabel lbl=new JLabel();
lbl.setForeground(Color.GREEN);
lbl.setFont(new Font("MS Arial Unicode",Font.BOLD,12));
lbl.setText("\u30"+Integer.toHexString(rand.nextInt(96) + 160));


JFrame frame=new JFrame();
frame.setLocationRelativeTo(null);
frame.pack();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
frame.getContentPane().setBackground(Color.BLACK);

//error! lbl cannot be resolved to a variable
frame.getContentPane().add(lbl);
frame.getContentPane().setLayout(new FlowLayout());











share|improve this question



















  • 1





    it would be helpful if you provide details on something that you have tried

    – vembutech
    Nov 6 '14 at 15:40












  • General advice for new programmers: Break down your problem into smaller problems and focus on solving each independently. In this case, you can break it down into two problems: 1. Generate random Unicode characters with a for loop. 2. Create a JFrame and write text into it. Then, break down those problems into even smaller problems. This will help you learn in small steps and ask clear, concise questions. Good luck!

    – ZoogieZork
    Nov 6 '14 at 17:36











  • i searched for hours but couldn't find the specific answer i was looking for ;i wanted to create a program that would randomly generate and display unicode characters in a jframe using a loop.

    – Ujwal Kundur
    Nov 7 '14 at 16:07







  • 1





    lbl goes out of scope at the end of the for-loop. Rewrite your code so that you can move frame.getContentPane().add(lbl); inside the loop.

    – David Gorsline
    Nov 7 '14 at 16:52












  • how to i repetatively make new jlabels and add random characters in them using a loop?

    – Ujwal Kundur
    Nov 8 '14 at 3:46













-1












-1








-1








I want to print random Unicode characters in a JFRAME in java by using an infinite for loop.



I am a newbie in java programming and i hope the answer is not too complex.



this is the code so far-



import java.awt.*;
import javax.swing.*;
import java.util.*;

public class Matrix extends JFrame
private static final int NUMBER_OF_REPS = 0;

public static void main(String[] args)
int a;

Random rand=new Random();

for(a=1;a>0;)

JLabel lbl=new JLabel();
lbl.setForeground(Color.GREEN);
lbl.setFont(new Font("MS Arial Unicode",Font.BOLD,12));
lbl.setText("\u30"+Integer.toHexString(rand.nextInt(96) + 160));


JFrame frame=new JFrame();
frame.setLocationRelativeTo(null);
frame.pack();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
frame.getContentPane().setBackground(Color.BLACK);

//error! lbl cannot be resolved to a variable
frame.getContentPane().add(lbl);
frame.getContentPane().setLayout(new FlowLayout());











share|improve this question
















I want to print random Unicode characters in a JFRAME in java by using an infinite for loop.



I am a newbie in java programming and i hope the answer is not too complex.



this is the code so far-



import java.awt.*;
import javax.swing.*;
import java.util.*;

public class Matrix extends JFrame
private static final int NUMBER_OF_REPS = 0;

public static void main(String[] args)
int a;

Random rand=new Random();

for(a=1;a>0;)

JLabel lbl=new JLabel();
lbl.setForeground(Color.GREEN);
lbl.setFont(new Font("MS Arial Unicode",Font.BOLD,12));
lbl.setText("\u30"+Integer.toHexString(rand.nextInt(96) + 160));


JFrame frame=new JFrame();
frame.setLocationRelativeTo(null);
frame.pack();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
frame.getContentPane().setBackground(Color.BLACK);

//error! lbl cannot be resolved to a variable
frame.getContentPane().add(lbl);
frame.getContentPane().setLayout(new FlowLayout());








java for-loop unicode infinite






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 7 at 2:45









Cœur

19k9113155




19k9113155










asked Nov 6 '14 at 15:34









Ujwal KundurUjwal Kundur

55




55







  • 1





    it would be helpful if you provide details on something that you have tried

    – vembutech
    Nov 6 '14 at 15:40












  • General advice for new programmers: Break down your problem into smaller problems and focus on solving each independently. In this case, you can break it down into two problems: 1. Generate random Unicode characters with a for loop. 2. Create a JFrame and write text into it. Then, break down those problems into even smaller problems. This will help you learn in small steps and ask clear, concise questions. Good luck!

    – ZoogieZork
    Nov 6 '14 at 17:36











  • i searched for hours but couldn't find the specific answer i was looking for ;i wanted to create a program that would randomly generate and display unicode characters in a jframe using a loop.

    – Ujwal Kundur
    Nov 7 '14 at 16:07







  • 1





    lbl goes out of scope at the end of the for-loop. Rewrite your code so that you can move frame.getContentPane().add(lbl); inside the loop.

    – David Gorsline
    Nov 7 '14 at 16:52












  • how to i repetatively make new jlabels and add random characters in them using a loop?

    – Ujwal Kundur
    Nov 8 '14 at 3:46












  • 1





    it would be helpful if you provide details on something that you have tried

    – vembutech
    Nov 6 '14 at 15:40












  • General advice for new programmers: Break down your problem into smaller problems and focus on solving each independently. In this case, you can break it down into two problems: 1. Generate random Unicode characters with a for loop. 2. Create a JFrame and write text into it. Then, break down those problems into even smaller problems. This will help you learn in small steps and ask clear, concise questions. Good luck!

    – ZoogieZork
    Nov 6 '14 at 17:36











  • i searched for hours but couldn't find the specific answer i was looking for ;i wanted to create a program that would randomly generate and display unicode characters in a jframe using a loop.

    – Ujwal Kundur
    Nov 7 '14 at 16:07







  • 1





    lbl goes out of scope at the end of the for-loop. Rewrite your code so that you can move frame.getContentPane().add(lbl); inside the loop.

    – David Gorsline
    Nov 7 '14 at 16:52












  • how to i repetatively make new jlabels and add random characters in them using a loop?

    – Ujwal Kundur
    Nov 8 '14 at 3:46







1




1





it would be helpful if you provide details on something that you have tried

– vembutech
Nov 6 '14 at 15:40






it would be helpful if you provide details on something that you have tried

– vembutech
Nov 6 '14 at 15:40














General advice for new programmers: Break down your problem into smaller problems and focus on solving each independently. In this case, you can break it down into two problems: 1. Generate random Unicode characters with a for loop. 2. Create a JFrame and write text into it. Then, break down those problems into even smaller problems. This will help you learn in small steps and ask clear, concise questions. Good luck!

– ZoogieZork
Nov 6 '14 at 17:36





General advice for new programmers: Break down your problem into smaller problems and focus on solving each independently. In this case, you can break it down into two problems: 1. Generate random Unicode characters with a for loop. 2. Create a JFrame and write text into it. Then, break down those problems into even smaller problems. This will help you learn in small steps and ask clear, concise questions. Good luck!

– ZoogieZork
Nov 6 '14 at 17:36













i searched for hours but couldn't find the specific answer i was looking for ;i wanted to create a program that would randomly generate and display unicode characters in a jframe using a loop.

– Ujwal Kundur
Nov 7 '14 at 16:07






i searched for hours but couldn't find the specific answer i was looking for ;i wanted to create a program that would randomly generate and display unicode characters in a jframe using a loop.

– Ujwal Kundur
Nov 7 '14 at 16:07





1




1





lbl goes out of scope at the end of the for-loop. Rewrite your code so that you can move frame.getContentPane().add(lbl); inside the loop.

– David Gorsline
Nov 7 '14 at 16:52






lbl goes out of scope at the end of the for-loop. Rewrite your code so that you can move frame.getContentPane().add(lbl); inside the loop.

– David Gorsline
Nov 7 '14 at 16:52














how to i repetatively make new jlabels and add random characters in them using a loop?

– Ujwal Kundur
Nov 8 '14 at 3:46





how to i repetatively make new jlabels and add random characters in them using a loop?

– Ujwal Kundur
Nov 8 '14 at 3:46












1 Answer
1






active

oldest

votes


















0














I used a while loop, they're easier for infinite numbers. As for JFRAME, you're going to want to look at another answer, as I'm not very good with javax.swing.* As of now it just puts it into the console



public Random random = new Random();

public static void main(String[] args)
while(true)
int i = random.nextInt(127);
System.out.print((char)i);







share|improve this answer






















    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f26783278%2fprinting-random-unicode-characters-in-java-through-infinite-for-loop%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    I used a while loop, they're easier for infinite numbers. As for JFRAME, you're going to want to look at another answer, as I'm not very good with javax.swing.* As of now it just puts it into the console



    public Random random = new Random();

    public static void main(String[] args)
    while(true)
    int i = random.nextInt(127);
    System.out.print((char)i);







    share|improve this answer



























      0














      I used a while loop, they're easier for infinite numbers. As for JFRAME, you're going to want to look at another answer, as I'm not very good with javax.swing.* As of now it just puts it into the console



      public Random random = new Random();

      public static void main(String[] args)
      while(true)
      int i = random.nextInt(127);
      System.out.print((char)i);







      share|improve this answer

























        0












        0








        0







        I used a while loop, they're easier for infinite numbers. As for JFRAME, you're going to want to look at another answer, as I'm not very good with javax.swing.* As of now it just puts it into the console



        public Random random = new Random();

        public static void main(String[] args)
        while(true)
        int i = random.nextInt(127);
        System.out.print((char)i);







        share|improve this answer













        I used a while loop, they're easier for infinite numbers. As for JFRAME, you're going to want to look at another answer, as I'm not very good with javax.swing.* As of now it just puts it into the console



        public Random random = new Random();

        public static void main(String[] args)
        while(true)
        int i = random.nextInt(127);
        System.out.print((char)i);








        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 6 '14 at 17:01









        mirvinemirvine

        91114




        91114





























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f26783278%2fprinting-random-unicode-characters-in-java-through-infinite-for-loop%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            AWS Lex not identifying response if by a variable The 2019 Stack Overflow Developer Survey Results Are In Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) The Ask Question Wizard is Live! Data science time! April 2019 and salary with experienceEnforcing custom enumeration in AWS LEX for slot valuesHow to give response based on user response in Amazon Lex?Intercepting AWS Lambda Response to a AWS Lex QueryLex chat bot error: Reached second execution of fulfillment lambda on the same utteranceamazon lex showing invalid responseLambda response send back to Lex slot?Response card in Amazon lexAmazon Lex - Lambda response return HTML to botHow can I solve 424 (Failed Dependency) (python) obtained from Amazon lex?

            Алба-Юлія

            Захаров Федір Захарович