看板 java 關於我們 聯絡資訊
不好意思: 小的意思是這樣的... 因為書上/網路上看到的都是長這樣的 畫圖: import java.awt.*; import java.awt.event.*; import javax.swing.*; public class InputDialog2 { public static void main(String[] args) { InputDialog2Frame f=new InputDialog2Frame(); f.setVisible(true); } } class InputDialog2Frame extends JFrame { InputDialog2Frame() { super( "InputDialog2 "); setDefaultCloseOperation(EXIT_ON_CLOSE); setLocation(400,300); setSize(300,200); ButtonPane p=new ButtonPane(); Container c=getContentPane(); c.add(p); } } class ButtonPane extends JPanel { String input= " "; ButtonPane() { JButton click=new JButton( "click me "); add(click); click.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { input=JOptionPane.showInputDialog(this, "Please input something "); repaint(); } }); } protected void paintComponent(Graphics g) { super.paintComponent(g); g.drawString(input, 50,100); } } 簡單來說 就是畫圖的method: paintComponent() 一定要放在繼承JPanel的class裡面 才能劃劃 ------------------------------------------------------------ 但是我想要把JPanel 當成參數傳給畫圖method 讓畫圖的method 在上面畫畫 OR 或是把JPanel 和 畫圖的method 拆開 我就是不能把畫圖的方法寫在JPanel裡面 ,可是這樣一來,Graphics g一劃,就不知道要畫到哪去... 該怎麼好呢? 因為每個不同的class有不同的劃法阿! 我只能在適當時call用該劃此元件 的method阿...不能只有一個paintComponent阿... 好痛苦阿xd... 為什麼 Google 大家都寫得一樣 T-T -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.115.155.193
chchwy:當然可以傳阿 為什麼不能傳 11/07 02:08
PsMonkey:你有沒有先試試看再過來問? 11/07 09:24
m13m13m:有阿 樓上你口氣是怎樣? 版主可以那麼兇嗎? 11/07 18:32
m13m13m:幾乎得不到答案的版 管理方式又囉哩八縮的 一直殺我文章 k 11/07 18:34
Aussie0117:因為問的問題深度不夠...所以...請私下寄信問問好了 11/07 22:27
cjcat2266:1)板有板規,請遵守 2)板主又辛苦人又nice,不兇不兇 11/08 16:36
narsilx:說真的 別人沒有義務要回答你阿.. 11/08 17:44