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.

1  
srecord noeq CenteredComboBoxRenderer<A>(ListCellRenderer<A> baseRenderer) is ListCellRenderer<A> {
2  
  settable bool centerItems;
3  
  
4  
  public Component getListCellRendererComponent(JList list, A value, int index, bool isSelected, bool cellHasFocus) {
5  
    var c = baseRenderer.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
6  
    if (c cast JLabel) {
7  
      if (centerItems() || index < 0)
8  
        centerLabel(c);
9  
      else
10  
        leftAlignLabel(c);
11  
    }
12  
    ret c;
13  
  }
14  
}

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: 174 / 272
Version history: 7 change(s)
Referenced in: [show references]