62,614
社区成员
发帖
与我相关
我的任务
分享
JLabel lable=new JLabel();
lable.setIcon(new ImageIcon(ImageUtil.loadImage("logo.png")));
lable.setOpaque(false);
this.getContentPane().add(lable);
this.getContentPane().add(wwd);
public class MyImageButton extends JButton {
Image image =ImageUtil.loadImage("logo.png");
public MyImageButton(String text) {
super(text);
setOpaque(false);
setFocusable(true);
setBorderPainted(false);
this.setPreferredSize(new Dimension(image.getWidth(this), image
.getHeight(this)));
}
@Override
protected void paintComponent(Graphics g) {
g.drawImage(image,
0,
0,
null);
}
}
this.wwd = new WorldWindowGLCanvas();
JButton button = new MyImageButton("按钮");
button.setSize(new Dimension(32,32));
button.setMargin(new Insets(1, 1, 0, 0));
button.setBorderPainted(false);
button.setContentAreaFilled(false);
button.setAlignmentX(0);
button.setAlignmentY(0);
//button.setOpaque(false);
this.getContentPane().add(button,0);
//this.getContentPane().add
this.getContentPane().add(wwd,1);