title: Error using protected method of data type of the same class
body: <p>I'm new to Java and I've been trying to create a text program. I've been trying to use a protected method .getRowHeight() from the JTextArea class and call it on an JTextArea object (like in the code below) but I'm getting an error saying "getRowHeight has protected access in javax.swing.JTextArea".</p>
  
  <p>I read online that you can only use protected methods in classes that inherit from the class. But I'm trying to use it on a variable that is from that class, so I thought it would work? Is there a way of making this work without having to inherit from the JTextArea class, because I only really need to use this method once?</p>
  
  <p>Here's a snippet of the code pertaining to userText:</p>
  
  <pre><code>    public class Client extends JFrame {
  
          private JTextArea userText;
  
          public Client() {
              userText = new JTextArea(); //2, 2
              userText.setLineWrap(true);     // turns on line wrapping
              userText.setWrapStyleWord(true);
              add(userText, BorderLayout.SOUTH);
              System.out.println(userText.getRowHeight());
          }
      }
  </code></pre>