发布网友 发布时间:2022-04-22 07:40
共2个回答
热心网友 时间:2023-07-05 13:09
import java.awt.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.*;
public class app//类名最好大写
{
static JFrame frm =new JFrame("清扫机器人模拟界面");
static ImageIcon bg = new ImageIcon("456.jpg");//背景图片名称,相对路径
static JLabel lab=new JLabel(bg);//图片放在标签里
public static void main(String[] args) {
lab.setBounds(0, 0, bg.getIconWidth(), bg.getIconHeight());//设置图片的大小
frm.getLayeredPane().add(lab,new Integer(Integer.MIN_VALUE));//把图片设置在第二层
JPanel jp = (JPanel) frm.getContentPane();//获取最上层JPanel
jp.setOpaque(false);//设置为透明
//JPanel jp2 = new JPanel();//如果要加按钮什么的就在这个jp2里面加,不需要的话就用了
//jp2.setOpaque(false);
//frm.add(jp2);
frm.setLayout(null);
frm.setSize(1300,700);
//frm.setBackground(Color.blue);
frm.setVisible(true);
frm.addWindowListener(new WindowAdapter() {//关闭窗口的方法没写
@Override
public void windowClosing(WindowEvent e) {
frm.setVisible(false);
System.exit(0);
}
});
}
}追问?是什么
热心网友 时间:2023-07-05 13:10
建个web项目新建就行啦