threadを使ってパネルの上のボタンの位置を動かしています。
repaint();をすると残像が残ってしまいます。
この残像を消したいと思っています。
<試したこと>
ソースの最後に
setOpaque(false);
を書きましたが駄目でした・・・。
これがそのソースです
java
1 public void paintComponent(Graphics g) { 2 Graphics2D g2 = (Graphics2D) g; 3 4 /***ここは周りのボタンです。***/ 5 //周りのボタンの作成 6 //クリエイトボタンを呼び出して自分に張り付ける 7 CreateButton crtButton = new CreateButton(); 8 button = crtButton.createButton(8); 9 for(int i=0;i<button.length;i++){ 10 button[i].addActionListener(new ClickListener()); 11 button[i].addMouseListener(new PopupListener()); 12 this.add(button[i]); 13 } 14 /***ここは周りのボタンです。***/ 15 16 //中心のボタン作成 17 ImageIcon icon = new ImageIcon("X:/center.png"); 18 JButton moveButton = new JButton(icon); 19 //枠けし 20 moveButton.setContentAreaFilled(false); 21 //ボーダーけし 22 moveButton.setBorderPainted(false); 23 //ボタンの表示位置とサイズ設定 24 moveButton.setBounds(x, y, 40, 40); 25 //mouseListenerととモーションListenerをつける 26 moveButton.addMouseListener(this); 27 moveButton.addMouseMotionListener(this); 28 //F12で閉じるため 29 moveButton.addKeyListener(new ClosekeyListener()); 30 31 //ホイール ここでホイールが回った時に真ん中のボタンが動く 32 moveButton.addMouseWheelListener(new ChangeWheelListener()); 33 //パネル(自分)に中心ボタンを乗っける 34 this.add(moveButton); 35 setOpaque(false); 36 37 } 38
どうにか残像を消したいです。
何を書き足せばいいでしょうか?
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/02/16 09:06