SolangeRichard
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("/h elp/help.h tm");
helpContent.setPage(url);
helpContent.setVisible(tru e);
getContentPane().add(helpC ontent);
}
catch (IOException e)
{
e.printStackTrace();
}
scroll = new JScrollPane();
scroll.setViewportView(hel pContent);
scroll.setBounds(0, 0, 640, 540);
helpPanel.add(scroll);
getContentPane().add(helpP anel);
}
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("/h
helpContent.setPage(url);
helpContent.setVisible(tru
getContentPane().add(helpC
}
catch (IOException e)
{
e.printStackTrace();
}
scroll = new JScrollPane();
scroll.setViewportView(hel
scroll.setBounds(0, 0, 640, 540);
helpPanel.add(scroll);
getContentPane().add(helpP
}
Either use a layout manager, or add a ComponentListener to your frame and resize your pane when frame resized.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you,
It's working perfectly!
It's working perfectly!
Glad to hear that.
Thanks for the acceptance.
Thanks for the acceptance.