试了十分钟终于好了,你看看
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class lianxi3 extends JFrame implements ActionListener{
JPanel jPanel,jPanel1;
JLabel jLabel;
Image image;
ImageIcon imageIcon;
JButton jButton;
float www=1;
float hhh=1;
public lianxi3() {
super("图片");
jPanel1=new JPanel();
jButton = new JButton("变大");
jButton.addActionListener(this);
image = Toolkit.getDefaultToolkit().getImage("src/1.jpg");
jLabel = new JLabel();
jPanel1.add(jButton);
imageIcon = new ImageIcon(image);
jLabel.setIcon(imageIcon);
this.add(jLabel, BorderLayout.NORTH);
this.add(jPanel1, BorderLayout.SOUTH);
this.setVisible(true);
this.setSize(600, 600);
}
public static void main(String[] args) {
new lianxi3();
}
public void big(){
int width=imageIcon.getIconWidth();
int height=imageIcon.getIconWidth();
double bigger=1.25;
www=(float)(width*bigger);
hhh=(float)(height*bigger);
System.out.println(www+""+hhh);
Math.pow(www,hhh);
image = image.getScaledInstance((int)www, (int)hhh, Image.SCALE_DEFAULT);
imageIcon = new ImageIcon(image);
//jLabel.setSize((int)www, (int)hhh);
jLabel.setIcon(imageIcon);
}
public void actionPerformed(ActionEvent e) {
if(e.getSource()==jButton){
big();
}
}
}
how many?
看样子我得好好看看你这个怎么实现的...