单击按钮如何绘画 [英] How to paint with button click

查看:66
本文介绍了单击按钮如何绘画的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在单击鼠标时调用paintComponent?

how to call a paintComponent when a mouse click ?

推荐答案

如何通过单击按钮传递我的值?

how to pass my values by button click?

如何更改JLabel或JButton中的文本?您使用setText(...)方法.

How do you change text in a JLabel or a JButton? You use the setText(...) method.

那么,如何在DisplayPanel中显示摄氏度值?

So how do you display the celsius value in your DisplayPanel?

在DisplayPanel类中创建一个 setCelsius(...)方法.在该方法中,您将celsius值另存为类中的实例变量,然后调用repaint().

Well you create a setCelsius(...) method in your DisplayPanel class. In that method you save the celsius value as an instance variable in your class and you invoke repaint().

然后在您的 paintComponent()方法中,使用保存的celcius进行自定义绘制.

Then in your paintComponent() method you use the saved celcius to do your custom painting.

因此,在ActionListner中,您可以计算摄氏度,然后调用

So in your ActionListner you calculate the Celsius and then invoke

displayPanel.setCelsius( Celsius );

这篇关于单击按钮如何绘画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