java swing的drag and drop源程序

Java中的Drag and Drop详解与代码示例  我最近对对Java中的Drag and Drop做了一个总结, 觉得大致可以通过两种方法实现Drag and Drop: 1.比较初级的D&D:只利用java.awt.datatransfer.*中的类实现. 2.高级D&D: 利用javax.awt.dnd.*中的类实现.比较初级D&D:只利用java.awt.datatransfer.*中的类实现. 这种方法只支持对JComponent的 阅读详情

import java.awt.*;
import java.io.*;
import java.util.*;
import java.awt.event.*;
import java.awt.dnd.*;
import java.awt.datatransfer.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.tree.*;

public class ListDemo extends JFrame
                      implements ListSelectionListener
{
    private DroppableList list;
    private JTextField fileName;

    public ListDemo()
    {
        super("ListDemo");

        //Create the list and put it in a scroll pane
        list = new DroppableList();
        DefaultListModel listModel = (DefaultListModel)list.getModel();
        list.setCellRenderer(new CustomCellRenderer());
        list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        list.setSelectedIndex(0);
        list.addListSelectionListener(this);
        JScrollPane listScrollPane = new JScrollPane(list);

        String dirName = new String("//");
        String filelist[] = new File(dirName).list();
        for (int i=0; i < filelist.length ; i++ )
        {
            String thisFileSt = dirName+filelist[i];
            File thisFile = new File(thisFileSt);
            if (thisFile.isDirectory())
                continue;
            try {
                listModel.addElement(makeNode(thisFile.getName(),
                                              thisFile.toURL().toString(),
                                              thisFile.getAbsolutePath()));
            } catch (java.net.MalformedURLException e){
            }
        }

        fileName = new JTextField(50);
        String name = listModel.getElementAt(
                              list.getSelectedIndex()).toString();
        fileName.setText(name);

        file://Create a panel that uses FlowLayout (the default).
        JPanel buttonPane = new JPanel();
        buttonPane.add(fileName);

        Container contentPane = getContentPane();
        contentPane.add(listScrollPane, BorderLayout.CENTER);
        contentPane.add(buttonPane, BorderLayout.NORTH);
    }

    public void valueChanged(ListSelectionEvent e)
    {
        if (e.getValueIsAdjusting() == false)
        {
            fileName.setText("");
            if (list.getSelectedIndex() != -1)
            {
                String name = list.getSelectedValue().toString();
                fileName.setText(name);
            }
        }
    }

    private static Hashtable makeNode(String name,
        String url, String strPath)
    {
        Hashtable hashtable = new Hashtable();
        hashtable.put("name", name);
        hashtable.put("url", url);
        hashtable.put("path", strPath);
        return hashtable;
    }

    public class DroppableList extends JList
        implements DropTargetListener, DragSourceListener, DragGestureListener
    {
        DropTarget dropTarget = new DropTarget (this, this);
        DragSource dragSource = DragSource.getDefaultDragSource();

        public DroppableList()
        {
          dragSource.createDefaultDragGestureRecognizer(
              this, DnDConstants.ACTION_COPY_OR_MOVE, this);
          setModel(new DefaultListModel());
        }

        public void dragDropEnd(DragSourceDropEvent DragSourceDropEvent){}
        public void dragEnter(DragSourceDragEvent DragSourceDragEvent){}
        public void dragExit(DragSourceEvent DragSourceEvent){}
        public void dragOver(DragSourceDragEvent DragSourceDragEvent){}
        public void dropActionChanged(DragSourceDragEvent DragSourceDragEvent){}

        public void dragEnter (DropTargetDragEvent dropTargetDragEvent)
        {
          dropTargetDragEvent.acceptDrag (DnDConstants.ACTION_COPY_OR_MOVE);
        }

        public void dragExit (DropTargetEvent dropTargetEvent) {}
        public void dragOver (DropTargetDragEvent dropTargetDragEvent) {}
        public void dropActionChanged (DropTargetDragEvent dropTargetDragEvent){}

        public synchronized void drop (DropTargetDropEvent dropTargetDropEvent)
        {
            try
            {
                Transferable tr = dropTargetDropEvent.getTransferable();
                if (tr.isDataFlavorSupported (DataFlavor.javaFileListFlavor))
                {
                    dropTargetDropEvent.acceptDrop (
                        DnDConstants.ACTION_COPY_OR_MOVE);
                    java.util.List fileList = (java.util.List)
                        tr.getTransferData(DataFlavor.javaFileListFlavor);
                    Iterator iterator = fileList.iterator();
                    while (iterator.hasNext())
                    {
                      File file = (File)iterator.next();
                      Hashtable hashtable = new Hashtable();
                      hashtable.put("name",file.getName());
                      hashtable.put("url",file.toURL().toString());
                      hashtable.put("path",file.getAbsolutePath());
                      ((DefaultListModel)getModel()).addElement(hashtable);
                    }
                    dropTargetDropEvent.getDropTargetContext().dropComplete(true);
              } else {
                System.err.println ("Rejected");
                dropTargetDropEvent.rejectDrop();
              }
            } catch (IOException io) {
                io.printStackTrace();
                dropTargetDropEvent.rejectDrop();
            } catch (UnsupportedFlavorException ufe) {
                ufe.printStackTrace();
                dropTargetDropEvent.rejectDrop();
            }
        }

        public void dragGestureRecognized(DragGestureEvent dragGestureEvent)
        {
            if (getSelectedIndex() == -1)
                return;
            Object obj = getSelectedValue();
            if (obj == null) {
                // Nothing selected, nothing to drag
                System.out.println ("Nothing selected - beep");
                getToolkit().beep();
            } else {
                Hashtable table = (Hashtable)obj;
                FileSelection transferable =
                  new FileSelection(new File((String)table.get("path")));
                dragGestureEvent.startDrag(
                  DragSource.DefaultCopyDrop,
                  transferable,
                  this);
            }
        }
    }

    public class CustomCellRenderer implements ListCellRenderer
    {
        DefaultListCellRenderer listCellRenderer =
          new DefaultListCellRenderer();
        public Component getListCellRendererComponent(
            JList list, Object value, int index,
            boolean selected, boolean hasFocus)
        {
            listCellRenderer.getListCellRendererComponent(
              list, value, index, selected, hasFocus);
            listCellRenderer.setText(getValueString(value));
            return listCellRenderer;
        }
        private String getValueString(Object value)
        {
            String returnString = "null";
            if (value != null) {
              if (value instanceof Hashtable) {
                Hashtable h = (Hashtable)value;
                String name = (String)h.get("name");
                String url = (String)h.get("url");
                returnString = name + " ==> " + url;
              } else {
                returnString = "X: " + value.toString();
              }
            }
            return returnString;
        }
    }

    public class FileSelection extends Vector implements Transferable
    {
        final static int FILE = 0;
        final static int STRING = 1;
        final static int PLAIN = 2;
        DataFlavor flavors[] = {DataFlavor.javaFileListFlavor,
                                DataFlavor.stringFlavor,
                                DataFlavor.plainTextFlavor};
        public FileSelection(File file)
        {
            addElement(file);
        }
        /* Returns the array of flavors in which it can provide the data. */
        public synchronized DataFlavor[] getTransferDataFlavors() {
     return flavors;
        }
        /* Returns whether the requested flavor is supported by this object. */
        public boolean isDataFlavorSupported(DataFlavor flavor) {
            boolean b  = false;
            b |=flavor.equals(flavors[FILE]);
            b |= flavor.equals(flavors[STRING]);
            b |= flavor.equals(flavors[PLAIN]);
         return (b);
        }
        /**
         * If the data was requested in the "java.lang.String" flavor,
         * return the String representing the selection.
         */
        public synchronized Object getTransferData(DataFlavor flavor)
       throws UnsupportedFlavorException, IOException {
     if (flavor.equals(flavors[FILE])) {
         return this;
     } else if (flavor.equals(flavors[PLAIN])) {
         return new StringReader(((File)elementAt(0)).getAbsolutePath());
     } else if (flavor.equals(flavors[STRING])) {
         return((File)elementAt(0)).getAbsolutePath();
     } else {
         throw new UnsupportedFlavorException(flavor);
     }
        }
    }

    public static void main(String s[])
    {
        JFrame frame = new ListDemo();
        frame.addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
                System.exit(0);
            }
        });
        frame.pack();
        frame.setVisible(true);
    }
}

