src/Pure/GUI/popup.scala
changeset 53783 f5e9d182f645
parent 53250 31f956f42e8d
child 53853 e8430d668f44
equal deleted inserted replaced
53782:3746a78a2c01 53783:f5e9d182f645
       
     1 /*  Title:      Pure/GUI/popup.scala
       
     2     Author:     Makarius
       
     3 
       
     4 Popup within layered pane.
       
     5 */
       
     6 
       
     7 package isabelle
       
     8 
       
     9 
       
    10 import java.awt.{Point, Dimension}
       
    11 import javax.swing.{JLayeredPane, JComponent}
       
    12 
       
    13 
       
    14 class Popup(
       
    15   layered: JLayeredPane,
       
    16   component: JComponent,
       
    17   location: Point,
       
    18   size: Dimension)
       
    19 {
       
    20   def show
       
    21   {
       
    22     component.setLocation(location)
       
    23     component.setSize(size)
       
    24     component.setPreferredSize(size)
       
    25     component.setOpaque(true)
       
    26     layered.add(component, JLayeredPane.POPUP_LAYER)
       
    27     layered.moveToFront(component)
       
    28     layered.repaint(component.getBounds())
       
    29   }
       
    30 
       
    31   def hide
       
    32   {
       
    33     val bounds = component.getBounds()
       
    34     layered.remove(component)
       
    35     layered.repaint(bounds)
       
    36   }
       
    37 }
       
    38