import java.awt.event.*;
import javax.swing.*;
public class GlassTest extends JFrame {
JButton bn=new JButton("Button");
public GlassTest(){
setBounds(100,100,400,500);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
init();
}
void init(){
JPanel p=new JPanel(null);
p.add(bn);
bn.setSize(100,100);
bn.setLocation(100,100);
p.setOpaque(false);
getRootPane().setGlassPane(p);
p.setVisible(true);
getContentPane().add("South",new JButton("Background"));
addMouseMotionListener(new MouseMotionAdapter(){
public void mouseMoved(MouseEvent e){
bn.setLocation(e.getX()-20,e.getY()-20);
}
});
}
public static void main(String[] args){
new GlassTest().show();
}
}