如何“做某事"?在Swing组件上调整大小? [英] How to "do something" on Swing component resizing?

查看:53
本文介绍了如何“做某事"?在Swing组件上调整大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个扩展 JPanel 的类.我重写了受保护的void paintComponent(Graphics g).

I've a class which extends JPanel. I overwrote protected void paintComponent(Graphics g).

当面板尺寸改变时,必须重新计算一个变量.如何以适当的方式做到这一点?

There is a variable which has to be recalculated when the panel's dimensions change. How do I do that in a proper way?

推荐答案

如果我正确理解了这个问题,那么您应该阅读

If I understand the question correctly then you should read the section from the Swing tutorial on How to Write a Component Listener which shows you how to listen for a change in a components size.

这篇关于如何“做某事"?在Swing组件上调整大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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