src/Pure/GUI/popup.scala
author wenzelm
Tue, 09 Jan 2024 23:52:02 +0100
changeset 79459 c53c261d91b9
parent 75393 87ebf5a50283
child 80552 973d276e130e
permissions -rw-r--r--
minor performance tuning, for important special case where consts are already expanded (e.g. re-certification within proof procedure);

/*  Title:      Pure/GUI/popup.scala
    Author:     Makarius

Popup within layered pane.
*/

package isabelle


import java.awt.{Point, Dimension}
import javax.swing.{JLayeredPane, JComponent}


class Popup(
  layered: JLayeredPane,
  component: JComponent,
  location: Point,
  size: Dimension
) {
  def show: Unit = {
    component.setLocation(location)
    component.setSize(size)
    component.setPreferredSize(size)
    component.setOpaque(true)
    layered.add(component, JLayeredPane.DEFAULT_LAYER)
    layered.moveToFront(component)
    layered.repaint(component.getBounds())
  }

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