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

15
LINES

< > BotCompany Repo | #1016595 // tableDependentButton_extraCondition - enable button when an item is selected in a JTable

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

Libraryless. Click here for Pure Java version (9753L/54K).

1  
static JButton tableDependentButton_extraCondition(JTable table, S text, O action, F0<Bool> extraCondition) {
2  
  final JButton b = jbutton(text, action);
3  
  onTableSelectionChangedAndNow(table, r {
4  
    b.setEnabled(table.getSelectedRow() >= 0 && isTrue(callF(extraCondition)))
5  
  });
6  
  ret b;
7  
}
8  
9  
static JButton tableDependentButton_extraCondition(JTable table, IF0<Bool> extraCondition, S text, Runnable action) {
10  
  JButton b = jbutton(text, action);
11  
  onTableSelectionChangedAndNow(table, r {
12  
    b.setEnabled(table.getSelectedRow() >= 0 && (extraCondition == null || extraCondition!));
13  
  });
14  
  ret b;
15  
}

Author comment

Began life as a copy of #1016591

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: #1016595
Snippet name: tableDependentButton_extraCondition - enable button when an item is selected in a JTable
Eternal ID of this version: #1016595/4
Text MD5: b96fc16e76c58c09eb5e3034e455d50e
Transpilation MD5: 22d74ac9fa2ef39e5635e856be1ad26f
Author: stefan
Category: javax / gui
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-10-30 19:03:24
Source code size: 615 bytes / 15 lines
Pitched / IR pitched: No / No
Views / Downloads: 450 / 547
Version history: 3 change(s)
Referenced in: [show references]