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

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

?? swingshapemover.java

?? 這是一個學習鼠標事件處理的程序
?? JAVA
字號:
/*
* @(#)SwingShapeMover.java   1.2 98/07/31
*/


import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
import javax.swing.*;

/*
 * This applet allows the user to move a texture painted rectangle around the applet
 * window.  The rectangle flickers and draws slowly because this applet does not use 
 * double buffering.
*/

public class SwingShapeMover extends JApplet {
    static protected JLabel label;
    DPanel d;

    public void init(){
        getContentPane().setLayout(new BorderLayout());

        d = new DPanel();
        d.setBackground(Color.white);
        getContentPane().add(d);

        label = new JLabel("Drag rectangle around within the area");
        getContentPane().add("South", label);
    }

    public static void main(String s[]) {
        JFrame f = new JFrame("SwingShapeMover");
        f.addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) {System.exit(0);}
        });
        JApplet applet = new SwingShapeMover();
        f.getContentPane().add("Center", applet);
        applet.init();
        f.pack();
        f.setSize(new Dimension(550,250));
        f.show();
    }

}


class DPanel extends JPanel implements MouseListener, MouseMotionListener{
        Rectangle rect = new Rectangle(0, 0, 100, 50);
        BufferedImage bi;
        Graphics2D big;
        
        // Holds the coordinates of the user's last mousePressed event.
        int last_x, last_y;
        boolean firstTime = true;
        TexturePaint fillPolka, strokePolka;
	      Rectangle area;                
        // True if the user pressed, dragged or released the mouse outside of
        // the rectangle; false otherwise.
        boolean pressOut = false;   


    public DPanel(){
                setBackground(Color.white);
                addMouseMotionListener(this);
                addMouseListener(this);

                // Creates the fill texture paint pattern.
                bi = new BufferedImage(5, 5, BufferedImage.TYPE_INT_RGB);
                big = bi.createGraphics();
                big.setColor(Color.pink);
                big.fillRect(0, 0, 7, 7);
                big.setColor(Color.cyan);
                big.fillOval(0, 0, 3, 3);
                Rectangle r = new Rectangle(0,0,5,5);
                fillPolka = new TexturePaint(bi, r);
                big.dispose();
        
                //Creates the stroke texture paint pattern.
                bi = new BufferedImage(5, 5, BufferedImage.TYPE_INT_RGB);
                big = bi.createGraphics();
                big.setColor(Color.cyan);
                big.fillRect(0, 0, 7, 7);
                big.setColor(Color.pink);
                big.fillOval(0, 0, 3, 3);
                r = new Rectangle(0,0,5,5);
                strokePolka = new TexturePaint(bi, r);
                big.dispose();
    }

    // Handles the event of the user pressing down the mouse button.
    public void mousePressed(MouseEvent e){

            last_x = rect.x - e.getX();
            last_y = rect.y - e.getY();

            // Checks whether or not the cursor is inside of the rectangle
            // while the user is pressing the mouse.
            if ( rect.contains(e.getX(), e.getY()) ) {
		 updateLocation(e);
            } else {
                 SwingShapeMover.label.setText("First position the cursor on the rectangle and then drag.");
		 pressOut = true;
            }
    }

    // Handles the event of a user dragging the mouse while holding
    // down the mouse button.
    public void mouseDragged(MouseEvent e){

            if ( !pressOut ) {
		updateLocation(e);
            } else {
                SwingShapeMover.label.setText("First position the cursor on the rectangle and then drag.");
	    }
    }

    // Handles the event of a user releasing the mouse button.
    public void mouseReleased(MouseEvent e){

            // Checks whether or not the cursor is inside of the rectangle
            // when the user releases the mouse button.
            if ( rect.contains(e.getX(), e.getY()) ) {
		 updateLocation(e);
            } else {
                 SwingShapeMover.label.setText("First position the cursor on the rectangle and then drag.");
		 pressOut = false;
            }
    }
       
     // This method is required by MouseListener.
     public void mouseMoved(MouseEvent e){}

     // These methods are required by MouseMotionListener.
     public void mouseClicked(MouseEvent e){}
     public void mouseExited(MouseEvent e){}
     public void mouseEntered(MouseEvent e){}
                         
