Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

33
LINES

< > BotCompany Repo | #1024693 // jCenteredLiveValueSection - jCenteredSection + LiveValue (or IGetterWithNotify)

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (9610L/55K).

import javax.swing.border.*;

sclass jCenteredLiveValueSection_class extends SingleComponentPanel {
  IGetterWithNotify<S> liveValue;
  settable int borderType = BevelBorder.LOWERED;
  settable bool bold;
  
  S getTitle() { ret liveValue!; }
  
  *(IGetterWithNotify<S> *liveValue, Component c) {
    super(c);
  }
    
  selfType init() {
    bindLiveValueListenerToComponent(this, liveValue, r-awt {
      var titledBorder = BorderFactory.createTitledBorder(
        makeBaseBorder(), liveValue!);
      if (bold) titledBorder.setTitleFont(deriveBoldFont(getFont()));
      setBorder(titledBorder);
      centerSection(jCenteredLiveValueSection_class.this);
      revalidate();
    });
    this;
  }
  
  swappable Border makeBaseBorder() {
    ret BorderFactory.createBevelBorder(borderType);
  }
}

static JPanel jCenteredLiveValueSection(IGetterWithNotify<S> lv, Component c) swing {
  ret new jCenteredLiveValueSection_class(lv, c).init();
}

Author comment

Began life as a copy of #1015895

download  show line numbers  debug dex  old transpilations   

Travelled to 7 computer(s): bhatertpkbcr, ekrmjmnbrukm, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1024693
Snippet name: jCenteredLiveValueSection - jCenteredSection + LiveValue (or IGetterWithNotify)
Eternal ID of this version: #1024693/13
Text MD5: 15480dad93d679fef981a2fb4229d7e7
Transpilation MD5: 26a72764707af04d0afa7e0e2008d4ba
Author: stefan
Category: javax / gui
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-03-30 19:53:17
Source code size: 980 bytes / 33 lines
Pitched / IR pitched: No / No
Views / Downloads: 312 / 518
Version history: 12 change(s)
Referenced in: [show references]