Alright.
I am building a chatroom client.
It's using a JFrame as the main window.
I wanted to add a feature, to when the window is minimized, I can hide all the components and paint the name of the client in large font.
I want to do this, so in operating systems like Vista, W7, etc; when users rollover the taskbar tab of my client, it will show that little thumbnail but instead of the components it would display the application name.
However, I am having problems getting it to paint. I can't seem to find the right Listener to get it to paint before the window minimizes. Since it has become painfully obvious to me that you cannot paint a window after it's been minimized.
Any ideas? Here's some code to show you what I'm talking about.
I am testing on Windows Vista Service Pack 1.
import java.awt.Color;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import javax.swing.JPanel;
import javax.swing.JFrame;
public class Test {
public static void create() {
final JPanel pane = new JPanel();
pane.setBackground(Color.black);
final JFrame frame = new JFrame();
frame.setContentPane(pane);
frame.setTitle("Minimize Paint Test");
frame.setLocation(new java.awt.Point(0, 0));
frame.setSize(new java.awt.Dimension(390, 300));
frame.addWindowListener(new WindowListener() {
public void windowActivated(WindowEvent e) { }
public void windowClosed(WindowEvent e) { }
public void windowClosing(WindowEvent e) { }
public void windowDeactivated(WindowEvent e) { }
public void windowDeiconified(WindowEvent e) { frame.setBackground(Color.black); }
public void windowIconified(WindowEvent e) { frame.setBackground(Color.red); }
public void windowOpened(WindowEvent e) { }
});
frame.setVisible(true);
}
public static void main(String[] args) { create(); }
}
What the code is supposed to do, is start black
When minimized, turn red. So the thumbnail becomes red.
And then when maximized again, turn black
However you'll realize if you turn off making it black on maximize, it will turn red only until it's been maximized again.
Any feedback would be appreciated, I could go without this; but would like to impliment it. Thanks.
The Virux