日期:2014-05-20 浏览次数:20882 次
public class Imageshow extends JFrame {
public Imageshow() {
JLabel r1 = new JLabel(" ");
r1.setBounds(100, 200, 200, 100);// 比如放在这个位置
ImageIcon ima = new ImageIcon(("C:\\Users\\vane\\Desktop\\火箭队.jpg"));
ima.setImage(ima.getImage().getScaledInstance(r1.getWidth(),r1.getHeight(), Image.SCALE_DEFAULT));// 压缩图片
r1.setIcon(ima);
// r1=new JLabel(ima);
add(r1);
getContentPane().setBackground(Color.blue);
}
public static void main(String args[]) {
Imageshow fame = new Imageshow();
fame.setSize(700, 500);
fame.setLayout(null);
fame.setDefaultCloseOperation(EXIT_ON_CLOSE);
fame.setVisible(true);
}
}
JLabel r1 = new JLabel(" ");
//r1.setBounds(100, 200, 200, 100);// 比如放在这个位置
ImageIcon ima = new ImageIcon(("C:\\Users\\vane\\Desktop\\火箭队.jpg"));
ima.setImage(ima.getImage().getScaledInstance(r1.getWidth(),r1.getHeight(), Image.SCALE_DEFAULT));// 压缩图片
r1.setIcon(ima);
// r1=new JLabel(ima);
r1.setBounds(100, 200, 200, 100);// 比如放在这个位置
add(r1);
getContentPane().setBackground(Color.blue);
public class Imageshow extends JFrame {
public Imageshow() {
JLabel r1 = new JLabel(" ");
r1.setBounds(100, 200, 200, 100);// 比如放在这个位置
ImageIcon ima = new ImageIcon(("C:\\Users\\vane\\Desktop\\火箭队.jpg"));
ima.setImage(ima.getImage().getScaledInstance(r1.getWidth(),r1.getHeight(), Image.SCALE_DEFAULT));// 压缩图片
r1.setIcon(ima);
// r1=new JLabel(ima);
add(r1);
getContentPane().setBackground(Color.blue);
}
public static void main(String args[]) {
Imageshow fame = new Imageshow();
fame.setSize(700, 500);
fame.setLayout(null);
fame.setDefaultCloseOperation(EXIT_ON_CLOSE);
fame.setVisible(true);
}
}
public Imageshow() {
JLabel r1 = new JLabel(" ");
r1.setBounds(100, 200, 200, 100);// 比如放在这个位置
ImageIcon ima = new ImageIcon(("C:\\Users\\vane\\Desktop\\火箭队.jpg"));
ima.setImage(ima.getImage().getScaledInstance(r1.getWidth(),r1.getHeight(), Image.SCALE_DEFAULT));// 压缩图片
//r1.setIcon(ima);
r1=new JLabel(ima);
add(r1);
getContentPane().setBackground(Color.blue);
}