该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class lianxi3 extends JFrame implements ActionListener{
JPanel jPanel,jPanel1;
JLabel jLabel;
Imageimage;
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/12.jpg");
jLabel = new JLabel();
jPanel = new JPanel();
jPanel1.add(jButton);
imageIcon = new ImageIcon(image);
jLabel.setIcon(imageIcon);
jPanel.add(jLabel);
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=image.getHeight(jLabel);
int height=image.getWidth(jLabel);
double bigger=1.25;
www=(float)(www*bigger);
hhh=(float)(hhh*bigger);
Math mt = null;
mt.pow(www,hhh);
jLabel.setIcon(imageIcon);
jLabel.setSize((int)www, (int)hhh);
}
public void actionPerformed(ActionEvent e) {
if(e.getSource()==jButton){
big();
}
}
}