List of usage examples for javax.swing JLayeredPane addMouseMotionListener
public synchronized void addMouseMotionListener(MouseMotionListener l)
From source file:components.RootLayeredPaneDemo.java
public RootLayeredPaneDemo(JLayeredPane layeredPane) { super(new GridLayout(1, 1)); //Create and load the duke icon. final ImageIcon icon = createImageIcon("images/dukeWaveRed.gif"); //Create and set up the layered pane. this.layeredPane = layeredPane; layeredPane.addMouseMotionListener(this); //This is the origin of the first label added. Point origin = new Point(10, 100); //This is the offset for computing the origin for the next label. int offset = 35; //Add several overlapping, colored labels to the layered pane //using absolute positioning/sizing. for (int i = 0; i < layerStrings.length; i++) { JLabel label = createColoredLabel(layerStrings[i], layerColors[i], origin); layeredPane.add(label, new Integer(layers[i])); origin.x += offset;//w w w . j a v a 2 s .c om origin.y += offset; } //Create and add the Duke label to the layered pane. dukeLabel = new JLabel(icon); if (icon != null) { dukeLabel.setBounds(15, 225, icon.getIconWidth(), icon.getIconHeight()); } else { System.err.println("Duke icon not found; using black square instead."); dukeLabel.setBounds(15, 225, 30, 30); dukeLabel.setOpaque(true); dukeLabel.setBackground(Color.BLACK); } layeredPane.add(dukeLabel, new Integer(layers[INITIAL_DUKE_LAYER_INDEX]), 0); //Add control pane to this JPanel. add(createControlPanel()); }