[英]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;
有人可以幫我解釋一下嗎?
這里的寬度和高度是多少?
我以為
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.