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

14
LINES

< > BotCompany Repo | #1034138 // comboBoxDynamicToolTip

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

Transpiled version (4573L) is out of date.

1  
svoid <A> comboBoxDynamicToolTip(JComboBox<A> cb, IF1<A, S> makeToolTip) {
2  
  class ComboBoxRendererWithToolTip extends javax.swing.plaf.basic.BasicComboBoxRenderer is javax.swing.plaf.UIResource {
3  
    public Component getListCellRendererComponent(JList list, O value, int index, bool isSelected, bool cellHasFocus) {
4  
      var c = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
5  
      //printVars(+isSelected, +value, +index);
6  
      if (c cast JComponent && isSelected) pcall {
7  
        c.setToolTipText(makeToolTip?.get((A) value));
8  
      }
9  
      ret c;
10  
    }
11  
  }
12  
  
13  
  cb.setRenderer(new ComboBoxRendererWithToolTip);
14  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 3 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1034138
Snippet name: comboBoxDynamicToolTip
Eternal ID of this version: #1034138/10
Text MD5: d2174e4e7e1af0d2b6a212712a631ad7
Author: stefan
Category: javax / gui
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-01-24 15:37:12
Source code size: 668 bytes / 14 lines
Pitched / IR pitched: No / No
Views / Downloads: 128 / 206
Version history: 9 change(s)
Referenced in: [show references]