有个变通的方法import javax.swing.JDialog; import javax.swing.JFrame;public class T { public static void main(String[] args) { JFrame f = new JFrame("我的Dialog"); f.setBounds(-100, -100, 10, 10); f.setVisible(true);
public void setIconImage(Image image) Description copied from class: Frame Sets the image to be displayed in the minimized icon for this frame. Not all platforms support the concept of minimizing a window. Overrides: setIconImage in class Frame Parameters: image - the icon image to be displayed. If this parameter is null then the icon image is set to the default image, which may vary with platform. See Also: Frame.getIconImage()
import javax.swing.JFrame;public class T {
public static void main(String[] args)
{
JFrame f = new JFrame("我的Dialog");
f.setBounds(-100, -100, 10, 10);
f.setVisible(true);
JDialog dialog = new JDialog(f, "我的Dialog", true);
dialog.setBounds(200, 200, 200, 200);
dialog.setVisible(true);
System.exit(0);
}
}
窗口上本来就显示了一个咖啡杯的小图标啊
Description copied from class: Frame
Sets the image to be displayed in the minimized icon for this frame. Not all platforms support the concept of minimizing a window. Overrides:
setIconImage in class Frame
Parameters:
image - the icon image to be displayed. If this parameter is null then the icon image is set to the default image, which may vary with platform.
See Also:
Frame.getIconImage()