java图片 变大了_我下面的Java程序,当点击变大按钮的时候,为什么图片不会变大,...

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼

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();

}

}

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值