Hi all,
I was referring to
http://forum.java.sun.com/thread.jsp...&thread=204595
to handle the resizing problem.
So I put the canvas into a JScrollPane, and then add the pane into the
JSplitPane.
The code is as follows:
JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
final Canvas canvas = new Canvas();
final JScrollPane scrollPane = new JScrollPane(
JScrollPane.VERTICAL_SCROLLBAR_NEVER,
JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
JPanel panel = new JPanel();
//scrollPane.getViewport().setLayout(new BorderLayout());
scrollPane.getViewport().add(canvas);
splitPane.add(panel);
splitPane.add(scrollPane);
PropertyChangeListener pcListener =
new PropertyChangeListener()
{
public void propertyChange(PropertyChangeEvent pcEvent)
{
scrollPane.getViewport().setSize(splitPane.getRigh tComponent().getSize());
canvas.setSize(splitPane.getRightComponent().getSi ze());
}
};
splitPane.addPropertyChangeListener(pcListener);
The problem is that the canvas won't resize. Is that the lines in
propertyChange() method is not correct? If this is the case, how should I
correct that?
Also, if I uncomment the line
//scrollPane.getViewport().setLayout(new BorderLayout());
the divider of the split pane could not be slided towards the canvas' side.
Is this the nomral behavior, just because I'm mixing heavy and light weight
components together?
Thanks!
Regards,
Dominic