ใครที่มีความสามารถ หรือมีความสนใจในภาษา JAVA ขอให้มาช่วยตอบปัญหา-ตั้งปัญหา ทางด้านนี้ด้วย
การส่งค่า Graphic ให้กับ class จะส่งผ่านกันแบบไหน
//main
{...
Double px = Double.parseDouble(st.nextToken());
Double py = Double.parseDouble(st.nextToken());
DrawComponent point = new DrawComponent(px,py);//บรรทัดนี้
จะส่งค่าให้คลาสยังงัย เพื่อเอาไปพลอตจุด
...}
//
class DrawComponent extends JComponent{
public double _x;
public double _y;
public void paintComponent(Graphics g){
Graphics2D g2 = (Graphics2D) g;
double width = 5;
double height = 5;
Rectangle2D rect = new Rectangle2D.Double(_x,_y,width,height);
g2.draw(rect);
}
}
ขอความกระ
JavaDevil Tue, 10/02/2009 - 20:51
ขอความกระจ่างของคำถามมากกว่านี้ได้หรือเปล่า
แล้วแต่คร
Nohohon Tue, 10/02/2009 - 22:12
แล้วแต่ครับ ตอบยากเพราะคำถามสั้นจัง
ส่วนมากเข
bow_der_kleine Tue, 10/02/2009 - 22:23
ส่วนมากเขาส่งผ่าน method parameter ครับ
BioLawCom.De
ส่งให้คลา
mr_tawan Tue, 10/02/2009 - 22:56
ส่งให้คลาส ... ก็ผ่านทาง static method สิครับ (คลาสมันรับค่าทางอื่นมิได้นิ ?) เอ๊ะ หรือจะผ่านทาง static public variable ... ไม่ดีมั้ง ??
ถ้าส่งเข้า object ก็ผ่านทาง instance method ...
ผมเข้าใจคำถามถูกมั้ยเนี่ย ???
ThaiGameDevX -- The First Game Developer Community in Thailand.
ยังพยายาม
kowito2 Tue, 10/02/2009 - 23:41
ยังพยายามตอบกันได้เนอะ lol
สร้าง window,
khajochi Wed, 11/02/2009 - 15:17
สร้าง window, panel หรือ frame ก่อนแล้วค่อย add component ลงไป
ตัวอย่าง http://kickjava.com/424.htm
ปล. น่าจะตั้งชื่อกระทู้ให้สื่อนิดนึงนะครับ มีแต่ Java โต้งๆ ไม่น่าจะดี
---
Khajochi Blog : It's not a Bug ... It's a Feature
public class Driver
tuckclub Wed, 11/02/2009 - 15:20
public class Driver { public static void main(String[] args) { StringTokenizer st = null;
Double px = Double.parseDouble(st.nextToken()); Double py = Double.parseDouble(st.nextToken()); DrawComponent point = new DrawComponent(px, py); } }
public class DrawComponent extends JComponent { private double _x; private double _y;
public DrawComponent(double _x, double _y) { this._x = _x; this._y = _y; }
public void paintComponent(Graphics g) { Graphics2D g2 = (Graphics2D) g; double width = 5; double height = 5; Rectangle2D rect = new Rectangle2D.Double(_x, _y, width, height); g2.draw(rect); } }
0 เดวลองไป
yochi403 Wed, 11/02/2009 - 18:13
0
เดวลองไปรันดูมั่ง