Graphing with JLabel for looks [null layout] Java Swing *ERROR









up vote
-1
down vote

favorite












I am trying to build a student graph with JLabels



my app does a sql query and returns an int value for each month's number of entries and if doesnt find any it returns 0.



//scale variable is an int

//ene is a return value from another method that runs before

//in case there are no students in january I dont have to graph anything
//so this 'if' doesnt run

Scale = 50;

if (Ene != 0)

System.out.println(Ene + " ene stdds");

// this prints out 11 ene stdds

double EneBH = 449 * (Ene / Scale);
int EneBHeight = (int) Math.round(EneBH);
int EneBYLocal = 612 - EneBHeight;

EneP.setBounds(76, EneBYLocal, 7, EneBHeight);
EneP.setVisible(true);

else

//if the last if didnt run I want to know if it hidd the label

System.out.println("HIDDEN ENE");
EneP.setVisible(false);



https://i.stack.imgur.com/su4qS.png



*Ene P is the very first jlabel for graphing, it looks kida gray and is at the enero zone.



*EneP prints out 11 students but never shows up, doesnt print hidden ene, it just doesnt show up



*EneP will have the same code than the other jlabels if I solve it or you solve it, please










share|improve this question



















  • 1




    Sorry, I could't see a question in your question.
    – yole
    Nov 9 at 17:29










  • For better help sooner, post a Minimal, Complete, and Verifiable example or Short, Self Contained, Correct Example. (And ask a question.)
    – Andrew Thompson
    Nov 10 at 3:24














up vote
-1
down vote

favorite












I am trying to build a student graph with JLabels



my app does a sql query and returns an int value for each month's number of entries and if doesnt find any it returns 0.



//scale variable is an int

//ene is a return value from another method that runs before

//in case there are no students in january I dont have to graph anything
//so this 'if' doesnt run

Scale = 50;

if (Ene != 0)

System.out.println(Ene + " ene stdds");

// this prints out 11 ene stdds

double EneBH = 449 * (Ene / Scale);
int EneBHeight = (int) Math.round(EneBH);
int EneBYLocal = 612 - EneBHeight;

EneP.setBounds(76, EneBYLocal, 7, EneBHeight);
EneP.setVisible(true);

else

//if the last if didnt run I want to know if it hidd the label

System.out.println("HIDDEN ENE");
EneP.setVisible(false);



https://i.stack.imgur.com/su4qS.png



*Ene P is the very first jlabel for graphing, it looks kida gray and is at the enero zone.



*EneP prints out 11 students but never shows up, doesnt print hidden ene, it just doesnt show up



*EneP will have the same code than the other jlabels if I solve it or you solve it, please










share|improve this question



















  • 1




    Sorry, I could't see a question in your question.
    – yole
    Nov 9 at 17:29










  • For better help sooner, post a Minimal, Complete, and Verifiable example or Short, Self Contained, Correct Example. (And ask a question.)
    – Andrew Thompson
    Nov 10 at 3:24












up vote
-1
down vote

favorite









up vote
-1
down vote

favorite











I am trying to build a student graph with JLabels



my app does a sql query and returns an int value for each month's number of entries and if doesnt find any it returns 0.



//scale variable is an int

//ene is a return value from another method that runs before

//in case there are no students in january I dont have to graph anything
//so this 'if' doesnt run

Scale = 50;

if (Ene != 0)

System.out.println(Ene + " ene stdds");

// this prints out 11 ene stdds

double EneBH = 449 * (Ene / Scale);
int EneBHeight = (int) Math.round(EneBH);
int EneBYLocal = 612 - EneBHeight;

EneP.setBounds(76, EneBYLocal, 7, EneBHeight);
EneP.setVisible(true);

else

//if the last if didnt run I want to know if it hidd the label

System.out.println("HIDDEN ENE");
EneP.setVisible(false);



https://i.stack.imgur.com/su4qS.png



*Ene P is the very first jlabel for graphing, it looks kida gray and is at the enero zone.



*EneP prints out 11 students but never shows up, doesnt print hidden ene, it just doesnt show up



*EneP will have the same code than the other jlabels if I solve it or you solve it, please










share|improve this question















I am trying to build a student graph with JLabels



