Download Jar. Uses 3874K of libraries. Click here for Pure Java version (2381L/16K).
!7 p-substance { JTextField tf1 = jtextfield(); JTextField tf2 = jtextfield(); for (JTextField tf : ll(tf1, tf2)) tf.setCaret(new HighlightCaret); showFrame(vgrid(tf1, tf2)); } sclass HighlightCaret extends DefaultCaret { private static final Highlighter.HighlightPainter unfocusedPainter = new DefaultHighlighter.DefaultHighlightPainter(Color.RED); private static final Highlighter.HighlightPainter focusedPainter = new DefaultHighlighter.DefaultHighlightPainter(Color.YELLOW); private static final long serialVersionUID = 1L; private boolean isFocused; @Override protected Highlighter.HighlightPainter getSelectionPainter() { setBlinkRate(500); // otherwise is disabled, stopped return isFocused ? focusedPainter/*super.getSelectionPainter()*/ : unfocusedPainter; } @Override public void setSelectionVisible(boolean hasFocus) { if (hasFocus != isFocused) { isFocused = hasFocus; super.setSelectionVisible(false); super.setSelectionVisible(true); } } }
Began life as a copy of #1008677
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
| Snippet ID: | #1008678 |
| Snippet name: | Test HighlightCaret (keeps showing selection of JTextField when not in focus) with Substance |
| Eternal ID of this version: | #1008678/1 |
| Text MD5: | fcad92b0fa113f06e0103c71024b4bb5 |
| Transpilation MD5: | 815ed0bb66f8e95842005c90793d471d |
| Author: | stefan |
| Category: | javax / gui |
| Type: | JavaX source code (desktop) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2017-05-28 07:07:35 |
| Source code size: | 1107 bytes / 31 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 729 / 1607 |
| Referenced in: | [show references] |