Home > Java > javaTutorial > How to center a form in java

How to center a form in java

藏色散人
Release: 2020-05-21 10:57:15
Original
3857 people have browsed it

How to center a form in java

#How to center a form in java?

// 设置窗体大小
int windowsWedth = 600;
int windowsHeight = 600;
// 得到显示器屏幕的宽高
int width = Toolkit.getDefaultToolkit().getScreenSize().width;
int height = Toolkit.getDefaultToolkit().getScreenSize().height;
//设置窗体在显示器居中显示
this.setBounds((width - windowsWedth) / 2,
(height - windowsHeight) / 2, windowsWedth, windowsHeight);
Copy after login

This is the centering code in the program I wrote. Try it. It should work!

Recommended: "java learning"

The above is the detailed content of How to center a form in java. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
Install JAVA
From 1970-01-01 08:00:00
0
0
0
Unable to install java
From 1970-01-01 08:00:00
0
0
0
Can java be used as the backend of the web?
From 1970-01-01 08:00:00
0
0
0
Is this in Java language?
From 1970-01-01 08:00:00
0
0
0
Help: JAVA encrypted data PHP decryption
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template