my app does a sql query and returns an int value for each month's number of entries and if doesnt find any it returns 0.



//scale variable is an int

//ene is a return value from another method that runs before

//in case there are no students in january I dont have to graph anything
//so this 'if' doesnt run

Scale = 50;

if (Ene != 0)

System.out.println(Ene + " ene stdds");

// this prints out 11 ene stdds

double EneBH = 449 * (Ene / Scale);
int EneBHeight = (int) Math.round(EneBH);
int EneBYLocal = 612 - EneBHeight;

EneP.setBounds(76, EneBYLocal, 7, EneBHeight);
EneP.setVisible(true);

else

//if the last if didnt run I want to know if it hidd the label

System.out.println("HIDDEN ENE");
EneP.setVisible(false);



https://i.stack.imgur.com/su4qS.png



*Ene P is the very first jlabel for graphing, it looks kida gray and is at the enero zone.



*EneP prints out 11 students but never shows up, doesnt print hidden ene, it just doesnt show up



*EneP will have the same code than the other jlabels if I solve it or you solve it, please







java swing interface helper javahelp






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 9 at 17:18









camickr

272k14124237




272k14124237










asked Nov 9 at 17:15









Miguel Romero

1




1







  • 1




    Sorry, I could't see a question in your question.
    – yole
    Nov 9 at 17:29










  • For better help sooner, post a Minimal, Complete, and Verifiable example or Short, Self Contained, Correct Example. (And ask a question.)
    – Andrew Thompson
    Nov 10 at 3:24












  • 1




    Sorry, I could't see a question in your question.
    – yole
    Nov 9 at 17:29










  • For better help sooner, post a Minimal, Complete, and Verifiable example or Short, Self Contained, Correct Example. (And ask a question.)
    – Andrew Thompson
    Nov 10 at 3:24







1




1




Sorry, I could't see a question in your question.
– yole
Nov 9 at 17:29




Sorry, I could't see a question in your question.
– yole
Nov 9 at 17:29












For better help sooner, post a Minimal, Complete, and Verifiable example or Short, Self Contained, Correct Example. (And ask a question.)
– Andrew Thompson
Nov 10 at 3:24




For better help sooner, post a Minimal, Complete, and Verifiable example or Short, Self Contained, Correct Example. (And ask a question.)
– Andrew Thompson
Nov 10 at 3:24












1 Answer
1






active

oldest

votes

















up vote
0
down vote













I have found a Solution for My Own Problem



The solution was easy turns out that If you divide Ene (the return variable from a query that saves as an integer value) by the Scale variable which is also an integer it causes java to return 0



So I have discovered this on my own by placing a system.out.print() after every line and printing the values of every variable.



I noticed 11/50 shouldn't return 0, so I changed the scale variable to be a double and still returned 0; but I changed both and now it works just right.



Scale = 50; 

if (Ene != 0)

System.out.println(Ene + " ene stdds");

// this prints out 11 ene stdds

double EneBH = 449 * (Ene / Scale);
int EneBHeight = (int) Math.round(EneBH);
int EneBYLocal = 612 - EneBHeight;

EneP.setBounds(76, EneBYLocal, 7, EneBHeight);
EneP.setVisible(true);

else

//if the last if didnt run I want to know if it hidd the label

System.out.println("HIDDEN ENE");
EneP.setVisible(false);



enter image description here






share|improve this answer








New contributor




