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

14
LINES

< > BotCompany Repo | #1034140 // CenteredComboBoxRenderer - centers either only text in combo box itself or also the items in the list

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

Transpiled version (4931L) is out of date.

srecord noeq CenteredComboBoxRenderer<A>(ListCellRenderer<A> baseRenderer) is ListCellRenderer<A> {
  settable bool centerItems;
  
  public Component getListCellRendererComponent(JList list, A value, int index, bool isSelected, bool cellHasFocus) {
    var c = baseRenderer.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
    if (c cast JLabel) {
      if (centerItems() || index < 0)
        centerLabel(c);
      else
        leftAlignLabel(c);
    }
    ret c;
  }
}

Author comment

Began life as a copy of #1034139

download  show line numbers  debug dex  old transpilations   

Travelled to 4 computer(s): bhatertpkbcr, ekrmjmnbrukm, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1034140
Snippet name: CenteredComboBoxRenderer - centers either only text in combo box itself or also the items in the list
Eternal ID of this version: #1034140/8
Text MD5: a1a9281a71a5ce00c56f47399063e72e
Author: stefan
Category: javax / gui
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-08-12 02:48:44
Source code size: 513 bytes / 14 lines
Pitched / IR pitched: No / No
Views / Downloads: 175 / 273
Version history: 7 change(s)
Referenced in: #1034167 - Standard Classes + Interfaces (LIVE, continuation of #1003674)