java鼠标改变窗口大小监听事件_java – 当用户拖动鼠标时,监听JFrame调整事件大小?...
當用戶單擊JFrame的角落來調整大小并拖動鼠標時,JFrame會根據用戶拖動時鼠標的當前位置重繪。你怎么聽這些事件?
下面是我目前嘗試的:
public final class TestFrame extends JFrame {
public TestFrame() {
this.addComponentListener(new ComponentAdapter() {
public void componentResized(ComponentEvent e) {
// This is only called when the user releases the mouse button.
System.out.println("componentResized");
}
});
}
// These methods do not appear to be called at all when a JFrame
// is being resized.
@Override
public void setSize(int width, int height) {
System.out.println("setSize");
}
@Override
public void setBounds(Rectangle r) {
System.out.println("setBounds A");
}
@Override
public void setBounds(int x, int y, int width, int height) {
System.out.println("setBounds B");
}
}
如何確定和約束用戶如何調整窗口(基于窗口的當前寬高比)的大小,當他們圍繞鼠標拖動?
總結
以上是生活随笔為你收集整理的java鼠标改变窗口大小监听事件_java – 当用户拖动鼠标时,监听JFrame调整事件大小?...的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 为什么我没有微粒贷?怎么才能开通微粒贷?
- 下一篇: java class文件 代码_java