Miguel Romero is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

















    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',
    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%2f53230455%2fgraphing-with-jlabel-for-looks-null-layout-java-swing-error%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








    up vote
    0
    down vote













    I have found a Solution for My Own Problem



    The solution was easy turns out that If you divide Ene (the return variable from a query that saves as an integer value) by the Scale variable which is also an integer it causes java to return 0



    So I have discovered this on my own by placing a system.out.print() after every line and printing the values of every variable.



    I noticed 11/50 shouldn't return 0, so I changed the scale variable to be a double and still returned 0; but I changed both and now it works just right.



    Scale = 50; 

    if (Ene != 0)

    System.out.println(Ene + " ene stdds");

    // this prints out 11 ene stdds

    double EneBH = 449 * (Ene / Scale);
    int EneBHeight = (int) Math.round(EneBH);
    int EneBYLocal = 612 - EneBHeight;

    EneP.setBounds(76, EneBYLocal, 7, EneBHeight);
    EneP.setVisible(true);

    else

    //if the last if didnt run I want to know if it hidd the label

    System.out.println("HIDDEN ENE");
    EneP.setVisible(false);



    enter image description here






    share|improve this answer








    New contributor




    Miguel Romero is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.





















      up vote
      0
      down vote













      I have found a Solution for My Own Problem



      The solution was easy turns out that If you divide Ene (the return variable from a query that saves as an integer value) by the Scale variable which is also an integer it causes java to return 0



      So I have discovered this on my own by placing a system.out.print() after every line and printing the values of every variable.



      I noticed 11/50 shouldn't return 0, so I changed the scale variable to be a double and still returned 0; but I changed both and now it works just right.



      Scale = 50; 

      if (Ene != 0)

      System.out.println(Ene + " ene stdds");

      // this prints out 11 ene stdds

      double EneBH = 449 * (Ene / Scale);
      int EneBHeight = (int) Math.round(EneBH);
      int EneBYLocal = 612 - EneBHeight;

      EneP.setBounds(76, EneBYLocal, 7, EneBHeight);
      EneP.setVisible(true);

      else

      //if the last if didnt run I want to know if it hidd the label

      System.out.println("HIDDEN ENE");
      EneP.setVisible(false);



      enter image description here






      share|improve this answer








      New contributor




      Miguel Romero is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.



















        up vote
        0
        down vote










        up vote
        0
        down vote









        I have found a Solution for My Own Problem



        The solution was easy turns out that If you divide Ene (the return variable from a query that saves as an integer value) by the Scale variable which is also an integer it causes java to return 0



        So I have discovered this on my own by placing a system.out.print() after every line and printing the values of every variable.



        I noticed 11/50 shouldn't return 0, so I changed the scale variable to be a double and still returned 0; but I changed both and now it works just right.



        Scale = 50; 

        if (Ene != 0)

        System.out.println(Ene + " ene stdds");

        // this prints out 11 ene stdds

        double EneBH = 449 * (Ene / Scale);
        int EneBHeight = (int) Math.round(EneBH);
        int EneBYLocal = 612 - EneBHeight;

        EneP.setBounds(76, EneBYLocal, 7, EneBHeight);
        EneP.setVisible(true);

        else

        //if the last if didnt run I want to know if it hidd the label

        System.out.println("HIDDEN ENE");
        EneP.setVisible(false);



        enter image description here






        share|improve this answer








        New contributor




        Miguel Romero is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.









        I have found a Solution for My Own Problem



        The solution was easy turns out that If you divide Ene (the return variable from a query that saves as an integer value) by the Scale variable which is also an integer it causes java to return 0



        So I have discovered this on my own by placing a system.out.print() after every line and printing the values of every variable.



        I noticed 11/50 shouldn't return 0, so I changed the scale variable to be a double and still returned 0; but I changed both and now it works just right.



        Scale = 50; 

        if (Ene != 0)

        System.out.println(Ene + " ene stdds");

        // this prints out 11 ene stdds

        double EneBH = 449 * (Ene / Scale);
        int EneBHeight = (int) Math.round(EneBH);
        int EneBYLocal = 612 - EneBHeight;

        EneP.setBounds(76, EneBYLocal, 7, EneBHeight);
        EneP.setVisible(true);

        else

        //if the last if didnt run I want to know if it hidd the label

        System.out.println("HIDDEN ENE");
        EneP.setVisible(false);



        enter image description here







        share|improve this answer








        New contributor




        Miguel Romero is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.









        share|improve this answer



        share|improve this answer






        New contributor




        Miguel Romero is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.









        answered Nov 10 at 6:48









        Miguel Romero

        1




        1




        New contributor




        Miguel Romero is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.





        New contributor





        Miguel Romero is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.






        Miguel Romero is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.



























             

            draft saved


            draft discarded















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53230455%2fgraphing-with-jlabel-for-looks-null-layout-java-swing-error%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

            Use pre created SQLite database for Android project in kotlin

            Darth Vader #20

            Ondo