Re: [問題] 關於actionperformed裡寫程式繪圖
※ 引述《hubin (阿賓  NN)》之銘言:
: ※ 引述《neigence (心夜)》之銘言:
: : 為什麼不把paint拉出去外面寫呢? 程式呼叫repaint()時 自已就會去找paint這個
: : method了
: : public class ???? extends JFrame{
: : public itemListener implements Actionlistener{
: : public void actionPerformed(ActionEvent event){
: : repaint();
: : }
: : }
: : public void paint(Graphics g){
: : // do something
: : }
: : }
: 我照了你的方式去寫:
: public class itemHandler extends JFrame implements ActionListener{
: public void actionPerformed(ActionEvent event){
: repaint(); //這行出現錯誤訊息
: }
: public void paint(Graphics g){
: g.drawLine(Painter.x1,Painter.y1,Painter.x2,Painter.y2);
: }
: }
多加了extends JFrame現在可以了~~
但還是有點問題~我在試一下,似乎也是handler的問題……
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.115.206.17
討論串 (同標題文章)
以下文章回應了本文:
完整討論串 (本文為第 8 之 12 篇):