Search in sources :

Example 1 with PainterGlasspane

use of org.jdesktop.swingx.painter.PainterGlasspane in project CodenameOne by codenameone.

the class BaseForm method setOverrideMode.

public synchronized void setOverrideMode(boolean overrideMode, java.awt.Component c) {
    RootPaneContainer r = (RootPaneContainer) SwingUtilities.windowForComponent(c);
    if (overrideMode) {
        if (overrideImage == null) {
            overrideImage = new ImageIcon(getClass().getResource("/override_stamp.png"));
        }
        PainterGlasspane pg = new PainterGlasspane();
        MattePainter matte = new MattePainter(new Color(0xcc, 0xcc, 0xcc, 120)) {

            protected void doPaint(java.awt.Graphics2D g, java.lang.Object component, int width, int height) {
                super.doPaint(g, component, width, height);
                overrideImage.paintIcon(BaseForm.this, g, 0, 0);
            // g.drawImage(overrideImage.getImage(), width / 2 - overrideImage.getIconWidth() / 2, 0, BaseForm.this);
            }
        };
        pg.setPainter(matte);
        pg.addTarget(this);
        r.setGlassPane(pg);
        pg.setBounds(0, 0, r.getContentPane().getWidth(), r.getContentPane().getHeight());
        pg.setVisible(true);
    } else {
        r.setGlassPane(new JLabel());
    }
}
Also used : MattePainter(org.jdesktop.swingx.painter.MattePainter) ImageIcon(javax.swing.ImageIcon) Color(java.awt.Color) RootPaneContainer(javax.swing.RootPaneContainer) JLabel(javax.swing.JLabel) PainterGlasspane(org.jdesktop.swingx.painter.PainterGlasspane) Graphics2D(java.awt.Graphics2D)

Aggregations

Color (java.awt.Color)1 Graphics2D (java.awt.Graphics2D)1 ImageIcon (javax.swing.ImageIcon)1 JLabel (javax.swing.JLabel)1 RootPaneContainer (javax.swing.RootPaneContainer)1 MattePainter (org.jdesktop.swingx.painter.MattePainter)1 PainterGlasspane (org.jdesktop.swingx.painter.PainterGlasspane)1