次のコードを使用して、カスタマイズされた JToolbar を使用しています。
public class GeneralToolbar extends JToolBar{
public GeneralToolbar() {
super();
setBackground(Color.white);
setOpaque(true);
setPreferredSize(new Dimension(54,54));
setMinimumSize(new Dimension(54,54));
setMaximumSize(new Dimension(54,54));
setSize(new Dimension(54,54));
}
public void paintComponent(Graphics g) {
super.paintComponent(g);
Dimension size = this.getSize();
ImageIcon image = DefaultAction.createImageIcon("/com/aaa/resources/tabback");
g.drawImage(image.getImage(), 0,0, size.width, size.height, this);
}
}
これで画像が表示されます。しかし、ボタンの周りに不透明な長方形が表示されます。ボタンを不透明に設定しようとしましたが、何も影響しませんでした。サポートしてくれてありがとう