是否有 JFrame.getBounds 等效项仅获取实际客户区域?

发布于 2024-12-02 11:16:54 字数 87 浏览 6 评论 0原文

而不是整个窗口都带有关闭、最大化和最小化按钮以及边框?

我正在尝试保存客户区的屏幕截图...maximizedBounds 使应用程序崩溃...

Instead of the whole window complete with close, maxi- and minimize buttons, as well as border?

I'm trying to save a screenshot of the client area...maximizedBounds crashes the app...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

天涯沦落人 2024-12-09 11:16:54

获取内容窗格的边界(即 JFrame.getContentPane().getBounds())。

Get the bounds of the content pane instead (i.e. JFrame.getContentPane().getBounds()).

风苍溪 2024-12-09 11:16:54

这做到了这一点:

   Point pos = this.getContentPane().getLocationOnScreen();
   Rectangle clientRect = this.getContentPane().getBounds(); 
   clientRect.x = pos.x;
   clientRect.y = pos.y;

This did the trick:

   Point pos = this.getContentPane().getLocationOnScreen();
   Rectangle clientRect = this.getContentPane().getBounds(); 
   clientRect.x = pos.x;
   clientRect.y = pos.y;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文