RSyntaxTextArea icon indicating copy to clipboard operation
RSyntaxTextArea copied to clipboard

RTextScrollPane.setViewPort() doesn't work properly

Open Zezombye opened this issue 7 years ago • 0 comments

I have the following code:

public class Classe1 extends JFrame {
   public Classe1() {
      JPanel contentPane = new JPanel(new BorderLayout());
      RSyntaxTextArea textArea = new RSyntaxTextArea(20, 60);
      textArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA);
      textArea.setCodeFoldingEnabled(true);
      RTextScrollPane rtsp = new RTextScrollPane();
      rtsp.setViewportView(textArea);
      //rtsp = new RTextScrollPane(textArea);
      contentPane.add(rtsp);

      setContentPane(contentPane);
      setTitle("Test");
      setDefaultCloseOperation(EXIT_ON_CLOSE);
      pack();
      setLocationRelativeTo(null);
   }
   public static void main(String[] args) {
      // Instantiate GUI on the EDT.
      SwingUtilities.invokeLater(new Runnable() {
         public void run() {
            try {
               String laf = UIManager.getSystemLookAndFeelClassName();
               UIManager.setLookAndFeel(laf);
            } catch (Exception e) { /* Never happens */ }
            new Classe1().setVisible(true);
         }
      });
   }
}

For some reason it doesn't display the scroll pane, only the text area. Passing the textArea as a constructor argument (commented line) works fine, however I expected setViewportView to do the same thing as passing to constructor.

Zezombye avatar Jul 11 '17 15:07 Zezombye