pausebutton.java

来自「FMJ(freedom media for java)是java视频开发的新选择」· Java 代码 · 共 73 行

JAVA
73
字号
package net.sf.fmj.ejmf.toolkit.gui.controls.skins.ejmf;import java.awt.Color;import java.awt.Graphics;import javax.swing.UIManager;/*** Pause button for StandardControlPanel.* <p>* PauseButton over-rides BasicControlButton's paintIcon* method to draw two vertical bars as button icon.* <p>* @see net.sf.fmj.ejmf.toolkit.gui.controls.skins.ejmf.BasicControlButton*/ public class PauseButton extends BasicControlButton{	/** Create a pause button.	*/	public PauseButton() {	   super();	}		/**	* Draw two rectangles into button.        *	* @param g Graphics into which rectangles are drawn.	* @param x not used.	* @param y not used	.	* @param size not used. Rather Component.getSize() is used to 	* to determine size of button and size of bars is determined	* relative to those dimensions.	* @param isEnabled If true, bars are drawn enabled (i.e. black), 	* otherwise, they are offset by (1,1) and drawn with UIManager's	* controlShadow color.	*/ 	protected void paintIcon(Graphics g, int x, int y, int size, boolean isEnabled) {	    int w = getSize().width;	    int h = getSize().height;	    int x_inc = w / 8;	    int y_inc = h / 4;	    int bar_w = 2 * x_inc - x_inc/2;	    int bar_h = 2 * y_inc;	    g.translate(2*x_inc+1, y_inc);	    if (isEnabled) {	        g.fillRect(0, 0, bar_w, bar_h);	        g.fillRect(3*x_inc, 0, bar_w, bar_h);	    } else {		g.translate(1, 1);		Color oldColor = g.getColor();		g.setColor(UIManager.getColor("controlShadow"));	        g.fillRect(0, 0, bar_w, bar_h);	        g.fillRect(3*x_inc, 0, bar_w, bar_h);		// "Hightlight" edge of bars to make them look etched.		g.setColor(UIManager.getColor("controlHighlight"));		// Etch right-side of left bar		g.drawLine(bar_w, 0, bar_w, bar_h-1);		// Etch bottom of left bar		g.drawLine(0, bar_h-1, bar_w, bar_h-1);		// Etch right-side of right bar		g.drawLine(3*x_inc+bar_w, 0, 3*x_inc+bar_w, bar_h-1);		// Etch bottom of right bar		g.drawLine(3*x_inc, bar_h-1, 3*x_inc+bar_w, bar_h-1);		g.setColor(oldColor);		g.translate(-1, -1);	    }	    g.translate(-x_inc, -y_inc);        }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?