Link to home
Start Free TrialLog in
Avatar of SolangeRichard
SolangeRichardFlag for Canada

asked on

Resize the JEditorPane/JScrollPane when the JFrame is resized

When the window is resized, I would like the content to be resized too.  
How can I do this please?

     public void initialize()
     {
          // Window properties
          screenSize = new Dimension(650, 550);
          setSize(screenSize);
          setResizable(true);

          // Help Panel
          helpPanel = new JPanel();
          helpPanel.setLayout(null);
 
          // Help Content
          helpContent = new JEditorPane("text/html", "");
          try
          {
               URL url = getClass().getResource("/help/help.htm");
               helpContent.setPage(url);
               helpContent.setVisible(true);
               getContentPane().add(helpContent);
          }
          catch (IOException e)
          {
               e.printStackTrace();
          }

          scroll = new JScrollPane();
          scroll.setViewportView(helpContent);
          scroll.setBounds(0, 0, 640, 540);
          helpPanel.add(scroll);
          getContentPane().add(helpPanel);
     }
Avatar of Mick Barry
Mick Barry
Flag of Australia image

Either use a layout manager, or add a ComponentListener to your frame and resize your pane when frame resized.
ASKER CERTIFIED SOLUTION
Avatar of zzynx
zzynx
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of SolangeRichard

ASKER

Thank you,

It's working perfectly!
Glad to hear that.
Thanks for the acceptance.