     // Updates the coordinates representing the location of the current rectangle.
     public void updateLocation(MouseEvent e){
                 rect.setLocation(last_x + e.getX(), last_y + e.getY());
                /*
                 * Updates the label to reflect the location of the
                 * current rectangle
                 * if checkRect returns true; otherwise, returns error message.
                 */
                if (checkRect()) {
                    SwingShapeMover.label.setText("Rectangle located at " +
                                                     rect.getX() + ", " +
                                                     rect.getY());
                } else {
                    SwingShapeMover.label.setText("Please don't try to "+
                                                     " drag outside the area.");
                }
 
		repaint();
     }

    public void paintComponent(Graphics g){
        super.paintComponent(g);
        Graphics2D g2 = (Graphics2D)g;
	g2.setStroke(new BasicStroke(8.0f));
        Dimension dim = getSize();
        int w = (int)dim.getWidth();
        int h = (int)dim.getHeight();

        if ( firstTime ) {
            area = new Rectangle(dim);
	    rect.setLocation(w/2-50, h/2-25);
            firstTime = false;
	}
        // Clears the rectangle that was previously drawn.
        g2.setPaint(Color.white);
        g2.fillRect(0, 0, w, h);


        // Draws and fills the newly positioned rectangle.
	g2.setPaint(fillPolka);
        g2.fill(rect);	
        g2.setPaint(strokePolka);
        g2.draw(rect);

    }

    /*
     Checks if the rectangle is contained within the applet window.  If the rectangle
     is not contained withing the applet window, it is redrawn so that it is adjacent
     to the edge of the window and just inside the window.
    */

