How can I do double click on JTree
of my laptop to transfer files to server using FTP4j thank you
public void mouseClicked(MouseEvent e) {
String s = arbre.getLastSelectedPathComponent().toString();
File file = new File(s);
if(file.isFile()) {
System.out.println("c'est un fichier");
if(e.getClickCount()==2){
client.upload(file);
}
}
Using getClickCount()
, you can detect double clicks in a MouseListener
, as shown here . Start the transfer in your implementation of the doInBackground()
method of SwingWorker
. Use setProgress()
to notify a listening progress indicator as the transfer proceeds, as shown here . You can show progress in a TreeCellRenderer
, illustrated here . Beacuase nodes share the same renderer, you'll need to store progress elsewhere , typically in your implementation of TreeModel
.
Addendum: A very simple way to display a JTree
of files is shown here .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.