1 /* Copyright (C) 2005-2011 Fabio Riccardi */ 2 3 package com.lightcrafts.ui.operation; 4 5 import javax.swing.*; 6 import java.awt.*; 7 import java.awt.event.MouseAdapter; 8 import java.awt.event.MouseMotionAdapter; 9 10 // A translucent overlay component that OpControls place on top of their 11 // other controls when they are in locked mode, to give a grayed look and to 12 // intercept input events. 13 14 class LockedOverlay extends JPanel { 15 16 private final static Color OverlayColor = new Color(128, 128, 128, 128); 17 LockedOverlay()18 LockedOverlay() { 19 // Swallow events so they don't propagate to underlying widgets. 20 addMouseListener(new MouseAdapter() {}); 21 addMouseMotionListener(new MouseMotionAdapter() {}); 22 setOpaque(false); 23 } 24 paintComponent(Graphics g)25 protected void paintComponent(Graphics g) { 26 Color oldColor = g.getColor(); 27 g.setColor(OverlayColor); 28 Dimension size = getSize(); 29 g.fillRect(0, 0, size.width, size.height); 30 g.setColor(oldColor); 31 } 32 } 33