Class ComponentWidget

java.lang.Object
org.netbeans.api.visual.widget.Widget
org.netbeans.api.visual.widget.ComponentWidget
All Implemented Interfaces:
Accessible, org.openide.util.Lookup.Provider

public class ComponentWidget extends Widget
This widget allows to use an AWT/Swing component in the scene. The widget itself just represents and reserve the place occupied by the component. When a component is resized, then reserved place is recalculated. The component placement is automatically update based on the placement of the widget. The widget also paints the component in the satelite views.

When a widget is added into the scene, it has to attach a scene listener for automatic recalculation. The attaching is done automatically for the first time.

  • Constructor Details

    • ComponentWidget

      public ComponentWidget(Scene scene, Component component)
      Creates a component widget.
      Parameters:
      scene - the scene
      component - the AWT/Swing component
  • Method Details

    • getComponent

      public final Component getComponent()
      Returns a AWT/Swing component.
      Returns:
      the AWT/Swing component
    • isComponentVisible

      public final boolean isComponentVisible()
      Returns whether the component should be visible.
      Returns:
      true if the component is visible
    • setComponentVisible

      public final void setComponentVisible(boolean componentVisible)
      Sets whether the component should be visible.
      Parameters:
      componentVisible - if true, then the component is visible
    • notifyAdded

      protected final void notifyAdded()
      Description copied from class: Widget
      This method is called to notify that the view is shown. Note: You must not modify a tree of widgets from within this method. It means: do not call addChild, removeChild and similar methods.
      Overrides:
      notifyAdded in class Widget
    • notifyRemoved

      protected final void notifyRemoved()
      Description copied from class: Widget
      This method is called to notify that the view is hidden. Note: You must not modify a tree of widgets from within this method. It means: do not call addChild, removeChild and similar methods.
      Overrides:
      notifyRemoved in class Widget
    • calculateClientArea

      protected final Rectangle calculateClientArea()
      Calculates a client area from the preferred size of the component.
      Overrides:
      calculateClientArea in class Widget
      Returns:
      the calculated client area
    • paintWidget

      protected final void paintWidget()
      Paints the component widget.
      Overrides:
      paintWidget in class Widget