62,614
社区成员
发帖
与我相关
我的任务
分享
import java.awt.Color;
import java.awt.Dimension;
import java.awt.FlowLayout;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
public class TT extends JFrame{
private static final long serialVersionUID = 1L;
JPanel panel = new JPanel();
JLabel label = new JLabel("tgrf");
TT(){
this.setSize(400, 400);
this.setLayout(new FlowLayout());
this.setBackground(Color.BLACK);
this.add(panel);
panel.setPreferredSize(new Dimension(200,200));
panel.setBackground(Color.BLUE);
panel.add(label);
label.setPreferredSize(new Dimension(100,100));
// label.setIcon(new ImageIcon("关闭.jpg"));
label.setIcon(new ImageIcon(this.getClass().getResource("关闭.jpg")));
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
this.setVisible(true);
}
public static void main(String[] args) {
new TT();
}
}