在这个java程序中,如果要图片充满整个框,在不改变框的大小,图片可以扩大情况下,程序怎样修改
importjavax.swing.*;importjava.awt.event.*;publicclasscccextendsJFrame{JLabeln1;Image...
import javax.swing.*;
import java.awt.event.*;
public class ccc extends JFrame{
JLabel n1;
ImageIcon n2;
public ccc(){
n2=new ImageIcon("D:\\111.JPG");
n1=new JLabel(n2);
this.add(n1);
pack();
this.setSize(600,600);
this.setVisible(true);
this.addWindowListener(new WindowAdapter(){
public void windowCloing(WindowEvent e)
{System.exit(0);}});
}
public static void main(String[] args) {
new ccc();
}
} 展开
import java.awt.event.*;
public class ccc extends JFrame{
JLabel n1;
ImageIcon n2;
public ccc(){
n2=new ImageIcon("D:\\111.JPG");
n1=new JLabel(n2);
this.add(n1);
pack();
this.setSize(600,600);
this.setVisible(true);
this.addWindowListener(new WindowAdapter(){
public void windowCloing(WindowEvent e)
{System.exit(0);}});
}
public static void main(String[] args) {
new ccc();
}
} 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询