接口 UIBasicDelegate<T extends JComponent>
- 所有超级接口:
SelfReportingMixin
- 所有已知实现类:
UIAppMainDelegate
,UIBuilderDelegate
,UIButtonDelegate
,UIControllerDelegateChilds.WindowSetupChildBlock
,UIDelegate
,UILabelDelegate
,UIPanelDelegate
,UIPanelDelegate.UIHorizontalPanelDelegate
,UITextFieldDelegate
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 publicSharedConstants
class).
In regular Java Swing or other imperative frameworks during UI building, you will end up with the following code:
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: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); }
There are no residue to the components because we only need them for construction and not for any advanced setting.UIButtonDelegate.make() .withHeight(300) .withWidth(400) .withChild( UIPainterPanel.make() .withLateCanvasPainter(g-> g.setColor(Colors.GREEN); g.fillRect(0,0,300,400); ) );
- 作者:
- Jack Meng
-
方法概要
修饰符和类型方法说明Converts to a Swing Lightweight component formdefault void
Calls the underlyingJComponent.revalidate()
for layout managementdefault void
refresh()
Calls the underlyingComponent.repaint()
for graphical management从接口继承的方法 pkg.exoad.poprock.core.debug.SelfReportingMixin
getCanonicallyNamedThis, getNamedThis
-
方法详细资料
-
refresh
default void refresh()Calls the underlyingComponent.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 underlyingJComponent.revalidate()
for layout management
-