Class Dialog

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible
Direct Known Subclasses:
FileDialog, JDialog

public class Dialog extends Window
Emulator for Dialog, rendered by SFrame.
See Also:
  • Field Details

    • DEFAULT_MODALITY_TYPE

      public static final Dialog.ModalityType DEFAULT_MODALITY_TYPE
      AWT's default modality type for setModal(true) and the boolean-taking ctors: APPLICATION_MODAL.
  • Constructor Details

  • Method Details

    • getTitle

      public String getTitle()
      The title, which is null if the dialog was given none — unlike Frame.getTitle().
    • setTitle

      public void setTitle(String title)
    • isModal

      public boolean isModal()
      AWT contract: isModal() returns modalityType != MODELESS.
    • setModal

      public void setModal(boolean modal)
      AWT shape: setModal(true) sets the modality type to DEFAULT_MODALITY_TYPE (APPLICATION_MODAL); setModal(false) sets it to MODELESS. The actual modal flag is stored on the modality-type field.
    • getModalityType

      public Dialog.ModalityType getModalityType()
    • setModalityType

      public void setModalityType(Dialog.ModalityType type)
      Store the modality type and mirror the bool (!= MODELESS) to the Vaadin Dialog peer so the overlay traps focus correctly. Null coerces to MODELESS per AWT contract.
    • isResizable

      public boolean isResizable()
    • setResizable

      public void setResizable(boolean resizable)
      Also drives the peer's resize grips, since a Vaadin Dialog overlay has real ones. Fires no PropertyChangeEvent, unlike Frame.setResizable(boolean).
    • isUndecorated

      public boolean isUndecorated()
    • setUndecorated

      public void setUndecorated(boolean b)
    • setOpacity

      public void setOpacity(float opacity)
      Description copied from class: Window
      AWT's other two throws are not reproduced, and deliberately: both ask the platform whether it can do translucency at all — a browser can, so the answers would be "yes, supported" and the throws unreachable. What is declined is the peer push, so the window renders fully opaque.
      Overrides:
      setOpacity in class Window
      Parameters:
      opacity - in [0, 1]
    • setShape

      public void setShape(Shape shape)
      Overrides:
      setShape in class Window
    • setBackground

      public void setBackground(Color bgColor)
      Overrides:
      setBackground in class Window
    • setVisible

      public void setVisible(boolean b)
      The blocking-modal park splits across show() and hide(), where the JDK puts it, so this stays the JDK's own pure delegation:
      • show() — after super.show() has opened the peer, isModal() parks the caller on a fresh future until close.
      • hide() — releases any modal latch, mirroring JDK Dialog's contract that a programmatic hide unblocks a parked modal show.
      Overrides:
      setVisible in class Window
    • show

      public void show()
      Show, then (if modal) block — two steps, not one, which is what lets a background thread show a modal at all.

      The JDK's own shape, from java.awt.Dialog.show() / WaitDispatchSupport.enter(): conditionalShow realises the dialog first, and only then does a modal enter its secondary loop — which, for a non-EDT caller, posts the pump to the EDT and blocks the caller alone. So real Swing blocks exactly one thread while the EDT stays free to deliver the click that ends it. Vaadin's request threads play the EDT's part: super.show() hops the peer write onto the UI thread and returns, and the caller blocks below, outside that hop.

      Overrides:
      show in class Window
    • blocksAfterVisibilityChange

      protected boolean blocksAfterVisibilityChange(boolean b)
      A modal show is followed by parkUntilClose, so its peer write is the one that must not be quietly dropped — see Window.blocksAfterVisibilityChange(boolean).
      Overrides:
      blocksAfterVisibilityChange in class Window
      Parameters:
      b - the visibility being applied, since only a show can be followed by a park
    • hide

      public void hide()
      Overrides:
      hide in class Window
    • dispose

      public void dispose()
      Override of Window.dispose() that releases any modal latch after the standard dispose work — mirrors JDK Dialog's "dispose unblocks a parked modal show" contract.
      Overrides:
      dispose in class Window
    • processWindowEvent

      protected void processWindowEvent(WindowEvent e)
      Release on peer-originated close too. WINDOW_CLOSING fires via Window.processWindowEvent(WindowEvent) for ESC / outside-click / header close. JDialog's close-op switch may dispose (which releases too — countDown is idempotent on a 1-count latch), but HIDE_ON_CLOSE closes the peer without disposing, and that path also needs to release the latch.
      Overrides:
      processWindowEvent in class Window
    • getAccessibleContext

      public AccessibleContext getAccessibleContext()
      Specified by:
      getAccessibleContext in interface Accessible
      Overrides:
      getAccessibleContext in class Window
    • paramString

      protected String paramString()
      Overrides:
      paramString in class Container