接口 UIBasicDelegate<T extends JComponent>

所有超级接口:
SelfReportingMixin
所有已知子接口:
UIControllerDelegateChilds.UIControllerDelegate
所有已知实现类:
UIAppMainDelegate, UIBuilderDelegate, UIButtonDelegate, UIControllerDelegateChilds.WindowSetupChildBlock, UIDelegate, UILabelDelegate, UIPanelDelegate, UIPanelDelegate.UIHorizontalPanelDelegate, UITextFieldDelegate

public interface UIBasicDelegate<T extends JComponent> extends SelfReportingMixin
Root of all UI delegates to extend from and the main extrapolation from the AWT/Swing roots.

Delegation

In Poprock UI building, delegation stands for an express way to build UI elements with a framework like Java Swing/AWT. A user should only modify an element on creation and not use that same object elsewhere (similar to exposing that element in a public SharedConstants class).

In regular Java Swing or other imperative frameworks during UI building, you will end up with the following code:

 Frame f=Frame();
 f.width=300;
 f.height=400;

 ContentPane p=ContentPane();
 p.width=300;
 p.height=400;
 p.painter= (Canvas canvas) => {
 canvas.color=GREEN;
 canvas.fillRect(0,0,300,400);
 }
 
This can cause code to look very linear and very hard to debug. Instead, Poprock tries to take it a reactive way to build applications but still being imperative whenever the programmer wants:
 UIButtonDelegate.make()
 .withHeight(300)
 .withWidth(400)
 .withChild(
 UIPainterPanel.make()
 .withLateCanvasPainter(g->
 g.setColor(Colors.GREEN);
 g.fillRect(0,0,300,400);
 )
 );
 
There are no residue to the components because we only need them for construction and not for any advanced setting.
作者:
Jack Meng
  • 方法详细资料

    • refresh

      default void refresh()
      Calls the underlying Component.repaint() for graphical management
    • asComponent

      T asComponent()
      Converts to a Swing Lightweight component form
      返回:
      as an awt suitable component (this should be used for internal operations only)
    • hardRefresh

      default void hardRefresh()
      Calls the underlying JComponent.revalidate() for layout management