嗨,我只是想知道如何在不使用frame.setLocationRelativeTo(null)
的情况下使x和y轴从jframe的中心开始,因为我希望能够使jframe跟随我的光标,现在它将jframe的左上角放在我的光标上,但我希望它在中心。谢谢
的任务非常简单
int newX=cursorX-frame.getWidth()/2;
int newY=cursorY-frame.getHeight()/2;
和
frame.setLocation(newX,newY);
这将定位你的框架,鼠标光标将在它的中间