- JDK :OpenJDK-11
- OS :CentOS 7.6.1810
- IDE :Eclipse 2019‑03
- typesetting :Markdown
code
package per.jizuiku.gui;
import java.awt.Dimension;
import java.awt.Frame;
import java.awt.Point;
/**
* @author 给最苦
* @date 2019/06/30
* @blog www.cnblogs.com/jizuiku
*/
public class Demo {
/**
* @param args
*/
public static void main(String[] args) {
// 创建窗体对象 相当于 创建了一个线程
Frame f = new Frame();
// 设置窗体的标题
// Frame(String title) 可以通过构造函数来设置
f.setTitle("第一个窗口程序");
// 设置窗体的大小,单位是像素
int width = 400;
int height = 500;
Dimension d = new Dimension(width, height);
f.setSize(d);
// 设置窗体出现的位置
int x = 300;
int y = 200;
Point p = new Point(x, y);
f.setLocation(p);
// f.setBounds(x, y, width, height);
// 可以通过这个函数 一次性设置窗口的位置和大小s
// 让窗体显示出来
f.setVisible(true);
}
}
result
sourceCode
/**
* {@inheritDoc}
* <p>
* The {@code d.width} and {@code d.height} values
* are automatically enlarged if either is less than
* the minimum size as specified by previous call to
* {@code setMinimumSize}.
* <p>
* The method changes the geometry-related data. Therefore,
* the native windowing system may ignore such requests, or it may modify
* the requested data, so that the {@code Window} object is placed and sized
* in a way that corresponds closely to the desktop settings.
*
* @see #getSize
* @see #setBounds
* @see #setMinimumSize
* @since 1.6
*/
public void setSize(Dimension d) {
super.setSize(d);
}
/**
* {@inheritDoc}
* <p>
* The method changes the geometry-related data. Therefore,
* the native windowing system may ignore such requests, or it may modify
* the requested data, so that the {@code Window} object is placed and sized
* in a way that corresponds closely to the desktop settings.
*/
@Override
public void setLocation(Point p) {
super.setLocation(p);
}
resource
- [ JDK ] openjdk.java.net
- [ doc - 参考 ] docs.oracle.com/en/java/javase/11
- [ 规范 - 推荐 ] yq.aliyun.com/articles/69327
- [ 规范 - 推荐 ] google.github.io/styleguide
- [ 源码 ] hg.openjdk.java.net
- [ OS ] www.centos.org
- [ IDE ] www.eclipse.org/downloads/packages
- [ 平台 ] www.cnblogs.com
感谢帮助过 给最苦 的人们。
Java、Groovy和Scala等基于JVM的语言,优秀,值得学习。
规范的命名和代码格式等,有助于沟通和理解。
JVM的配置、监控与优化,比较实用,值得学习。