當前位置:編程學習大全網 - 電腦編程 - swing編程,JFrame和JPanel設置相同大小,JFrame總是比JPanel大壹點

swing編程,JFrame和JPanel設置相同大小,JFrame總是比JPanel大壹點

別忘記窗口有邊框的。

WIN7下,兩邊邊框約10個piexls

JFrame f = new JFrame("JFrameClientWidth Demo");

f.setSize(400, 300);

f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

Rectangle rc=f.getContentPane().getBounds();

System.out.printf("x=%d, y=%d, width=%d, height=%d\n", rc.x, rc.y, rc.width, rc.height);

結果是:

x=0, y=0, width=392, height=273

  • 上一篇:淄博師範數字媒體畢業去向
  • 下一篇:AT89s51單片機求壹亮燈程序:八個LED,分別是紅黃綠紅黃綠紅黃排列,求高手編程,正確即給分
  • copyright 2024編程學習大全網