Re: [問題] JButton getGraphics
※ 引述《willieliao (Willie Liao)》之銘言:
: ※ 引述《lovesneakers (sneakers)》之銘言:
: : public class NewBtn extends JFrame {
: : public NewBtn() {
: : setSize(100, 100);
: class myButton extends JButton {
: public void paint(Graphics g) {
: super.paint(g);
: g.setColor(Color.BLUE);
: g.fillOval(0, 0, 100, 100);
: }
: public myButton(String label) {
: super(label);
: }
: }
: myButton btn = new MyButton("Whatever");
: getContentPane().add(btn);
: : setVisible(true);
: : }
: : public static void main(String[] args)
: : {
: : new NewBtn();
: : }
: : }
: : 請問我要像上面的方法, 在生出 JButton 後改變其 Graphics
: : 能辦到嗎? 不用繼承的方法
: : 我試的結果似乎都會被它的 text 蓋在底下
謝謝你的回覆
因為我想辦到 JButton 的 Graphics 是由其它物件幫它畫
有沒有辦法這樣子
別的物件畫好一個 Canvas, 然後把這個 Canvas 所成的圖像
畫到 JButton 上面
謝謝回覆
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 61.222.64.14
推
04/25 04:44, , 1F
04/25 04:44, 1F
推
04/25 04:46, , 2F
04/25 04:46, 2F
討論串 (同標題文章)