package Rong;
import java.awt.Color;
import java.awt.Image;
import java.awt.Toolkit;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
public class Demo extends JFrame implements Runnable {
private static final long serialVersionUID = 1L;
private int width = 0;
private int height = 0;
ImageIcon bg= new ImageIcon("D:/1.jpg");//背景图片
JPanel panel=new JPanel();
JLabel label=new JLabel(bg);
public Demo() {
this.setUndecorated(true);//无标题栏
this.setSize(0, 0);//初始大小
this.setLocation(400, 250);//窗口位置
this.getContentPane().add(label);
this.getContentPane().setBackground(Color.BLACK);
Image img=Toolkit.getDefaultToolkit().getImage("D:/star.png");
this.setIconImage(img);//图标
this.setVisible(true);//设置可见
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);//默认关闭方式
}
public static void main(String[] args) {
Demo demo = new Demo();
new Thread(demo).start();
}
//窗口慢慢变大
public void run() {
while (this.width < 300) {
width++;
height++;
this.setSize(width, height);
repaint();
try {
Thread.sleep(20);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
import java.awt.Color;
import java.awt.Image;
import java.awt.Toolkit;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
public class Demo extends JFrame implements Runnable {
private static final long serialVersionUID = 1L;
private int width = 0;
private int height = 0;
ImageIcon bg= new ImageIcon("D:/1.jpg");//背景图片
JPanel panel=new JPanel();
JLabel label=new JLabel(bg);
public Demo() {
this.setUndecorated(true);//无标题栏
this.setSize(0, 0);//初始大小
this.setLocation(400, 250);//窗口位置
this.getContentPane().add(label);
this.getContentPane().setBackground(Color.BLACK);
Image img=Toolkit.getDefaultToolkit().getImage("D:/star.png");
this.setIconImage(img);//图标
this.setVisible(true);//设置可见
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);//默认关闭方式
}
public static void main(String[] args) {
Demo demo = new Demo();
new Thread(demo).start();
}
//窗口慢慢变大
public void run() {
while (this.width < 300) {
width++;
height++;
this.setSize(width, height);
repaint();
try {
Thread.sleep(20);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}