JavaSwing_5.5: 拖拽功能 本文链接: http://blog.csdn.net/xietansheng/article/details/78389272 Java Swing 图形界面开发(目录) 拖拽功能的使用非常普遍。例如打开U盘文件夹,把U盘的文件拖到桌面;把选中的文件拖入文件夹内等。拖拽的过程实际是数据传输的过程,Swing 组件支持拖拽功能,只需要为组件注册一个拖拽目标监听器,用于接收从外部拖拽到组件的数据。... 阅读详情

相关推荐

java swing控件的drag和drop的实现方法

java swing控件的drag和drop的实现方法: 主要用到java.awt.dnd.*;里面的方法,可以实现任意2个component的drag and drop.

疯狂JAVA讲义---第十二章:Swing编程(三)拖放功能

拖放功能其实就像我们使用windows 的时候按住CTRL然后拖动某个图标,会复制该对象。这给用户提供了很棒的用户体验,没办法程序员总是给自己找麻烦,让用户觉得方便,其实这个功能AWT也提供了Swing话只是利用了这个,因为这和界面没什么关系。DropTarget(拖放目的地)eg(将图片拖入后显示):public class TestDropTarget{ final int D

TERRY的技术日志 4600

swing文件拖拽

实现文件的拖拽功能 import java.awt.AlphaComposite; import java.awt.Component; import java.awt.Graphics2D; import java.awt.Point; import java.awt.Rectangle; import java.awt.Toolkit; import java.awt.datatransfer.DataFlavor; import java.awt.datatransfer.StringSelection; import java.awt.datatransfer.Transferable; import java.awt.datatransfer.UnsupportedFlavorException; import java.awt.dnd.DnDConstants; import java.awt.dnd.DragGestureEvent; import java.awt.dnd.DragGestureListener; import java.awt.dnd.DragSource; import java.awt.dnd.DragSourceDragEvent; import java.awt.dnd.DragSourceDropEvent; import java.awt.dnd.DragSourceEvent; import java.awt.dnd.DragSourceListener; import java.awt.dnd.DropTarget; import java.awt.dnd.DropTargetDragEvent; import java.awt.dnd.DropTargetDropEvent; import java.awt.dnd.DropTargetEvent; import java.awt.dnd.DropTargetListener; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; import java.awt.geom.AffineTransform; import java.awt.geom.Rectangle2D; import java.awt.image.BufferedImage; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.util.Iterator; import java.util.List; import javax.swing.Icon; import javax.swing.JLabel; import javax.swing.JTree; import javax.swing.Timer; import javax.swing.event.TreeExpansionEvent; import javax.swing.event.TreeExpansionListener; import javax.swing.filechooser.FileSystemView; import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.tree.DefaultTreeCellRenderer; import javax.swing.tree.DefaultTreeModel; import javax.swing.tree.TreePath; class DragTree extends JTree implements DragGestureListener, DragSourceListener, DropTargetListener { /** * */ private static final long serialVersionUID = 1L; BufferedImage ghostImage; private Rectangle2D ghostRect = new Rectangle2D.Float(); private Point ptOffset = new Point(); private Point lastPoint = new Point(); private TreePath lastPath; private Timer hoverTimer; FileNode sourceNode; public DragTree() { DragSource dragSource = DragSource.getDefaultDragSource(); dragSource.createDefaultDragGestureRecognizer(this, // component where // drag originates DnDConstants.ACTION_COPY_OR_MOVE, // actions this); // drag gesture recognizer setModel(createTreeModel()); addTreeExpansionListener(new TreeExpansionListener() { public void treeCollapsed(TreeExpansionEvent e) { } public void treeExpanded(TreeExpansionEvent e) { TreePath path = e.getPath(); if (path != null) { FileNode node = (FileNode) path.getLastPathComponent(); if (!node.isExplored()) { DefaultTreeModel model = (DefaultTreeModel) getModel(); node.explore(); model.nodeStructureChanged(node); } } } }); this.setCellRenderer(new DefaultTreeCellRenderer() { public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) { TreePath tp = tree.getPathForRow(row); if (tp != null) { FileNode node = (FileNode) tp.getLastPathComponent(); File f = node.getFile(); try { Icon icon = FileSystemView.getFileSystemView() .getSystemIcon(f); this.setIcon(icon); this.setLeafIcon(icon); this.setOpenIcon(icon); this.setClosedIcon(icon); this.setDisabledIcon(icon); } catch (Exception e) { e.printStackTrace(); } } return super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus); } }); super.setScrollsOnExpand(true); new DropTarget(this, DnDConstants.ACTION_COPY_OR_MOVE, this); // Set up a hover timer, so that a node will be automatically expanded // or collapsed // if the user lingers on it for more than a short time hoverTimer = new Timer(1000, new ActionListener() { public void actionPerformed(ActionEvent e) { if (lastPath == null) { return; } if (getRowForPath(lastPath) == 0) return; // Do nothing if we are hovering over the root node if (isExpanded(lastPath)) collapsePath(lastPath); else expandPath(lastPath); } }); hoverTimer.setRepeats(false); // Set timer to one-shot mode this.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent e) { int code = e.getKeyCode(); int modifiers = e.getModifiers(); if (code == 'v' || code == 'V') { System.out.println("find v"); System.out.println("modifiers:" + modifiers + "\t" + ((modifiers & KeyEvent.CTRL_MASK) != 0)); } if ((modifiers & KeyEvent.CTRL_MASK) != 0 && (code == 'v' || code == 'V')) { Transferable tr = Toolkit.getDefaultToolkit() .getSystemClipboard().getContents(null); TreePath path = getSelectionPath(); if (path == null) { return; } FileNode node = (FileNode) path.getLastPathComponent(); if (node.isDirectory()) { System.out.println("file cp"); try { List list = (List) (tr .getTransferData(DataFlavor.javaFileListFlavor)); Iterator iterator = list.iterator(); File parent = node.getFile(); while (iterator.hasNext()) { File f = (File) iterator.next(); cp(f, new File(parent, f.getName())); } node.reexplore(); } catch (Exception ioe) { ioe.printStackTrace(); } updateUI(); } } } }); } public void dragGestureRecognized(DragGestureEvent e) { // drag anything ... TreePath path = getLeadSelectionPath(); if (path == null) return; FileNode node = (FileNode) path.getLastPathComponent(); sourceNode = node; // Work out the offset of the drag point from the TreePath bounding // rectangle origin Rectangle raPath = getPathBounds(path); Point ptDragOrigin = e.getDragOrigin(); ptOffset.setLocation(ptDragOrigin.x - raPath.x, ptDragOrigin.y - raPath.y); // Get the cell renderer (which is a JLabel) for the path being dragged int row = this.getRowForLocation(ptDragOrigin.x, ptDragOrigin.y); JLabel lbl = (JLabel) getCellRenderer().getTreeCellRendererComponent( this, // tree path.getLastPathComponent(), // value false, // isSelected (dont want a colored background) isExpanded(path), // isExpanded getModel().isLeaf(path.getLastPathComponent()), // isLeaf row, // row (not important for rendering) false // hasFocus (dont want a focus rectangle) ); lbl.setSize((int) raPath.getWidth(), (int) raPath.getHeight()); // <-- // The // layout // manager // would // normally // do // this // Get a buffered image of the selection for dragging a ghost image this.ghostImage = new BufferedImage((int) raPath.getWidth(), (int) raPath.getHeight(), BufferedImage.TYPE_INT_ARGB_PRE); Graphics2D g2 = ghostImage.createGraphics(); // Ask the cell renderer to paint itself into the BufferedImage g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC, 0.5f)); // Make the image ghostlike lbl.paint(g2); g2.dispose(); // this.getGraphics().drawImage(ghostImage, e.getDragOrigin().x, // e.getDragOrigin().y, this); e.startDrag( null, // cursor ghostImage, new Point(5, 5), new StringSelection(getFilename()), // transferable this); // drag source listener } public void dragDropEnd(DragSourceDropEvent e) { ghostImage = null; sourceNode = null; } public void dragEnter(DragSourceDragEvent e) { } public void dragExit(DragSourceEvent e) { if (!DragSource.isDragImageSupported()) { repaint(ghostRect.getBounds()); } } public void dragOver(DragSourceDragEvent e) { } public void dropActionChanged(DragSourceDragEvent e) { } public String getFilename() { TreePath path = getLeadSelectionPath(); FileNode node = (FileNode) path.getLastPathComponent(); return ((File) node.getUserObject()).getAbsolutePath(); } private DefaultTreeModel createTreeModel() { File root = FileSystemView.getFileSystemView().getRoots()[0]; FileNode rootNode = new FileNode(root); rootNode.explore(); return new DefaultTreeModel(rootNode); } public void dragEnter(DropTargetDragEvent dtde) { } public void dragOver(DropTargetDragEvent dtde) { Point pt = dtde.getLocation(); if (pt.equals(lastPoint)) { return; } if (ghostImage != null) { Graphics2D g2 = (Graphics2D) getGraphics(); // If a drag image is not supported by the platform, then draw my // own drag image if (!DragSource.isDragImageSupported()) { paintImmediately(ghostRect.getBounds()); // Rub out the last // ghost image and cue // line // And remember where we are about to draw the new ghost image ghostRect.setRect(pt.x - ptOffset.x, pt.y - ptOffset.y, ghostImage.getWidth(), ghostImage.getHeight()); g2.drawImage((ghostImage), AffineTransform .getTranslateInstance(ghostRect.getX(), ghostRect.getY()), null); } } TreePath path = getClosestPathForLocation(pt.x, pt.y); if (!(path == lastPath)) { lastPath = path; hoverTimer.restart(); } } public void dropActionChanged(DropTargetDragEvent dtde) { } public void drop(DropTargetDropEvent e) { try { DataFlavor stringFlavor = DataFlavor.stringFlavor; Transferable tr = e.getTransferable(); TreePath path = this.getPathForLocation(e.getLocation().x, e.getLocation().y); if (path == null) { e.rejectDrop(); return; } FileNode node = (FileNode) path.getLastPathComponent(); if (e.isDataFlavorSupported(DataFlavor.javaFileListFlavor) && node.isDirectory()) { e.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE); System.out.println("file cp"); List list = (List) (e.getTransferable() .getTransferData(DataFlavor.javaFileListFlavor)); Iterator iterator = list.iterator(); File parent = node.getFile(); while (iterator.hasNext()) { File f = (File) iterator.next(); cp(f, new File(parent, f.getName())); } node.reexplore(); e.dropComplete(true); this.updateUI(); } else if (e.isDataFlavorSupported(stringFlavor) && node.isDirectory()) { String filename = (String) tr.getTransferData(stringFlavor); if (filename.endsWith(".txt") || filename.endsWith(".java") || filename.endsWith(".jsp") || filename.endsWith(".html") || filename.endsWith(".htm")) { e.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE); File f = new File(filename); if (f.exists()) { f.renameTo(new File(node.getFile(), f.getName())); node.reexplore(); ((FileNode) sourceNode.getParent()).remove(sourceNode); e.dropComplete(true); this.updateUI(); } else { e.rejectDrop(); } } else { e.rejectDrop(); } } else { e.rejectDrop(); } } catch (IOException ioe) { ioe.printStackTrace(); } catch (UnsupportedFlavorException ufe) { ufe.printStackTrace(); } finally { ghostImage = null; this.repaint(); } } private void cp(File src, File dest) throws IOException { if (src.isDirectory()) { if (!dest.exists()) { boolean ret = dest.mkdir(); if (ret == false) return; } File[] fs = src.listFiles(); for (int i = 0; i < fs.length; i++) { cp(fs[i], new File(dest, fs[i].getName())); } return; } byte[] buf = new byte[1024]; FileInputStream in = new FileInputStream(src); FileOutputStream out = new FileOutputStream(dest); int len; try { while ((len = in.read(buf)) > 0) { out.write(buf, 0, len); } } finally { in.close(); out.close(); } } public void dragExit(DropTargetEvent dte) { } } class FileNode extends DefaultMutableTreeNode { private boolean explored = false; public FileNode(File file) { setUserObject(file); } public boolean getAllowsChildren() { return isDirectory(); } public boolean isLeaf() { return !isDirectory(); } public File getFile() { return (File) getUserObject(); } public boolean isExplored() { return explored; } public boolean isDirectory() { File file = getFile(); return file.isDirectory(); } public String toString() { File file = (File) getUserObject(); String filename = file.toString(); int index = filename.lastIndexOf(File.separator); return (index != -1 && index != filename.length() - 1) ? filename .substring(index + 1) : filename; } public void explore() { if (!isDirectory()) return; if (!isExplored()) { File file = getFile(); File[] children = file.listFiles(); for (int i = 0; i < children.length; ++i) { if (children[i].isDirectory()) add(new FileNode(children[i])); } for (int i = 0; i < children.length; ++i) { if (!children[i].isDirectory()) add(new FileNode(children[i])); } explored = true; } } public void reexplore() { this.removeAllChildren(); explored = false; explore(); } }

java swing拖放文字,java – 使用swing进行拖放

我需要一些帮助.是否有可能模拟拖动和放大器没有注册组件而丢弃?例如.我在窗口的任何地方单击鼠标键并按住鼠标键,此时,我想用Java以编程方式创建或模拟DragSourceEvent.这可能吗?更新:关于鲍勃的回复,至少我明白了,我可以创造一个倾听者的倾听者.下降:DragSource dragSource = new DragSource();DragGestureListener listene...

weixin_42350314的博客 192

EtherCAT同步模式实战:如何用TwinCAT配置DC-Synchronous模式(附时序图详解)

本文详细解析了如何在TwinCAT环境中配置EtherCAT的DC-Synchronous同步模式,实现纳秒级同步精度。通过硬件准备、参数配置和高级调优步骤,帮助工程师解决工业自动化中的同步挑战,提升运动控制性能。

gold的博客 1571

ALTERA MAX10 FPGA 串口远程升级实战:从原理到烧录的避坑指南

本文详细解析了ALTERA MAX10 FPGA如何通过串口实现远程升级。文章从工程师实战经验出发,深入剖析了MAX10片内Flash的双镜像备份原理、CONFIG_SEL引脚启动机制,并重点介绍了使用On-Chip Flash IP核进行擦写操作的核心流程。同时,提供了从Quartus工程配置、RPD文件生成、串口协议设计到驱动代码编写的完整避坑指南,旨在帮助开发者稳定、高效地完成远程升级功能部署。

weixin_29197699的博客 273

Java swing拖拽移动组件.

首先构造自己的组件,如..Component extends JComponents { ... }。在里面添加了

黑天的猩猩 7297

某讯天御滑块验证码逆向实战:从参数解析到环境对抗

本文详细解析了某讯天御滑块验证码的逆向工程实战技巧,从关键参数解析到浏览器环境模拟对抗。重点介绍了collect、eks等参数的逆向思路,以及如何通过puppeteer等工具补全环境检测,帮助开发者有效突破验证码防护。文章还提供了常见错误解决方案和性能优化建议,是验证码逆向领域的实用指南。

weixin_29325007的博客 437

java 拖拽_java swing中实现拖拽功能示例

package com;import java.awt.*;import java.awt.datatransfer.DataFlavor;import java.awt.dnd.DnDConstants;import java.awt.dnd.DropTarget;import java.awt.dnd.DropTargetAdapter;import java.awt.dnd.DropTarg...

weixin_42197110的博客 470

四旋翼无人机Matlab建模

本文主要分享一下四旋翼无人机的建模过程,然后在Matlab的simulink模块搭建起四旋翼无人机的模型,下一章将结合这个模型设计双环PID控制器并调节参数。 一、无人机建模过程

qq_36903625的博客 3万+

汽车Bootloader流程

根据ISO14229-1 写的汽车行业 Bootloader流程 1:编程前 → 先读取软硬件版本号 22 F1 XX 软件信息 22 F1 XX 硬件信息 → 进入扩展会话extend diagnostic sessions 功能寻址 10 03 → 编程条件检测routine control:ECU升级条件的判断,如车速,检测车的型号 31 01 02 03 → 关闭DTC检测,(由于很多节点收不到其它节点的报文后会记录DTC故障)功能寻址 85 02 → 关闭诊断通讯(禁止各个节点的应用报...

weixin_41320142的博客 2831

java swing的drag and drop源程序 (转)

java swing的drag and drop源程序 (转)[@more@]import Java.awt.*;import java.io.*;import java.util.*;import java.awt.event...

csd3176的博客 97

openclaw-cn : 无法将“openclaw-cn”项识别为 cmdlet、函数、脚本文件或可运行程序的名称 解决方案

本文主要介绍了openclaw-cn : 无法将“openclaw-cn”项识别为 cmdlet、函数、脚本文件或可运行程序的名称解决方案,希望能对使用openclaw-cn的同学们有所帮助。 文章目录 1. 问题描述 2. 解决方案

weixin_43178406的博客 10万+

Java中的Drag and Drop详解…

博主写得很详细,最近正在为这个头疼,看了这个终于搞清楚了原文地址:and Drop详解与代码示例">Java中的Drag and Drop详解与代码示例作者:SuRen对对Java中的Drag and Drop做了一个总结, 觉得大致可以通过两种方法实现Drag and Drop:  1.比较初级的D&D:只利用java.awt.datatransfer.*中的类实现.  2.高级D&D: 利用

胖大星的博客 2802

【大模型+知识图谱】哈工大版chinese-roberta-wwm-ext模型介绍、下载部署和GPU显卡配置

RoBERTa模型的一个重要改进版本,由阿里云的研究团队提出。而Chinese RoBERTa-wwm-ext则是针对中文文本的预训练模型,它在哈工大的研究团队手中进一步优化,特别适用于中文自然语言处理任务。

知识靠谱的博客 2773

LinePhone3.2.7(android端最新版本) sip客户端

SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/

java drag and drop_java的Drag and Drop(拖拽)简单例子

该楼层疑似违规已被系统折叠隐藏此楼查看此楼为了上传附件,写了个将压缩包合并到图片的小程序。选择用C#写,毫无疑问是因为visual studio的强大功能,随便拖拖就整出了界面。现在发个java的拖拽import java.awt.datatransfer.DataFlavor;import java.awt.datatransfer.Transferable;import java.awt.d...

weixin_42512183的博客 220

迈瑞BS系列全自动生化分析仪LIS协议接口手册(内含HL7和ASTM)

迈瑞BS系列全自动生化分析仪LIS协议接口手册,内含HL7和ASTM)

Java学习指南(Swing高级篇)

☆ Java程序员居家旅行必备课程 ☆Java学习指南系列的第4篇,介绍基于Java Swing的的高级应用技术。本篇的前一篇是Swing入门篇。Swing系列教程分为两篇:(1) Swing入门篇 (2) Swing高级篇。本篇内容至少包含:- 高级绘制技术,包含线型、渐变色、文本的精确绘制- 不规则形状及图表的绘制- 工作线程与界面线程的原理- 短任务、长任务、定时任务的应用举例- 弹出式窗口 Popup的使用方法- 短消息提示 Toaster 的设计与使用- 事件处理机制,鼠标键盘事件处理,以及一个基于键盘操作的“推箱子”游戏 - 多行文本的显示- 图片操作:缩放、剪裁、旋转、镜像,以及一个屏幕截图程序的实例- 管理型应用界面的框架- 向导型应用界面的框架- 文档型应用界面的框架- 拖放支持 Drag & Drop,一个可拖拽排序的列表,以及一个拼图游戏的实现* 课程特色 *轻快 - 采用小章节教学,学起来轻松实用 - 以实际工程需要出发来设计课程有趣 - 穿插大量特效实例,增加趣味性和学员的成就感专业 - 课程中采用的代码库,就是经过良好封装的成熟的库本篇穿插多个实例,通过实例,综合运用多种技术,使学员对项目的构建有所有认识。

怀旧版电脑GBC模拟器

再现原版GBC掌机的界面,电脑运行连游戏界面都一样大小,很怀旧,很真实,(英文版)强烈推荐,很小的文件,很难才找到的。

java swing拖放文字_swing实现拖拽效果(将本地文件拖拽到程序的文本框中显示内容) | 学步园...

import java.awt.BorderLayout;import java.awt.datatransfer.DataFlavor;import java.awt.datatransfer.Transferable;import java.awt.datatransfer.UnsupportedFlavorException;import java.awt.dnd.DnDConstants;...

weixin_39524741的博客 613

java swing 控件拖动_java swing 中怎么实现鼠标拖拽控件到另一个控件的功能?

你在DropTargetListener中把各个DataFlavor打印处理看看:publicvoiddrop(DropTargetDropEventdtde){System.out.println("drop........................");Transferablett=dtde.getTransferable();DataFlavor[]flavors=...

weixin_30014783的博客 817

Java Swing GUI文件拖拽

      为了方便,有时我们需要直接将本地文件或字符或图片直接拖拽到图形上,让组件自动打开拖拽的文件。基于这种思想,我写了如下代码实现这个拖拽监听的功能。      1.UI源码package ibees.desktop;import javax.swing.BorderFactory;import javax.swing.JFrame;import javax.swing.

敏于行 1万+

Swing-实现拖拽支持

目录 一、创建拖拽源 二、创建拖放目标 三、处理拖拽数据 四、图片的拖拽 一、创建拖拽源 DragSource : 拖放操作的源窗口 DropTarget :拖放操作的目标窗口 Transferable : 传递物,传递的数据 创建拖放源,仅窗口支持拖放操作 1、创建DragSource 2、创建Transferable 3、开始拖拽操作startDrag 核心...

给你更好的 2353
上一篇: J2EE vs. Microsoft.NET(7)
下一篇: 在java中实现对FORM的打印功能
programlover
博客等级 码龄26年 1粉丝 36原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值