请教JFrame定位

withchenlei 2011-05-06 05:03:03
我的目标是新建一个容器,然后始终位于屏幕正中。
查看了下API,但是这点没弄懂,求众编友点拨。
下面是API原文,这个真没看懂

public JFrame(String title,
GraphicsConfiguration gc)
创建一个具有指定标题和指定屏幕设备的 GraphicsConfiguration 的 JFrame。
此构造方法将组件的 locale 属性设置为 JComponent.getDefaultLocale 所返回的值。

参数:
title - 要显示在窗体边框中的标题。将 null 值视为空字符串 ""。
gc - 用于构造新 JFrame 的 GraphicsConfiguration;如果 gc 为 null,则使用系统默认的 GraphicsConfiguration
抛出:
IllegalArgumentException - 如果 gc 不是来自屏幕设备。GraphicsEnvironment.isHeadless() 返回 true 时总是抛出此异常。
...全文
64 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
withchenlei 2011-05-07
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 biaogege 的回复:]

你应该查看的是JFrame下的方法,而不是构造函数
setBounds(int x, int y, int width, int height)、setLocation(int x, int y)
[/Quote]

Thank you !
biaogege 2011-05-06
  • 打赏
  • 举报
回复
你应该查看的是JFrame下的方法,而不是构造函数
setBounds(int x, int y, int width, int height)、setLocation(int x, int y)

23,407

社区成员

发帖
与我相关
我的任务
社区描述
Java 非技术区
社区管理员
  • 非技术区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