I
Ian
Hi,
I am having a problem trying to repaint a Jpanel.
The problem is I have a editor(jpanel), I then call a method to resize and
change its properties. In order to achieve this I create a new drawing
editor(editorNew)
I change its size and other properties - and to keep older functionality I
point the new editor to the older one
editor = editorNew;
If I do the following the new version successfully "overwrites" the first
one and is repainted immediately.
However, I would like to make the new version scrollable- which if I do the
commented code below works- but the panel is not painted.
The strange thing is that as soon as I manually resize the whole window with
the mouse the new correctly scrollable version magically appears?
Can anyone please tell me the correct way/order of making the panel being
redrawn immediately?
tried repaint(), paintcomponent() etc.
regards
getContentPane().remove(editor);
editorNew = new DrawingEditor(xnew, ynew);
editor.setVisible(false);
editorNew.setVisible(false);
editorNew.addMyListener(this);
editor = editorNew;
//JScrollPane scrollPane = new JScrollPane(editor);
// scrollPane.revalidate();
// scrollPane.repaint();
// scrollPane.validate();
// scrollPane.setVisible(true);
//getContentPane().add(scrollPane, BorderLayout.CENTER);
getContentPane().add(editor, BorderLayout.CENTER);
editor.revalidate();
editor.repaint();
editor.validate();
editor.setVisible(true);
I am having a problem trying to repaint a Jpanel.
The problem is I have a editor(jpanel), I then call a method to resize and
change its properties. In order to achieve this I create a new drawing
editor(editorNew)
I change its size and other properties - and to keep older functionality I
point the new editor to the older one
editor = editorNew;
If I do the following the new version successfully "overwrites" the first
one and is repainted immediately.
However, I would like to make the new version scrollable- which if I do the
commented code below works- but the panel is not painted.
The strange thing is that as soon as I manually resize the whole window with
the mouse the new correctly scrollable version magically appears?
Can anyone please tell me the correct way/order of making the panel being
redrawn immediately?
tried repaint(), paintcomponent() etc.
regards
getContentPane().remove(editor);
editorNew = new DrawingEditor(xnew, ynew);
editor.setVisible(false);
editorNew.setVisible(false);
editorNew.addMyListener(this);
editor = editorNew;
//JScrollPane scrollPane = new JScrollPane(editor);
// scrollPane.revalidate();
// scrollPane.repaint();
// scrollPane.validate();
// scrollPane.setVisible(true);
//getContentPane().add(scrollPane, BorderLayout.CENTER);
getContentPane().add(editor, BorderLayout.CENTER);
editor.revalidate();
editor.repaint();
editor.validate();
editor.setVisible(true);