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

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

?? appletmenubar.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.gui;import java.awt.*;import java.awt.event.*;import java.util.Vector;public class AppletMenuBar extends Panel {    // Menubar contents    Vector labels = new Vector();    Vector menus = new Vector();    // Properties    Insets margins = new Insets(3, 10, 3, 10); // top, left, bottom, right    int spacing = 10;              // Space between menu labels    Color highlightColor;          // Rollover color for labels    // internal stuff    boolean remeasure = true;      // Whether the labels need to be remeasured    int[] widths;                          // The width of each label    int[] startPositions;                  // Where each label starts    int ascent, descent;                   // Font metrics    Dimension prefsize = new Dimension();  // How big do we want to be?    int highlightedItem = -1;              // Which item is the mouse over?    /**     * Create a new component that simulates a menubar by displaying     * the specified labels.  Whenever the user clicks the specified label,     * popup up the PopupMenu specified in the menus array.     * Elements of the menus arra may be a static PopupMenu object, or     * a PopupMenuFactory object for dynamically creating menus.     * Perhaps we'll also provide some other kind of constructor or factory     * method that reads popup menus out of a config file.     */    public AppletMenuBar() {	// We'd like these kinds of events to be delivered	enableEvents(AWTEvent.MOUSE_EVENT_MASK |		     AWTEvent.MOUSE_MOTION_EVENT_MASK);    }    /** Add a popup menu to the menubar */    public void addMenu(String label, PopupMenu menu) {	insertMenu(label, menu, -1);    }    /** Insert a popup menu into the menubar */    public void insertMenu(String label, PopupMenu menu, int index) {	if (index < 0) index += labels.size()+1;  // Position to put it at	this.add(menu);                           // Popup belongs to us	labels.insertElementAt(label, index);     // Remember the label	menus.insertElementAt(menu, index);       // Remember the menu	remeasure = true;                         // Remeasure everything	invalidate();                             // Container must relayout    }    /** Property accessor methods for margins property */    public Insets getMargins() { return (Insets) margins.clone(); }    public void setMargins(Insets margins) {	this.margins = margins;	remeasure = true;	invalidate();    }    /** Property accessor methods for spacing property */    public int getSpacing() { return spacing; }    public void setSpacing(int spacing) {	if (this.spacing != spacing) {	    this.spacing = spacing;	    remeasure = true;	    invalidate();	}    }    /** Accessor methods for highlightColor property */    public Color getHighlightColor() {	if (highlightColor == null) return getForeground();	else return highlightColor;    }    public void setHighlightColor(Color c) {	if (highlightColor != c) {	    highlightColor = c;	    repaint();	}    }    /** We override the setFont() method so we can remeasure */    public void setFont(Font f) {	super.setFont(f);	remeasure = true;	invalidate();    }    /** Override these color property setter method so we can repaint */    public void setForeground(Color c) {	super.setForeground(c);	repaint();    }    public void setBackground(Color c) {	super.setBackground(c);	repaint();    }    /**     * This method is called to draw tell the component to redraw itself.     * If we were implementing a Swing component, we'd override      * paintComponent() instead     **/    public void paint(Graphics g) {	if (remeasure) measure();  // Remeasure everything first, if needed		// Figure out Y coordinate to draw at	Dimension size = getSize();	int baseline = size.height - margins.bottom - descent;	// Set the font to draw with	g.setFont(getFont());	// Loop through the labels	int nummenus = labels.size();	for(int i = 0; i < nummenus; i++) {	    // Set the drawing color.  Highlight the current item	    if ((i == highlightedItem) && (highlightColor != null))		g.setColor(getHighlightColor());	    else		g.setColor(getForeground());	    // Draw the menu label at the position computed in measure()	    g.drawString((String)labels.elementAt(i), 			 startPositions[i], baseline);	}	// Now draw a groove at the bottom of the menubar.	Color bg = getBackground();	g.setColor(bg.darker());	g.drawLine(0, size.height-2, size.width, size.height-2);	g.setColor(bg.brighter());	g.drawLine(0, size.height-1, size.width, size.height-1);    }    /** Called when a mouse event happens over the menubar */    protected void processMouseEvent(MouseEvent e) {	int type = e.getID();             // What type of event?	int item = findItemAt(e.getX());  // Over which menu label?	if (type == MouseEvent.MOUSE_PRESSED) {	    // If it was a mouse down event, then pop up the menu	    if (item == -1) return;	    Dimension size = getSize();	    PopupMenu pm = (PopupMenu) menus.elementAt(item);	    if (pm != null) pm.show(this, startPositions[item]-3, size.height);	}	else if (type == MouseEvent.MOUSE_EXITED) {	    // If the mouse left the menubar, then unhighlight	    if (highlightedItem != -1) {		highlightedItem = -1;		if (highlightColor != null) repaint();	    }	}	else if ((type == MouseEvent.MOUSE_MOVED) || 		 (type == MouseEvent.MOUSE_ENTERED)) {	    // If the mouse moved, change the highlighted item, if necessary	    if (item != highlightedItem) {		highlightedItem = item;		if (highlightColor != null) repaint();	    }	}    }    /** This method is called when the mouse moves */    protected void processMouseMotionEvent(MouseEvent e) {	processMouseEvent(e);    }    /** This utility method converts an X coordinate to a menu label index */    protected int findItemAt(int x) {	// This could be a more efficient search...	int nummenus = labels.size();	int halfspace = spacing/2-1;	int i;	for(i = nummenus-1; i >= 0; i--) {	    if ((x >= startPositions[i]-halfspace) && 		(x <= startPositions[i]+widths[i]+halfspace)) break;	}	return i;    }    /**     * Measure the menu labels, and figure out their positions, so we     * can determine when a click happens, and so we can redraw efficiently.     **/    protected void measure() {	// Get information about the font	FontMetrics fm = this.getFontMetrics(getFont());	// Remember the basic font size	ascent = fm.getAscent();	descent = fm.getDescent();	// Create arrays to hold the measurements and positions	int nummenus = labels.size();	widths = new int[nummenus];	startPositions = new int[nummenus];	// Measure the label strings and	// figure out the starting position of each label	int pos = margins.left;	for(int i = 0; i < nummenus; i++) {	    startPositions[i] = pos;	    String label = (String)labels.elementAt(i);	    widths[i] = fm.stringWidth(label);	    pos += widths[i] + spacing;	}	// Compute our preferred size from this data	prefsize.width = pos - spacing + margins.right;	prefsize.height = ascent + descent + margins.top + margins.bottom;	// We've don't need to be remeasured anymore.	remeasure = false;    }    /**     * These methods tell the container how big the menubar wants to be.     *      **/    public Dimension getMinimumSize() { return getPreferredSize(); }    public Dimension getPreferredSize() {	if (remeasure) measure();	return prefsize;    }    /** @deprecated Here for compatibility with Java 1.0 */    public Dimension minimumSize() { return getPreferredSize(); }    /** @deprecated Here for compatibility with Java 1.0 */    public Dimension preferredSize() { return getPreferredSize(); }    /**      * This method is called when the underlying AWT component is created.     * We can't measure ourselves (no font metrics) until this is called.     **/    public void addNotify() {	super.addNotify();	measure();    }    /** This method tells the container not to give us keyboard focus */    public boolean isFocusTraversable() { return false; }}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
午夜精品久久久久久久蜜桃app| 91麻豆自制传媒国产之光| 在线91免费看| 视频一区免费在线观看| 欧美日韩精品久久久| 午夜电影网亚洲视频| 欧美一区二区视频在线观看| 久久99精品久久久久久| 久久久久综合网| eeuss鲁片一区二区三区| 亚洲欧美韩国综合色| 欧美日韩一本到| 奇米影视一区二区三区| 久久免费偷拍视频| 91污片在线观看| 视频一区视频二区中文| 久久嫩草精品久久久久| av不卡一区二区三区| 亚洲一卡二卡三卡四卡| 日韩一区二区三区免费看| 国产一区二区视频在线| 最新国产精品久久精品| 欧美精品在线观看播放| 国产乱人伦偷精品视频免下载| 日本一区二区综合亚洲| 欧美在线高清视频| 另类综合日韩欧美亚洲| 亚洲少妇屁股交4| 91精品国产综合久久国产大片| 国产精品888| 亚洲一区在线电影| 337p日本欧洲亚洲大胆色噜噜| 成人av网在线| 免费美女久久99| 国产精品久久久一区麻豆最新章节| 91国产免费观看| 寂寞少妇一区二区三区| 一区二区三区成人| 久久久久久99久久久精品网站| 91色porny| 国产一区二区在线电影| 亚洲综合视频在线| 国产亚洲精久久久久久| 精品视频999| 国产成人av电影在线观看| 亚洲一级二级在线| 日本不卡视频一二三区| 中文字幕一区免费在线观看| 欧美一区二区三区小说| 91官网在线观看| 国产精品一区2区| 天天av天天翘天天综合网色鬼国产| 国产精品欧美一区喷水| 日韩欧美高清一区| 欧美人与性动xxxx| 99精品久久久久久| 国产成人aaaa| 久久国产精品一区二区| 午夜av电影一区| 亚洲人精品午夜| 国产女主播视频一区二区| 精品国产人成亚洲区| 538在线一区二区精品国产| 色综合久久久久综合体桃花网| 国产一区二区电影| 久久精工是国产品牌吗| 婷婷成人激情在线网| 亚洲一区视频在线| 一区二区三区四区在线| 亚洲欧洲一区二区在线播放| 欧美国产日韩精品免费观看| 精品久久久久久久一区二区蜜臀| 91精品午夜视频| 欧美人伦禁忌dvd放荡欲情| 欧美在线色视频| 在线观看国产一区二区| 在线一区二区三区| 色婷婷精品久久二区二区蜜臀av| 97精品久久久久中文字幕| 成人av先锋影音| 91视视频在线观看入口直接观看www | 国产视频视频一区| 2023国产一二三区日本精品2022| 日韩欧美久久久| 欧美精品一区二区三区高清aⅴ | 中文字幕不卡的av| 国产欧美精品一区| 国产精品久久久久久久岛一牛影视| 亚洲国产精品黑人久久久| 国产精品久久久久久久久快鸭| 国产精品久久久久久久久久免费看| 中文欧美字幕免费| 日韩一区欧美小说| 亚洲综合在线五月| 午夜视频在线观看一区| 蜜臀久久99精品久久久久宅男 | 欧美日韩中文精品| 欧美性做爰猛烈叫床潮| 欧美丰满美乳xxx高潮www| 日韩一区二区三免费高清| 欧美大片日本大片免费观看| 欧美不卡一区二区三区四区| 精品成人一区二区三区| 国产精品每日更新在线播放网址| 国产精品久久三| 一区二区三区毛片| 日韩电影一二三区| 国产精品一区二区你懂的| 菠萝蜜视频在线观看一区| 在线观看三级视频欧美| 91精品国产乱码| 国产视频一区二区三区在线观看| 亚洲男女一区二区三区| 日韩综合小视频| 国产精品影音先锋| 欧美亚洲免费在线一区| 久久综合九色综合97婷婷| 国产精品乱子久久久久| 亚洲综合一区二区三区| 国产在线不卡视频| 色噜噜偷拍精品综合在线| 日韩女同互慰一区二区| 国产精品久久久久久久久搜平片| 五月婷婷综合在线| 另类的小说在线视频另类成人小视频在线| 国产成人a级片| 欧美精品免费视频| 国产精品久久久久久久久搜平片| 午夜精品福利一区二区三区蜜桃| 国产中文字幕一区| 欧美中文字幕一区二区三区| 26uuu精品一区二区在线观看| 亚洲人成人一区二区在线观看| 日韩av在线播放中文字幕| 成人app下载| 日韩一区二区在线观看视频播放| 国产精品久久久久久久久免费桃花| 亚洲电影一区二区| 国产.欧美.日韩| 欧美一卡二卡在线| 日韩理论片一区二区| 久草精品在线观看| 欧美性一二三区| 中文字幕一区二区三区乱码在线 | 国产麻豆精品一区二区| 欧美视频在线观看一区| 亚洲同性同志一二三专区| 韩国在线一区二区| 欧美一区日本一区韩国一区| 亚洲激情自拍偷拍| av综合在线播放| 国产清纯白嫩初高生在线观看91 | 欧美乱熟臀69xxxxxx| 中文字幕制服丝袜成人av| 国产在线一区观看| 欧美一区二区三区免费在线看| 亚洲区小说区图片区qvod| 国产成人午夜高潮毛片| 日韩三级在线观看| 日韩精品电影一区亚洲| 在线观看国产一区二区| 亚洲青青青在线视频| 99re这里只有精品首页| 国产精品国模大尺度视频| 懂色av一区二区夜夜嗨| 久久久国产精品午夜一区ai换脸| 九九久久精品视频| 精品日韩在线观看| 黄色成人免费在线| 欧美tk丨vk视频| 激情欧美日韩一区二区| 精品国产免费人成电影在线观看四季 | 色视频欧美一区二区三区| 国产精品每日更新| 99精品视频在线播放观看| 国产精品色眯眯| 国产成人综合精品三级| 国产欧美精品国产国产专区| 国产精品一品二品| 久久精品无码一区二区三区| 国产中文字幕精品| 欧美激情一区在线| 成人午夜视频在线| 中文字幕一区二区三区乱码在线| 99re热这里只有精品免费视频| 国产精品护士白丝一区av| 色噜噜夜夜夜综合网| 亚洲成人av一区二区三区| 777xxx欧美| 韩国精品久久久| 国产精品天干天干在线综合| 99精品国产视频| 亚洲最大色网站| 欧美大尺度电影在线| 国产成人精品免费| 一区二区三区精品视频| 欧美一级高清片在线观看| 国产一区二区福利| 亚洲欧美另类综合偷拍| 宅男噜噜噜66一区二区66|