java为什么我不能移动JLabel图标?
为什么我不能更改图标的x和y坐标?我真正需要的就是把图像添加到屏幕上。我甚至需要使用JLabel吗
package bit;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
public class BIT extends JFrame
{
JLabel CL;
public BIT()
{
CL = new JLabel(new ImageIcon(this.getClass().getResource("final-image.jpg")));
CL.setBounds(0,0,100,100);
this.getContentPane().add(CL);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setBounds(5,5,1000,500);
this.setResizable(false);
this.setVisible(true);
}
public static void main(String[] args)
{
new BIT();
}
}
# 1 楼答案
在添加带有设置框的控件之前,取消设置JFrame的布局