利用JFrame继承java.awt.Container类的函数getInsets()。该函数返回insets类。 

 1 import java.awt.Insets;
 2 import javax.swing.JFrame;
 3 
 4 
 5 public class FrameTitleBarLength {
 6 
 7     public static void main(String[] args) {
 8         JFrame frame = new JFrame("获取标题栏大小");
 9         frame.setBounds(104, 104, 1, 26);
10         frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
11         frame.setVisible(true);
12         Insets inset = frame.getInsets();
13     
14         System.out.println(inset);
15         System.out.println(inset.bottom);
16     }
17 }

  

  通过计算,默认情况下,标题栏的高度应该是26像素。

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-15
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-04-08
  • 2021-11-14
  • 2022-12-23
相关资源
相似解决方案