src/Tools/jEdit/src/popup.scala
author wenzelm
Wed, 28 Aug 2013 15:14:58 +0200
changeset 53246 8d34caf5bf82
child 53247 bd595338ca18
permissions -rw-r--r--
more elementary Popup via JLayeredPane -- avoid javax.swing.PopupFactory with its many problems and dangers of accidental HeavyWeightPopup (especially on Mac OS X); observe !evt.isConsumed semantically: no initial dismiss here (e.g. due to cursor keys);

/*  Title:      Tools/jEdit/src/popup.scala
    Author:     Makarius

Simple popup within layered pane, based on component with given geometry.
*/

package isabelle.jedit


import isabelle._

import javax.swing.{JLayeredPane, JComponent}


class Popup(
  layered: JLayeredPane,
  component: JComponent) extends javax.swing.Popup()
{
  override def show
  {
    component.setOpaque(true)
    layered.add(component, JLayeredPane.POPUP_LAYER)
    layered.repaint(component.getBounds())
  }

  override def hide
  {
    val bounds = component.getBounds()
    layered.remove(component)
    layered.repaint(bounds)
  }
}