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

30
LINES

< > BotCompany Repo | #1034438 // JFilePathButton - JButton with a small icon allowing to open a file in file exporer

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

Libraryless. Compilation Failed (13795L/81K).

srecord noeq JFilePathButton(File file) is Swingable {
  transient JButton button;
  
  cachedVisualize {
    if (button == null) {
      button = jimageButtonScaledToWidth(16, #1101292, "", l0 showInExplorer);
      componentPopupMenuItem(button, "Copy path", -> copyToClipboard(f2s(file)));
    }
    updateToolTip();
    ret button;
  }
  
  void showInExplorer {
    thread {
      File dirToShow = isFile(file) ? dirOfFile(file) : file;
      //startPlatformFileManager(dirToShow);
      desktopOpen(dirToShow);
    }
  }
  
  void setFile(File file) {
    this.file = file;
    updateToolTip();
  }
  
  void updateToolTip {
    setEnabled(button, file != null);
    toolTip(file == null ? "No file" : f2s(file) + " [click to show in file explorer]", button);
  }
}

Author comment

Began life as a copy of #1034207

download  show line numbers  debug dex  old transpilations   

Travelled to 5 computer(s): bhatertpkbcr, ekrmjmnbrukm, elmgxqgtpvxh, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1034438
Snippet name: JFilePathButton - JButton with a small icon allowing to open a file in file exporer
Eternal ID of this version: #1034438/7
Text MD5: 34d3602a311d7315232a23dabfeb6aee
Transpilation MD5: 1c20df8286fefc0f4c5a708a7b26d4cb
Author: stefan
Category: javax / screen recognition
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2023-01-15 19:19:39
Source code size: 800 bytes / 30 lines
Pitched / IR pitched: No / No
Views / Downloads: 181 / 301
Version history: 6 change(s)
Referenced in: [show references]