< prev index next >
src/java.desktop/share/classes/javax/swing/plaf/basic/BasicFileChooserUI.java
Print this page
@@ -31,15 +31,21 @@
import javax.swing.event.*;
import javax.swing.plaf.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.datatransfer.*;
+import java.awt.image.BufferedImage;
+import static java.awt.image.BufferedImage.TYPE_INT_ARGB;
import java.beans.*;
import java.io.*;
+import java.nio.file.Files;
+import java.nio.file.Path;
import java.util.*;
import java.util.List;
import java.util.regex.*;
+import static java.util.stream.Collectors.toList;
+import javax.swing.tree.TreePath;
import sun.awt.shell.ShellFolder;
import sun.swing.*;
import sun.swing.SwingUtilities2;
/**
@@ -1344,10 +1350,14 @@
}
private void changeDirectory(File dir) {
JFileChooser fc = getFileChooser();
+
+ Cursor prevCursor = fc.getCursor();
+ fc.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
+
// Traverse shortcuts on Windows
if (dir != null && FilePane.usesShellFolder(fc)) {
try {
ShellFolder shellFolder = ShellFolder.getShellFolder(dir);
@@ -1373,10 +1383,12 @@
if (fc.getFileSelectionMode() == JFileChooser.FILES_AND_DIRECTORIES &&
fc.getFileSystemView().isFileSystem(dir)) {
setFileName(dir.getAbsolutePath());
}
+
+ fc.setCursor(prevCursor);
}
// *****************************************
// ***** default AcceptAll file filter *****
@@ -1553,10 +1565,44 @@
}
if (values == null || values.length == 0) {
return null;
}
+ try {
+ BufferedImage img = null;
+ Graphics2D g = null;
+ for (Object value : values) {
+ File f=(File) value;
+ Image icon = ShellFolder.getShellFolder(f).getIcon(true);
+ if(img == null) {
+ img = new BufferedImage(icon.getWidth(null)+20,
+ icon.getHeight(null)+20, TYPE_INT_ARGB);
+ g = img.createGraphics();
+
+ int w = img.getWidth()-2;
+ int h = img.getHeight()-2;
+ g.setPaint(new GradientPaint(
+ 0, 0, new Color(0, 149, 234, 12),
+ 0, h, new Color(0, 155, 237, 28)
+ ));
+ g.fillRoundRect(0, 0, w, h, 4, 4);
+
+ g.setColor(new Color(0, 170, 248, 36));
+ g.drawRoundRect(0, 0, w, h, 4, 4);
+ }
+ g.drawImage(icon,
+ img.getWidth()/2-icon.getWidth(null)/2,
+ img.getHeight() / 2-icon.getHeight(null)/2, null);
+ }
+ setDragImage(img);
+ setDragImageOffset(new Point(
+ img.getWidth()/2, img.getHeight()-5));
+ } catch (FileNotFoundException ex) {
+ ex.printStackTrace();
+ setDragImage(null);
+ }
+
StringBuilder plainBuf = new StringBuilder();
StringBuilder htmlBuf = new StringBuilder();
htmlBuf.append("<html>\n<body>\n<ul>\n");
@@ -1572,11 +1618,11 @@
return new FileTransferable(plainBuf.toString(), htmlBuf.toString(), values);
}
public int getSourceActions(JComponent c) {
- return COPY;
+ return COPY|MOVE;
}
static class FileTransferable extends BasicTransferable {
Object[] fileData;
< prev index next >