    boolean checkRect(){

	       if (area == null) {
			return false;
	       }

               if(area.contains(rect.x, rect.y, 100, 50)){
                        return true;
                }
                int new_x = rect.x;
                int new_y = rect.y;
        
                if((rect.x+100)>area.getWidth()){
                        new_x = (int)area.getWidth()-99;
                }
                if(rect.x < 0){
                        new_x = -1;  
                }
                if((rect.y+50)>area.getHeight()){
                        new_y = (int)area.getHeight()-49;
                }
                if(rect.y < 0){
                        new_y = -1;
                }
                rect.setLocation(new_x, new_y);
                return false;
    }
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
午夜不卡av免费| 亚洲精品免费电影| 久久er精品视频| 日本一区二区在线不卡| 不卡视频在线观看| 日韩高清不卡一区二区三区| 久久伊99综合婷婷久久伊| 91浏览器打开| 激情图片小说一区| 亚洲国产精品一区二区尤物区| 26uuu亚洲婷婷狠狠天堂| 日韩欧美高清一区| 欧美综合色免费| 成人精品视频一区二区三区尤物| 亚洲地区一二三色| 国产精品久久久久久久久晋中| 欧美一区二区黄| 在线精品视频一区二区三四 | 91精品国产品国语在线不卡| 欧美日韩精品一区二区三区蜜桃 | 亚洲国产精品欧美一二99| 亚洲一区二区三区美女| 中文字幕的久久| 欧美大片在线观看一区二区| 精品欧美乱码久久久久久1区2区| 欧美日韩国产片| 欧美不卡在线视频| 国产亚洲欧美日韩日本| 日韩精品一区在线观看| 国产喷白浆一区二区三区| 亚洲女同ⅹxx女同tv| 久久精品视频网| 一区二区三区欧美亚洲| 综合久久久久久久| 中文字幕中文字幕一区二区| 亚洲成人自拍网| 国产激情视频一区二区在线观看| 久久国产欧美日韩精品| 成人av午夜影院| 51午夜精品国产| 日韩视频免费直播| 日韩精品一区二区三区老鸭窝| 国产精品日产欧美久久久久| 国产精品久久久久婷婷二区次| 亚洲丶国产丶欧美一区二区三区| 国产一区二区影院| 成+人+亚洲+综合天堂| 欧美高清视频www夜色资源网| 欧美日本在线播放| 国产精品视频在线看| 丝袜国产日韩另类美女| 性做久久久久久久免费看| 国产精品一二三区在线| 成人小视频免费观看| 69久久夜色精品国产69蝌蚪网| 国产精品天天看| 狠狠网亚洲精品| 日韩一二三区视频| 亚洲国产欧美在线| a美女胸又www黄视频久久| 色婷婷久久一区二区三区麻豆| 欧美性一区二区| 日韩午夜激情电影| 一区二区在线观看视频在线观看| 国产99久久久国产精品潘金网站| 99视频国产精品| 国产精品丝袜一区| 国产一区二区在线电影| 日韩欧美在线1卡| 视频一区二区中文字幕| 在线一区二区三区四区五区| 91精品国产综合久久精品| 亚洲精品免费一二三区| 色综合激情五月| 尤物视频一区二区| 欧美性淫爽ww久久久久无| 亚洲欧洲av在线| 久久精品99国产国产精| 91精品国模一区二区三区| 偷窥少妇高潮呻吟av久久免费| 色婷婷综合在线| 亚洲最新视频在线观看| 在线视频中文字幕一区二区| 亚洲精品成人天堂一二三| 97se亚洲国产综合自在线| 日韩免费观看高清完整版| 蜜桃视频第一区免费观看| 91网站最新地址| 亚洲码国产岛国毛片在线| 一本大道久久a久久综合| 亚洲蜜臀av乱码久久精品| 色婷婷精品久久二区二区蜜臀av| 一区二区三区四区不卡在线 | 欧美变态口味重另类| 久久99国内精品| 欧美综合在线视频| 亚洲成人免费在线| 日韩免费观看高清完整版| 黄色精品一二区| 中文字幕一区二| 欧美日韩亚洲综合一区| 亚洲天堂2016| 欧美日韩国产精品自在自线| 美女视频黄免费的久久| 国产亚洲午夜高清国产拍精品| 丰满少妇在线播放bd日韩电影| 亚洲男人电影天堂| 6080亚洲精品一区二区| 懂色av一区二区三区免费看| 亚洲日本va在线观看| 337p亚洲精品色噜噜噜| 国产精品小仙女| 亚洲午夜成aⅴ人片| 精品捆绑美女sm三区| 91一区一区三区| 美国欧美日韩国产在线播放| 中文文精品字幕一区二区| 精品视频一区二区三区免费| 精品一区二区三区日韩| 亚洲精品国产高清久久伦理二区| 欧美变态tickling挠脚心| 色综合 综合色| 免费在线看成人av| 欧美大片国产精品| 91免费看`日韩一区二区| 日韩中文字幕区一区有砖一区 | 97久久超碰国产精品电影| 日韩影视精彩在线| 自拍av一区二区三区| 日韩欧美一区二区免费| 欧美性感一区二区三区| 成人激情午夜影院| 国产一区二区免费在线| 亚洲aⅴ怡春院| 亚洲免费观看视频| 国产婷婷色一区二区三区| 337p亚洲精品色噜噜噜| 色婷婷激情久久| 成人午夜看片网址| 国产中文一区二区三区| 日韩av电影免费观看高清完整版在线观看| 国产精品毛片久久久久久久| 精品免费日韩av| 欧美一区二区视频观看视频 | 88在线观看91蜜桃国自产| av在线不卡免费看| 成人性生交大片免费看视频在线 | 国产精品美女久久久久aⅴ | 伊人色综合久久天天| 国产精品你懂的在线欣赏| 精品999久久久| 91啪九色porn原创视频在线观看| 国产精品77777| 国产激情一区二区三区| 国产精品69毛片高清亚洲| 国内偷窥港台综合视频在线播放| 六月婷婷色综合| 久久99久久精品| 国产精品亚洲人在线观看| 国产一区二区毛片| 国产成人精品影视| 处破女av一区二区| 成人网在线免费视频| av在线一区二区三区| 91网站在线观看视频| 日本精品一区二区三区高清 | 中文字幕乱码一区二区免费| 国产精品亲子伦对白| 国产精品理论片| 一区二区高清在线| 日韩极品在线观看| 国产在线观看一区二区| 国产成人啪午夜精品网站男同| 成人免费观看视频| 在线中文字幕不卡| 日韩一区二区三区av| 久久久影院官网| 91麻豆精品国产91久久久久久| 欧美一级欧美一级在线播放| 精品对白一区国产伦| 综合中文字幕亚洲| 婷婷综合在线观看| 国产激情视频一区二区三区欧美 | 在线播放91灌醉迷j高跟美女 | 老司机午夜精品| 成人激情图片网| 91精品国产色综合久久ai换脸| 精品人在线二区三区| 国产精品三级在线观看| 亚洲视频一区二区在线| 天天亚洲美女在线视频| 国产激情一区二区三区| 欧美日韩一区在线| 久久久久国产精品麻豆| 亚洲成人免费电影| 国产91精品入口| 欧美日韩精品一区二区三区四区| 久久久久久久国产精品影院| 无码av免费一区二区三区试看| 国产精品一区专区|