cannot access public method in main. (JFrame) [on hold]












-1












$begingroup$


I have 2 classes:




  • Main

  • UI


UI has a button and text area.



Goal is to have Main print out text in text area when button was pressed.



HOW I'M TRYING TO DO IT(Sudo code):



UI extends JFrame{
boolean tf = false
TextArea ta = new TextArea();
JButton b(event e){
tf=true
}
public boolean getTF(){
return tf;
}
public String getTextArea(){
return ta.getText();
}
}



Main{
public static void Main(String args){
JFrame ui = new UI()
while(true){
if(ui.getTF() == true){
System.out.println(ui.getTextArea())
}
}
}


Problem is Main does not see the methods getTF() and getTextArea() in the UI class. I'm guessing this is because it extends JFrame.



Is there a better way to do this (without combining the UI Class and the Main class)?










share|improve this question









$endgroup$



put on hold as off-topic by vnp, 200_success, Jamal 53 mins ago


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Code not implemented or not working as intended: Code Review is a community where programmers peer-review your working code to address issues such as security, maintainability, performance, and scalability. We require that the code be working correctly, to the best of the author's knowledge, before proceeding with a review." – vnp, 200_success, Jamal

If this question can be reworded to fit the rules in the help center, please edit the question.


















    -1












    $begingroup$


    I have 2 classes:




    • Main

    • UI


    UI has a button and text area.



    Goal is to have Main print out text in text area when button was pressed.



    HOW I'M TRYING TO DO IT(Sudo code):



    UI extends JFrame{
    boolean tf = false
    TextArea ta = new TextArea();
    JButton b(event e){
    tf=true
    }
    public boolean getTF(){
    return tf;
    }
    public String getTextArea(){
    return ta.getText();
    }
    }



    Main{
    public static void Main(String args){
    JFrame ui = new UI()
    while(true){
    if(ui.getTF() == true){
    System.out.println(ui.getTextArea())
    }
    }
    }


    Problem is Main does not see the methods getTF() and getTextArea() in the UI class. I'm guessing this is because it extends JFrame.



    Is there a better way to do this (without combining the UI Class and the Main class)?










    share|improve this question









    $endgroup$



    put on hold as off-topic by vnp, 200_success, Jamal 53 mins ago


    This question appears to be off-topic. The users who voted to close gave this specific reason:


    • "Code not implemented or not working as intended: Code Review is a community where programmers peer-review your working code to address issues such as security, maintainability, performance, and scalability. We require that the code be working correctly, to the best of the author's knowledge, before proceeding with a review." – vnp, 200_success, Jamal

    If this question can be reworded to fit the rules in the help center, please edit the question.
















      -1












      -1








      -1





      $begingroup$


      I have 2 classes:




      • Main

      • UI


      UI has a button and text area.



      Goal is to have Main print out text in text area when button was pressed.



      HOW I'M TRYING TO DO IT(Sudo code):



      UI extends JFrame{
      boolean tf = false
      TextArea ta = new TextArea();
      JButton b(event e){
      tf=true
      }
      public boolean getTF(){
      return tf;
      }
      public String getTextArea(){
      return ta.getText();
      }
      }



      Main{
      public static void Main(String args){
      JFrame ui = new UI()
      while(true){
      if(ui.getTF() == true){
      System.out.println(ui.getTextArea())
      }
      }
      }


      Problem is Main does not see the methods getTF() and getTextArea() in the UI class. I'm guessing this is because it extends JFrame.



      Is there a better way to do this (without combining the UI Class and the Main class)?










      share|improve this question









      $endgroup$




      I have 2 classes:




      • Main

      • UI


      UI has a button and text area.



      Goal is to have Main print out text in text area when button was pressed.



      HOW I'M TRYING TO DO IT(Sudo code):



      UI extends JFrame{
      boolean tf = false
      TextArea ta = new TextArea();
      JButton b(event e){
      tf=true
      }
      public boolean getTF(){
      return tf;
      }
      public String getTextArea(){
      return ta.getText();
      }
      }



      Main{
      public static void Main(String args){
      JFrame ui = new UI()
      while(true){
      if(ui.getTF() == true){
      System.out.println(ui.getTextArea())
      }
      }
      }


      Problem is Main does not see the methods getTF() and getTextArea() in the UI class. I'm guessing this is because it extends JFrame.



      Is there a better way to do this (without combining the UI Class and the Main class)?







      java swing scope






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 3 hours ago









      llamaCaraDarallamaCaraDara

      1413




      1413




      put on hold as off-topic by vnp, 200_success, Jamal 53 mins ago


      This question appears to be off-topic. The users who voted to close gave this specific reason:


      • "Code not implemented or not working as intended: Code Review is a community where programmers peer-review your working code to address issues such as security, maintainability, performance, and scalability. We require that the code be working correctly, to the best of the author's knowledge, before proceeding with a review." – vnp, 200_success, Jamal

      If this question can be reworded to fit the rules in the help center, please edit the question.




      put on hold as off-topic by vnp, 200_success, Jamal 53 mins ago


      This question appears to be off-topic. The users who voted to close gave this specific reason:


      • "Code not implemented or not working as intended: Code Review is a community where programmers peer-review your working code to address issues such as security, maintainability, performance, and scalability. We require that the code be working correctly, to the best of the author's knowledge, before proceeding with a review." – vnp, 200_success, Jamal

      If this question can be reworded to fit the rules in the help center, please edit the question.






















          0






          active

          oldest

          votes

















          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes

          Popular posts from this blog

          How to reconfigure Docker Trusted Registry 2.x.x to use CEPH FS mount instead of NFS and other traditional...

          is 'sed' thread safe

          How to make a Squid Proxy server?