- 浏览: 3122643 次
- 性别:
- 来自: 北京
文章分类
- 全部博客 (372)
- diy (4)
- linux (19)
- 杂项 (30)
- Swing (21)
- Java2D (21)
- Java3D (5)
- JavaIO (9)
- Java通讯 (5)
- Java设计模式 (3)
- Java多媒体 (0)
- Java算法 (7)
- Spring&EJB (29)
- Javaoffice (4)
- web前端 (23)
- javascript (1)
- php基础 (1)
- eclipse (3)
- 网站相关 (3)
- Apache (4)
- seo (12)
- db (28)
- server (3)
- api (4)
- 异常 (12)
- 计算机网络词汇表 (3)
- 随想录 (52)
- 收藏 (17)
- 犹太人的智慧 (3)
- 多线程 (1)
- jfreechart (7)
- Test (1)
- SorLib (30)
- ruby on rails (1)
最新评论
-
houyutao:
二三四都是错的空字符串也被匹配,*应该改成+
Java中判断字符串是否为数字的五种方法 -
mingyun:
但是 java.util.ArrayList 实现了 remo ...
java.lang.UnsupportedOperationException 解决方案 -
mingyun:
1.因为 Arrays.asList 返回的是 Arrays内 ...
java.lang.UnsupportedOperationException 解决方案 -
leolu007:
用java8新特性String testStr = " ...
java.lang.UnsupportedOperationException 解决方案 -
zhaohuaxishiwzw:
我之前所在的项目就是日本一家证券公司的项目。完全使用的是j2e ...
抛弃EJB(EJB2.0,EJB3.0,EJB4.0)
一个Java(JTree)拖拽的例子,其核心思想还是去实现Java拖拽的三个接口:DragGestureListener,
DragSourceListener, DropTargetListener。实现后的效果如下图:从左侧树上拖拽一个文件到右侧打开。代码已经编译通过,不需要第三方Java包。
DragSourceListener, DropTargetListener。实现后的效果如下图:从左侧树上拖拽一个文件到右侧打开。代码已经编译通过,不需要第三方Java包。
package com.zakisoft.drug; 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 = -7123350256666099899L; 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() { private static final long serialVersionUID = 7616415055309322562L; 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 static final long serialVersionUID = -6713369593920467035L; 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(); } }
package com.zakisoft.drug; import java.awt.BorderLayout; import java.awt.Dimension; import java.awt.datatransfer.DataFlavor; import java.awt.datatransfer.Transferable; import java.awt.datatransfer.UnsupportedFlavorException; import java.awt.dnd.DnDConstants; 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.WindowAdapter; import java.awt.event.WindowEvent; import java.io.File; import java.io.FileReader; import java.io.IOException; import javax.swing.BorderFactory; import javax.swing.JEditorPane; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JSplitPane; import javax.swing.UIManager; import javax.swing.WindowConstants; import javax.swing.text.Document; import javax.swing.text.EditorKit; public class Test extends JFrame implements DropTargetListener { private static final long serialVersionUID = -5037743965292608371L; private JEditorPane textPane = new JEditorPane(); public Test() { super("Drag and Drop With Swing"); new DropTarget(textPane, DnDConstants.ACTION_COPY_OR_MOVE, this); JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, createTreePanel(), createTextPanel()); splitPane.setDividerLocation(250); splitPane.setOneTouchExpandable(true); getContentPane().add(splitPane, BorderLayout.CENTER); } public static void main(String args[]) { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e1) { e1.printStackTrace(); } Test test = new Test(); test.setBounds(300, 300, 850, 350); test.setVisible(true); test.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); test.addWindowListener(new WindowAdapter() { public void windowClosed(WindowEvent e) { System.exit(0); } }); } private JPanel createTreePanel() { JPanel treePanel = new JPanel(); DragTree tree = new DragTree(); treePanel.setLayout(new BorderLayout()); treePanel.add(new JScrollPane(tree), BorderLayout.CENTER); treePanel.setBorder(BorderFactory .createTitledBorder("Drag source for filenames")); return treePanel; } private JPanel createTextPanel() { JPanel textPanel = new JPanel(); textPanel.setLayout(new BorderLayout()); textPanel.add(new JScrollPane(textPane), BorderLayout.CENTER); textPanel.setMinimumSize(new Dimension(375, 0)); textPanel.setBorder(BorderFactory .createTitledBorder("Drop target for filenames")); return textPanel; } private void readFile(final String filename) { try { textPane.setPage(new File(filename).toURL()); } catch (IOException e) { EditorKit kit = textPane.getEditorKit(); Document document = textPane.getDocument(); try { document.remove(0, document.getLength()); kit.read(new FileReader(filename), document, 0); } catch (Exception ex) { ex.printStackTrace(); } } } public void drop(DropTargetDropEvent e) { try { DataFlavor stringFlavor = DataFlavor.stringFlavor; Transferable tr = e.getTransferable(); if (e.isDataFlavorSupported(stringFlavor)) { 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); readFile(filename); textPane.setCaretPosition(0); e.dropComplete(true); } else { e.rejectDrop(); } } else { e.rejectDrop(); } } catch (IOException ioe) { ioe.printStackTrace(); } catch (UnsupportedFlavorException ufe) { ufe.printStackTrace(); } } public void dragEnter(DropTargetDragEvent e) { } public void dragExit(DropTargetEvent e) { } public void dragOver(DropTargetDragEvent e) { } public void dropActionChanged(DropTargetDragEvent e) { } }
发表评论
-
JFileChooser 只选(显示)文件夹
2012-06-29 11:17 3870小常识,就是总是忘,干脆整理下: JFileChooser f ... -
Swing免费皮肤Substance的使用
2010-10-25 16:22 22434关键词:Swing换肤,Substance,免费皮肤 Swi ... -
Swing 窗体关闭对话框提示
2010-10-20 17:56 6871关键词:Swing,关闭窗体,对话框提示 Swing关闭窗体 ... -
JTable表头排序的两种方法
2010-10-13 09:46 16624关键词:JTable,表头排序,线程安全 在Java6以前, ... -
基于Swing的图片倒影特效
2010-10-11 17:34 3750关键字:Swing,倒影特效,Graphics2D,Gradi ... -
怎样学习Swing
2010-09-27 16:36 3571Sun网站上的Java Tutorial就非常好,非常适合。它 ... -
Swing的第一推动力(转载)
2010-09-27 16:32 1634转载自[url]http://blog.sina. ... -
How to Write a Custom Swing Component
2010-09-27 16:29 2546When you hear comparisons betwe ... -
Swing页面属性的设置顺序
2010-09-15 15:35 4769这是一个细节问题,但 ... -
paint和paintComponent方法的关系
2010-09-15 14:12 15723关键词:swing,paint,paintComponent, ... -
Swing拖拽效果
2010-09-07 16:31 5208Swing的拖拽貌似挺复杂 ... -
SwingUtilities中invokeLater,invokeAndWait的区别和作用
2010-09-02 17:28 2986invokeLater,invokeAndWait是专门给Sw ... -
Swing控件(JLabel,JButton....)设置字体和大小
2010-09-02 16:57 19926关键字:Swing控件,JButton,JLabel,字体,大 ... -
Java 拖动Swing组件和图片
2010-08-17 14:07 14482在Swing中拖动一个组件或者图片,我们抛开定位布局不说,是件 ... -
SwingUtilities.convertPoint 方法的作用
2010-08-17 13:38 6770SwingUtilities类是Swing组件 ... -
JTable 行 列 单元格 操作小结
2010-07-15 10:11 11080一.创建表格 1) 调用无参构造函数. JTable tabl ... -
JTable 保存单元格内容
2010-07-14 17:25 4199在开发过程中遇到这样一个问题,我编辑JTable里的内容,编辑 ... -
Swing JTable工厂(table4j)
2010-06-07 16:36 5257因为Swing提供的JTable用 ... -
Java Swing Border(Swing 边框) 归纳
2010-05-27 12:32 25762对Swing Border的一个小总结: 使用方法: Titl ... -
JFrame打开居中和相关设置
2010-05-13 15:51 7172对于JFrame,在界面初始化完成时,加入以下代码: //设置 ...
相关推荐
这个例子展示了如何实现一个可拖动节点的`JTree`,这在用户界面设计中是一个常见且实用的功能,特别是在需要展示层次结构信息时。`JTree`允许用户通过拖放操作来重新排列节点,提高交互性和用户体验。 拖放(Drag ...
在例子中,使用了`FlowLayout`布局管理器将`JTree`添加到窗口中。 3. **节点的选中和信息获取**: JTree允许用户选择特定的节点。当用户选择节点时,可以通过监听`TreeSelectionListener`事件来获取选中的节点信息...
1. 掌握JTree应用,树节点的操作; 2. 使用JTree展数,管理对象。
Java Swing中的JTree组件是用来展示层次结构数据的可视化控件,它通常用于文件系统或组织结构的表示。JTree的核心是TreeNode接口,每个节点都对应一个TreeNode对象。TreeNode定义了一系列方法,如`getChildCount()`...
在Java的Swing库中,JTree是一个非常重要的组件,用于展示层次结构的数据。它以树状的形式显示信息,使得用户能够浏览和交互这些数据。本篇“JAVA中的Swing的JTree操作的宝典”将深入探讨如何进行树节点的增加、删除...
博文链接:https://xiancoder.iteye.com/blog/75830
Swing中的JTree组件是Java GUI(图形用户界面)开发中的一个重要组成部分,它允许程序员创建和展示层次结构数据。在Java Swing库中,JTree是一个用于显示和操作树形数据结构的视图组件。这个“Swing-JTree.rar”文件...
该项目的目标是提供具有文件系统目录层次结构的Java Swing JTree模型的高效且便捷的实现(例如,用于目录选择器组件)。 提供了一个演示应用程序。 参见org.swingk.io.dirtree.demo.Demo 。 该库被打包为Java 9...
Swing中的JTree组件是Java GUI(图形用户界面)设计中的一个重要组成部分,它允许用户以树状结构展示数据。在Java Swing库中,JTree是一个用于显示和操作数据的可视控件,通常用来呈现层次化的信息,如文件系统目录...
在Java的Swing库中,`JTree`组件是一个强大的工具,用于展示层次结构的数据,如文件系统目录结构。这个组件允许用户以图形化的方式浏览和操作这些数据,包括展开、折叠节点,以及选择和编辑特定节点。在"Swing展示的...
1. **Swing组件**:Swing 提供了许多组件,如按钮(JButton),文本框(JTextField),标签(JLabel),面板(JPanel),滚动窗格(JScrollPane),列表(JList),表格(JTable),树(JTree)等。这些组件是构建用户界面的基本单元...
本篇文章将深入探讨如何在`JTree`中实现拖拽(Drag and Drop,简称DnD)功能,使用户能够通过拖动节点来重新组织树形结构。 首先,为了启用`JTree`的拖放功能,我们需要在`JTree`实例上注册一个`DragSource`和`...
### JTree用法详解:Swing中的树状结构控件 在Java Swing中,`JTree`是一个非常重要的组件,用于展示层次结构的数据,如文件系统、组织结构图等。本文将详细介绍`JTree`的各种使用方法,包括如何创建、自定义外观、...
在Swing中,我们可以创建各种用户界面元素,如按钮、文本框、面板等,其中包括树形视图(JTree)。在描述中提到的“java Swing带复选框的树”,即在JTree的基础上增加了复选框功能,允许用户对树结构中的节点进行...
本篇将详细讲解`JTree`的相关知识点,并通过实际例子进行练习。 首先,我们要了解`JTree`的基本概念。它是Java Swing库的一部分,用于构建用户界面,它允许用户通过节点和子节点的关系来查看和操作数据。每个节点都...
在Swing中,`JTree`组件是用于显示和操作树形数据结构的控件。当我们处理大量数据时,一次性加载所有节点可能会导致性能问题,这时就需要用到“懒加载”(Lazy Loading)技术。 懒加载是一种优化策略,它只在需要时...
本资源“JAVA_Swing 学习经典例子”是一个包含各种Swing功能实现的代码集合,适用于不同水平的开发者学习和参考。 Swing 提供了大量可定制的组件,如按钮、文本框、菜单、滚动面板等,这些组件都是轻量级的,不依赖...