freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內(nèi)容

全國計算機等級考試二級java語言程序設(shè)計試題及答案(五)-資料下載頁

2025-06-19 20:45本頁面
  

【正文】 java.a(chǎn)wt.*;   import java.a(chǎn)wt.datatransfer.*;   import java.a(chǎn)wt.dnd.*;   import java.a(chǎn)wt.event.*;   import java.io.*;   import java.util.*;   import javax.swing.*;   public class java3   {   public static void main(String[]args)   {   JFrame frame=new DragSourceFrame();   frame.setDefauhCloseOperation(JFrame.EXIT_   0N_CLoSE);   frame.show();   }   }   class DragSoureeFrame extends JFrame   {   public DragSourceFrame()   {   setTitle(java3);   setSize(WlDTH,HElGHT);   Container contentPane=getContentPane();   File f=new File(.).getabsoluteFile();   File[]files=f.listFiles();   model=new DefaultListModel();   for(int i=0;i  try   {   model.a(chǎn)ddElement(files[i].getCanonicalFile());   }   catch(IOException exception)   {   JOptionPane.showMessageDialog(this,exeep   tion);   }   fileList=new JList(model);   contentPane.a(chǎn)dd(new JScrollPane(fileList),   BorderLayout.CENTER);   contentPane.a(chǎn)dd(new JLabel(從列表中拖曳出文   件),   BorderLayout.NoRTH);   DragSource dragSource=DragSource.getDefauh   DragSource();   dragSource.createDefaultDragGestureRecognizer   (fileList,   DnDConstants. ACTION_COPY_0R_   MOVE,new   DragGestureListener()   {   public void dragGestureRecognized(   DragGestureEvent event)   {   draggedValues=fileList.getSelectedValues();   Transferable transferable   =new FiteListTransferable(draggedValues);   evenr.startDrag(null,transferable,   new FileListDragSourceListener());   }   });   }   private class FileListDragSourceListener imple   ments DragSourceAdapter   {   public void dragDropEnd(DragSourceDropEvent e   vent)   {   if(event.getDropSuccess())   {   int action=event.getDropAction();   if(action= =DnDConstants.ACTl0N MOVE)   {   for(int i=0;i  model.removeElement(draggedValues[i]);   }   }   }   }   private JList fileList;   private DefauhListModel model;   private Object[]draggedValues;   private static final int WIDTH=300;   private static final int HEIGHT=200;   }   class FileListTransferable implements Transferable   {   public FileListTransferable(Object[]files)   {   fileList=new ArrayList(Arrays.a(chǎn)sList(files));   }   public DataFlavor[]getTransferDataFlavors()   {   return flavors。   public boolean isDataFlavorSupported(DataFlavor   flavor)   {   return Arrays. asList(flavors), contains(flavor) 。   }   public Object getTransferData(DataFlavor flavor)   throws UnsupportedFlavorException   if(flavor, equals(DataFlavor, javaFileListFlavor) )   return fileList。   else if(flavor, equals(DataFlavor, stringFlavor))   return fileList, toString() 。   else   throw new UnsupportedFlavorException(flavor) 。   }   private static DataFlavor[] flavors =   {   DataFlavor. j avaFileListFlavor,   DataFlavor. stringFlavor   }。   private java. util. List fileList。 第1處:File f—new File(.).getAbsoluteFile()   第2處:int i=0;i  第3處:private class FileListDragSoureeListener ex   tends DragSourceAdapter   【解析】第1處是通過絕對路徑創(chuàng)建一個File對象f;第2處是files中f文件所在目錄下的所有文件名列表,此處就是遍歷這些文件名;第3處是定義了一個FileListDragSoureeListener類繼承用于接收拖動源事件的抽象適配器類 DragSoureeAdapter。
點擊復(fù)制文檔內(nèi)容
高考資料相關(guān)推薦
文庫吧 www.dybbs8.com
備案圖鄂ICP備17016276號-1