here is some code for a glasspane that I have.
For some reason, it never hits the paintComponent.
My program does:
public class GlassPane extends JPanel {
/** Creates a new instance of glassPane */
public GlassPane() {
}
public void cashierAction(JPanel panel, int initialX, int initialY) {
frame = (JFrame)SwingUtilities.getAncestorOfClass(JFrame.class, panel);
glass = (JPanel) frame.getGlassPane();
//glass.setLayout(null);
xPos = initialX;
yPos = initialY;
glass.setVisible(true);
cashierAnimation = true;
repaint();
}
public void paintComponent(Graphics g) {
Graphics2D g2d = (Graphics2D)g;
super.paintComponent(g);
if(cashierAnimation) {
g2d.drawImage(this.dollarSign, xPos, yPos, 10, 10, null);
}
}
private JFrame frame;
private JPanel glass;
private int xPos;
private int yPos;
private boolean cashierAnimation = false;
private ImageIcon dollarImg = new ImageIcon("Data/Icons/dollar.gif");
private Image dollarSign = dollarImg.getImage();
}
Any ideas why it is not running the paintComponent?
I am pretty new to glass panes, I have gotten them to work with buttons, and other items, but painting on them is driving me crazy.