亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? scribbledraganddrop.java

?? 164個完整的Java代碼,資源比較大
?? JAVA
字號:
/* * Copyright (c) 2000 David Flanagan.  All rights reserved. * This code is from the book Java Examples in a Nutshell, 2nd Edition. * It is provided AS-IS, WITHOUT ANY WARRANTY either expressed or implied. * You may study, use, and modify it for any non-commercial purpose. * You may distribute it non-commercially as long as you retain this notice. * For a commercial use license, or to purchase the book (recommended), * visit http://www.davidflanagan.com/javaexamples2. */package com.davidflanagan.examples.datatransfer;import java.awt.*;import java.awt.event.*;import javax.swing.*;import javax.swing.border.*;import java.awt.datatransfer.*;  // Clipboard, Transferable, DataFlavor, etc.import java.awt.dnd.*;import java.util.ArrayList;/** * This component can operate in two modes.  In "draw mode", it allows the user * to scribble with the mouse.  In "drag mode", it allows the user to drag * scribbles with the mouse.  Regardless of the mode, it always allows * scribbles to be dropped on it from other applications. **/public class ScribbleDragAndDrop extends JComponent    implements DragGestureListener,   // For recognizing the start of drags	       DragSourceListener,    // For processing drag source events	       DropTargetListener,    // For processing drop target events	       MouseListener,         // For processing mouse clicks	       MouseMotionListener    // For processing mouse drags{    ArrayList scribbles = new ArrayList();  // A list of Scribbles to draw    Scribble currentScribble;               // The scribble in progress    Scribble beingDragged;                  // The scribble being dragged    DragSource dragSource;                  // A central DnD object    boolean dragMode;                       // Are we dragging or scribbling?    // These are some constants we use    static final int LINEWIDTH = 3;    static final BasicStroke linestyle = new BasicStroke(LINEWIDTH);    static final Border normalBorder = new BevelBorder(BevelBorder.LOWERED);    static final Border dropBorder = new BevelBorder(BevelBorder.RAISED);    /** The constructor: set up drag-and-drop stuff */    public ScribbleDragAndDrop() {	// Give ourselves a nice default border.	// We'll change this border during drag-and-drop.	setBorder(normalBorder);	// Register listeners to handle drawing	addMouseListener(this);	addMouseMotionListener(this);	// Create a DragSource and DragGestureRecognizer to listen for drags	// The DragGestureRecognizer will notify the DragGestureListener	// when the user tries to drag an object	dragSource = DragSource.getDefaultDragSource();	dragSource.createDefaultDragGestureRecognizer(this, // What component		          DnDConstants.ACTION_COPY_OR_MOVE, // What drag types?						      this);// the listener	// Create and set up a DropTarget that will listen for drags and	// drops over this component, and will notify the DropTargetListener	DropTarget dropTarget = new DropTarget(this,   // component to monitor					       this);  // listener to notify	this.setDropTarget(dropTarget);  // Tell the component about it.    }    /**     * The component draws itself by drawing each of the Scribble objects.     **/    public void paintComponent(Graphics g) {	super.paintComponent(g);	Graphics2D g2 = (Graphics2D) g;	g2.setStroke(linestyle);   // Specify wide lines	int numScribbles = scribbles.size();	for(int i = 0; i < numScribbles; i++) {	    Scribble s = (Scribble)scribbles.get(i);	    g2.draw(s);         // Draw the scribble	}    }    public void setDragMode(boolean dragMode) {	this.dragMode = dragMode;    }    public boolean getDragMode() { return dragMode; }    /**     * This method, and the following four methods are from the MouseListener     * interface.  If we're in drawing mode, this method handles mouse down     * events and starts a new scribble.     **/    public void mousePressed(MouseEvent e) {	if (dragMode) return;	currentScribble = new Scribble();	scribbles.add(currentScribble);	currentScribble.moveto(e.getX(), e.getY());    }    public void mouseReleased(MouseEvent e) {}    public void mouseClicked(MouseEvent e) {}    public void mouseEntered(MouseEvent e) {}    public void mouseExited(MouseEvent e) {}    /**     * This method and mouseMoved() below are from the MouseMotionListener     * interface.  If we're in drawing mode, this method adds a new point     * to the current scribble and requests a redraw     **/    public void mouseDragged(MouseEvent e) {	if (dragMode) return;	currentScribble.lineto(e.getX(), e.getY());	repaint();    }    public void mouseMoved(MouseEvent e) {}    /**     * This method implements the DragGestureListener interface.  It will be     * invoked when the DragGestureRecognizer thinks that the user has      * initiated a drag.  If we're not in drawing mode, then this method will     * try to figure out which Scribble object is being dragged, and will     * initiate a drag on that object.     **/    public void dragGestureRecognized(DragGestureEvent e) {	// Don't drag if we're not in drag mode	if (!dragMode) return;	// Figure out where the drag started	MouseEvent inputEvent = (MouseEvent) e.getTriggerEvent();	int x = inputEvent.getX();	int y = inputEvent.getY();	// Figure out which scribble was clicked on, if any by creating a 	// small rectangle around the point and testing for intersection.	Rectangle r = new Rectangle (x-LINEWIDTH, y-LINEWIDTH, 				     LINEWIDTH*2, LINEWIDTH*2);	int numScribbles = scribbles.size();	for(int i =  0; i < numScribbles; i++) {  // Loop through the scribbles	    Scribble s = (Scribble) scribbles.get(i);	    if (s.intersects(r)) {  		// The user started the drag on top of this scribble, so 		// start to drag it.		// First, remember which scribble is being dragged, so we can 		// delete it later (if this is a move rather than a copy)		beingDragged = s;		// Next, create a copy that will be the one dragged		Scribble dragScribble = (Scribble) s.clone();		// Adjust the origin to the point the user clicked on.		dragScribble.translate(-x, -y);  				// Choose a cursor based on the type of drag the user initiated		Cursor cursor;		switch(e.getDragAction()) {		case DnDConstants.ACTION_COPY: 		    cursor = DragSource.DefaultCopyDrop;		    break;		case DnDConstants.ACTION_MOVE:		    cursor = DragSource.DefaultMoveDrop;		    break;		default: 		    return;   // We only support move and copys		}		// Some systems allow us to drag an image along with the 		// cursor.  If so, create an image of the scribble to drag		if (dragSource.isDragImageSupported()) {		    Rectangle scribbleBox = dragScribble.getBounds();		    Image dragImage = this.createImage(scribbleBox.width,						       scribbleBox.height);		    Graphics2D g = (Graphics2D)dragImage.getGraphics();		    g.setColor(new Color(0,0,0,0));  // transparent background		    g.fillRect(0, 0, scribbleBox.width, scribbleBox.height);		    g.setColor(Color.black);		    g.setStroke(linestyle);			g.translate(-scribbleBox.x, -scribbleBox.y);		    g.draw(dragScribble);		    Point hotspot = new Point(-scribbleBox.x, -scribbleBox.y);		    		    // Now start dragging, using the image.		    e.startDrag(cursor, dragImage, hotspot, dragScribble,this);		}		else {		    // Or start the drag without an image		    e.startDrag(cursor, dragScribble,this);		}		// After we've started dragging one scribble, stop looking		return;	    }	}    }    /**     * This method, and the four unused methods that follow it implement the     * DragSourceListener interface.  dragDropEnd() is invoked when the user     * drops the scribble she was dragging.  If the drop was successful, and     * if the user did a "move" rather than a "copy", then we delete the     * dragged scribble from the list of scribbles to draw.     **/    public void dragDropEnd(DragSourceDropEvent e) {	if (!e.getDropSuccess()) return;	int action = e.getDropAction();	if (action == DnDConstants.ACTION_MOVE) {	    scribbles.remove(beingDragged);	    beingDragged = null;	    repaint();	}    }    // These methods are also part of DragSourceListener.    // They are invoked at interesting points during the drag, and can be    // used to perform "drag over" effects, such as changing the drag cursor    // or drag image.    public void dragEnter(DragSourceDragEvent e) {}    public void dragExit(DragSourceEvent e) {}    public void dropActionChanged(DragSourceDragEvent e) {}    public void dragOver(DragSourceDragEvent e) {}    // The next five methods implement DropTargetListener    /**     * This method is invoked when the user first drags something over us.     * If we understand the data type being dragged, then call acceptDrag()     * to tell the system that we're receptive.  Also, we change our border     * as a "drag under" effect to signal that we can accept the drop.     **/    public void dragEnter(DropTargetDragEvent e) {	if (e.isDataFlavorSupported(Scribble.scribbleDataFlavor) ||	    e.isDataFlavorSupported(DataFlavor.stringFlavor)) {	    e.acceptDrag(DnDConstants.ACTION_COPY_OR_MOVE);	    this.setBorder(dropBorder);	}    }        /** The user is no longer dragging over us, so restore the border */    public void dragExit(DropTargetEvent e) { this.setBorder(normalBorder); }      /**      * This is the key method of DropTargetListener.  It is invoked when the     * user drops something on us.     **/    public void drop(DropTargetDropEvent e) {	this.setBorder(normalBorder);          // Restore the default border	// First, check whether we understand the data that was dropped.	// If we supports our data flavors, accept the drop, otherwise reject.	if (e.isDataFlavorSupported(Scribble.scribbleDataFlavor) ||	    e.isDataFlavorSupported(DataFlavor.stringFlavor)) {	    e.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);	}	else {	    e.rejectDrop();	    return;	}	// We've accepted the drop, so now we attempt to get the dropped data	// from the Transferable object.	Transferable t = e.getTransferable();  // Holds the dropped data	Scribble droppedScribble;  // This will hold the Scribble object	// First, try to get the data directly as a scribble object	try {	    droppedScribble =		(Scribble) t.getTransferData(Scribble.scribbleDataFlavor);	}	catch (Exception ex) {  // unsupported flavor, IO exception, etc.	    // If that doesn't work, try to get it as a String and parse it	    try {		String s = (String) t.getTransferData(DataFlavor.stringFlavor);		droppedScribble = Scribble.parse(s);	    }	    catch(Exception ex2) {		// If we still couldn't get the data, tell the system we failed		e.dropComplete(false);		return;	    }	}	// If we get here, we've got the Scribble object	Point p = e.getLocation();         // Where did the drop happen?	droppedScribble.translate(p.getX(), p.getY());  // Move it there	scribbles.add(droppedScribble);                 // add to display list	repaint();                                      // ask for redraw	e.dropComplete(true);                           // signal success!    }    // These are unused DropTargetListener methods    public void dragOver(DropTargetDragEvent e) {}    public void dropActionChanged(DropTargetDragEvent e) {}        /**     * The main method.  Creates a simple application using this class.  Note     * the buttons for switching between draw mode and drag mode.     **/    public static void main(String[] args) {	// Create a frame and put a scribble pane in it	JFrame frame = new JFrame("ScribbleDragAndDrop");	final ScribbleDragAndDrop scribblePane = new ScribbleDragAndDrop();	frame.getContentPane().add(scribblePane, BorderLayout.CENTER);	// Create two buttons for switching modes	JToolBar toolbar = new JToolBar();	ButtonGroup group = new ButtonGroup();	JToggleButton draw = new JToggleButton("Draw");	JToggleButton drag = new JToggleButton("Drag");	draw.addActionListener(new ActionListener() {		public void actionPerformed(ActionEvent e) {		    scribblePane.setDragMode(false);		}	    });	drag.addActionListener(new ActionListener() {		public void actionPerformed(ActionEvent e) {		    scribblePane.setDragMode(true);		}	    });	group.add(draw); group.add(drag);	toolbar.add(draw); toolbar.add(drag);	frame.getContentPane().add(toolbar, BorderLayout.NORTH);	// Start off in drawing mode	draw.setSelected(true);	scribblePane.setDragMode(false);	// Pop up the window	frame.setSize(400, 400);	frame.setVisible(true);    }}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产精品一级二级三级| xnxx国产精品| 亚洲精品一二三区| 91小宝寻花一区二区三区| 亚洲视频在线一区二区| 在线观看一区日韩| 夜色激情一区二区| 91精品国产综合久久香蕉麻豆| 久久成人麻豆午夜电影| 欧美一区二区三区性视频| 精品亚洲成a人在线观看| 久久九九全国免费| 91麻豆成人久久精品二区三区| 亚洲精品日韩综合观看成人91| 欧美日韩一级片网站| 秋霞午夜av一区二区三区| 久久久久久夜精品精品免费| fc2成人免费人成在线观看播放| 一区二区三区在线看| 欧美丰满美乳xxx高潮www| 国产久卡久卡久卡久卡视频精品| 国产精品免费网站在线观看| 欧美日韩一区小说| 国内精品伊人久久久久av一坑| 中文字幕一区二区三区精华液| 欧美唯美清纯偷拍| 国产成人av在线影院| 亚洲永久免费av| 久久久国产精品麻豆| 91欧美一区二区| 极品尤物av久久免费看| 亚洲人成精品久久久久久| 日韩一区二区在线看片| 不卡在线视频中文字幕| 午夜精品aaa| 中文字幕在线视频一区| 这里只有精品视频在线观看| 丁香婷婷深情五月亚洲| 日韩在线卡一卡二| 亚洲人精品午夜| 精品国产精品一区二区夜夜嗨| 色婷婷av一区| 国产99久久精品| 日本aⅴ亚洲精品中文乱码| 中文字幕一区日韩精品欧美| 日韩免费性生活视频播放| 99精品国产热久久91蜜凸| 老司机精品视频在线| 亚洲制服丝袜一区| 国产精品久久777777| 精品国产一区二区三区久久影院| 欧洲精品一区二区| av在线免费不卡| 国产综合色在线| 午夜精品福利在线| 一区二区三区国产精品| 国产精品国产三级国产普通话蜜臀| 日韩一区二区电影网| 欧美日韩一区二区在线观看 | 久久se精品一区精品二区| 亚洲制服丝袜一区| 18涩涩午夜精品.www| 久久精品一区二区三区不卡牛牛 | 8v天堂国产在线一区二区| 97久久超碰精品国产| 国产99久久久久| 国产成人精品一区二区三区网站观看| 男人的j进女人的j一区| 午夜激情一区二区三区| 亚洲成人免费观看| 亚洲一区二区三区四区五区中文| 亚洲少妇屁股交4| 国产精品乱码久久久久久| 国产亚洲欧美激情| 欧美国产欧美综合| 国产免费久久精品| 国产精品麻豆一区二区| 中文文精品字幕一区二区| 日韩欧美电影在线| 久久亚洲影视婷婷| 国产午夜一区二区三区| 国产日本亚洲高清| 国产精品久久久久久久久晋中 | 欧美成人aa大片| 久久网站最新地址| 国产精品无人区| 亚洲人成精品久久久久| 亚洲综合色在线| 婷婷综合久久一区二区三区| 天堂久久久久va久久久久| 麻豆精品一区二区综合av| 国内精品第一页| 成人精品一区二区三区中文字幕| 97久久久精品综合88久久| 欧美无砖砖区免费| 91精品国产91久久久久久最新毛片 | 国产精品88888| 99久久精品99国产精品| 在线视频中文字幕一区二区| 777午夜精品免费视频| 精品国产乱码久久久久久浪潮| 久久久久88色偷偷免费| **性色生活片久久毛片| 亚洲图片有声小说| 国产原创一区二区| 色综合天天性综合| 4438x成人网最大色成网站| 久久精品日韩一区二区三区| 亚洲三级在线免费观看| 日韩精品成人一区二区三区| 国产乱子轮精品视频| 色猫猫国产区一区二在线视频| 欧美一级片在线看| 综合电影一区二区三区| 奇米精品一区二区三区在线观看| 国产99久久久国产精品| 欧美精品亚洲二区| 国产精品视频yy9299一区| 香蕉影视欧美成人| 国产麻豆精品一区二区| 在线日韩一区二区| 成av人片一区二区| 日韩一区二区三区免费看| 日韩精品最新网址| 中文字幕不卡一区| 日本不卡中文字幕| 国产成人精品免费在线| 色婷婷综合久久久久中文一区二区 | 在线免费一区三区| 欧美人与禽zozo性伦| 国产精品嫩草99a| 亚洲不卡在线观看| 国产999精品久久久久久| 在线精品视频一区二区| 欧美韩国日本不卡| 亚洲丰满少妇videoshd| 国产乱一区二区| 色婷婷综合激情| 日韩丝袜情趣美女图片| 亚洲一区二区成人在线观看| 精品一区二区免费看| 在线视频欧美精品| 久久久久一区二区三区四区| 免费一级欧美片在线观看| av在线这里只有精品| 日韩免费观看2025年上映的电影| 国产精品二三区| 另类小说图片综合网| 欧美日韩大陆一区二区| 国产精品美日韩| 国产专区欧美精品| 在线看国产一区二区| 亚洲欧美日本在线| 国产麻豆精品在线| 91精品久久久久久久91蜜桃| 亚洲人被黑人高潮完整版| 免费一级片91| 欧美少妇一区二区| 国产精品国产自产拍高清av王其| 精品亚洲porn| 在线观看成人小视频| 亚洲另类在线制服丝袜| 粉嫩aⅴ一区二区三区四区 | 欧美日韩激情一区二区三区| 国产精品色哟哟网站| 成人午夜av在线| 26uuu欧美日本| 久久电影网电视剧免费观看| 51午夜精品国产| 国产一区二区三区精品视频| 久久中文字幕电影| 狠狠色丁香婷婷综合| 欧美一级久久久久久久大片| 日韩精品一级二级| 欧美日高清视频| 亚洲午夜精品17c| 91精品国产综合久久小美女 | 国产精品久久久久影院亚瑟 | 国产一区在线视频| 久久影院视频免费| 国产乱妇无码大片在线观看| 久久久久99精品一区| 国产毛片精品视频| 久久天天做天天爱综合色| 精品一区二区在线免费观看| 日韩精品中文字幕一区| 日韩精品午夜视频| 欧美精品日韩综合在线| 亚洲精品日韩综合观看成人91| 欧美少妇xxx| 三级欧美在线一区| 91精品国模一区二区三区| 午夜视频一区在线观看| 欧美日韩视频在线观看一区二区三区| 一区二区三区加勒比av| 欧美精品丝袜中出| 婷婷开心激情综合| 欧美大白屁股肥臀xxxxxx| 国产一区二区视频在线| 亚洲色图欧洲色图婷婷|