簡體   English   中英

jcomponents的寬度和高度

[英]jcomponents width and height

  int width = getWidth();
  int height = getHeight();

 switch(type) {
  case LINE: // Display two cross lines
   g.setColor(Color.BLACK);
  g.drawLine(10, 10, width - 10, height - 10);
  g.drawLine(width - 10, 10, 10, height - 10);
  break;

有人可以幫我解釋一下嗎?

  1. 這里的寬度和高度是多少?

  2. 我以為

      drawline( int x1, int y1, int x2, int y2), 

那我為什么要使用寬度和高度?

int width = getWidth();
int height = getHeight();

這些代表您要繪制到的JPanel的寬度和高度。 這使您可以將X繪制成與面板/窗口一樣大。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM