Re: [問題] JButton getGraphics
※ 引述《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 蓋在底下
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 208.238.98.1
→
04/24 05:33, , 1F
04/24 05:33, 1F
→
04/24 05:35, , 2F
04/24 05:35, 2F
→
04/24 05:39, , 3F
04/24 05:39, 3F
討論串 (同標題文章)