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

20
LINES

< > BotCompany Repo | #1003297 // newButton - make JButton with runnable/function name

JavaX fragment (include)

1  
sbool newButton_autoToolTip = true;
2  
3  
sbool newButton_autoToolTip() { ret newButton_autoToolTip; }
4  
5  
// action can be Runnable or a function name
6  
static JButton newButton(fS text, final O action) {
7  
  ret swing(func -> JButton {
8  
    S text2 = dropPrefix("[disabled] ", text);
9  
    JButton btn = basicJButton(text2);
10  
    if (l(text2) < l(text)) btn.setEnabled(false);
11  
    if (newButton_autoToolTip) {
12  
      btn.setToolTipText(btn.getText());
13  
      //onChangeAndNow(btn, r { btn.setToolTipText(btn.getText()) });
14  
    }
15  
    // submitButtonOnEnter(btn); // test this first
16  
    if (action != null)
17  
      btn.addActionListener(actionListener(action, btn));
18  
    ret btn;
19  
  });
20  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1003297
Snippet name: newButton - make JButton with runnable/function name
Eternal ID of this version: #1003297/14
Text MD5: 0cc38e9b252967010cab6ac4caf437ad
Author: stefan
Category: javax / gui
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-10-07 15:30:12
Source code size: 686 bytes / 20 lines
Pitched / IR pitched: No / No
Views / Downloads: 679 / 805
Version history: 13 change(s)
Referenced in: [show references]