感谢LS的一些提议,但是我本意不是改桌面壁纸....我希望的是,可以通过java制作出一个动态的桌面,就好像屏保一样...简单来说,就是希望制作一个让桌面可以下雪的软件....请求各位不吝赐教....

解决方案 »

  1.   

    去iteye.com找Swing是一把刀,里面有这个程序。
    其实就是制作不规则窗口,也可以看下面的代码
    import java.awt.Color;import java.awt.Graphics;import java.awt.Graphics2D;import java.awt.Image;import java.awt.RenderingHints;
    import javax.swing.ImageIcon;import javax.swing.JFrame;import javax.swing.JPanel;
    import com.sun.awt.AWTUtilities;
    /* 创建无规则的窗口: http://www.javaeye.com/topic/707514 在程序中依次设置以下几个参数: 1. 设置窗口完全透明:AWTUtilities.setWindowOpaque(frame, false); // false支持拖动,很关键 2. 设置窗口无边缘:frame.setUndecorated(true); 3. 设置窗口的ContentPane为要显示的Pane:frame.setContentPane(myPane); 在myPane中放置具体要显示的内容,也可以重载paint方法进行Java2D绘制。这些paint会直接发生在桌面背景上。 接下来,就是见证奇迹的时刻! */@SuppressWarnings("restriction")public class ArbitrayShapeWindow {
        @SuppressWarnings({ "serial" })    public static void main(String[] args) {        JPanel panel = new JPanel() {            private Image img = new ImageIcon("resources/shape.png").getImage();
                @Override            public void paintComponent(Graphics g) {                super.paintComponent(g);                Graphics2D g2d = (Graphics2D) g;                g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,                    RenderingHints.VALUE_ANTIALIAS_ON);
                    g2d.setPaint(Color.red);                g2d.drawImage(img, 0, 0, img.getWidth(this), img.getHeight(this), null);            }        };
            JFrame frame = new JFrame();        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);        frame.setUndecorated(true);        AWTUtilities.setWindowOpaque(frame, false);        frame.setContentPane(panel);        //frame.setSize(500, 500); // frame不能用pack()函数        frame.setAlwaysOnTop(true); // 窗口最前面显示        frame.setExtendedState(JFrame.MAXIMIZED_BOTH); // 最大宽度        frame.setLocationRelativeTo(null);        frame.setVisible(true);    }}
      

  2.   

    Swing第三刀: http://www.iteye.com/topic/707514