
代码如下:
eling=new ImageIcon("image/eling.jpg");
myframe=new JFrame();
JLabel mid=new JLabel(eling);
mid.setBounds(0, 0, 400, 300);
mid.setLayout(null);
myframe.add(mid);
myframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
myframe.setLocationRelativeTo(null);
myframe.setResizable(false);
myframe.setVisible(true);
myframe.setSize(500,400);
myframe.setLayout(null);
myframe.repaint();
图片是好的,400*300的大小,但是效果如图所示,只显示了一个角。