This is the closest code I could find to redraw the screen when the frame is resized:
public ImageTest()
{
initializeMethod();
label = new JLabel(new String("Hello"));
pane = new JPanel();
pane.add(label);
add(pane);
addComponentListener(new ComponentMsgHandler());
}
class ComponentMsgHandler implements ComponentListener
{
ComponentMsgHandler(){
}
public void componentResized(ComponentEvent e){
JFrame f = (JFrame)e.getSource();
f.update(/*f.getGraphics()*/);
label.setText(String.format("%1d",++c));
}
public void componentMoved(ComponentEvent e){
}
public void componentShown(ComponentEvent e){
}
public void componentHidden(ComponentEvent e){
}
}
Although the label gets updated with the correct value for 'c', the JFrame.paint() doesn't redraw. I'm wondering if the problem is with the graphics object I'm passing to f.update()? Is there a proper way to do this?