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.

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

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