⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jcpanel.java

📁 非常好的java collapse游戏代码
💻 JAVA
字号:
/* * JCollapse - Java Collapse Game * Copyright (C) 2005 Erico Gon鏰lves Rimoli *  * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. *  * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the * GNU General Public License for more details. *  * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA. */package sourceforge.net.projects.jcollapse.game.components;import java.awt.Color;import java.awt.FlowLayout;import java.awt.GradientPaint;import java.awt.Graphics;import java.awt.Graphics2D;import java.awt.LayoutManager;import javax.swing.JPanel;/** * Panel for JCollapse Game. This Component provide a JPanel with gradient paint * @author erico */public class JCPanel extends JPanel {	private Color m_ColorFrom;	private Color m_ColorTo;		/**	 * Default constructor set layout to FlowLayout and	 * gradient paint to Color.WHITE to Color.BLACK	 */	public JCPanel() {		this( new FlowLayout(), Color.WHITE, Color.BLACK );	}		/**	 * Constructor with layout manager and	 * gradient paint to Color.WHITE to Color.BLACK	 * @param layoutManager the layout manager	 */	public JCPanel( LayoutManager layoutManager ) {		this( layoutManager, Color.WHITE, Color.BLACK );	}		/**	 * Constructor with layout manager and color set	 * @param layoutManager the layout manager	 * @param colorFrom the Color from	 * @param colorTo the Color to	 */	public JCPanel( LayoutManager layoutManager, Color colorFrom, Color colorTo ) {		super( layoutManager );		setColorFrom( colorFrom );		setColorTo( colorTo );	}		/**	 * Get the Color "from" for gradient fill	 * @return color the Color object	 */	public Color getColorFrom() {		return m_ColorFrom;	}		/**	 * Set the Color "from" for gradient fill	 * @param color the Color object	 */	public void setColorFrom( Color color ) {		m_ColorFrom = color;	}		/**	 * Get the Color "to" for gradient fill	 * @return color the Color object	 */	public Color getColorTo() {		return m_ColorTo;	}		/**	 * Set the Color "to" for gradient fill	 * @param color the Color object	 */	public void setColorTo( Color color ) {		m_ColorTo = color;	}		/* (non-Javadoc)	 * @see java.awt.Component#paint(java.awt.Graphics)	 */	public void paint( Graphics g ) {		Graphics2D g2d = (Graphics2D)g;		g2d.setPaint(				new GradientPaint(						(float)( getWidth() / 2 ),						0f,						getColorFrom(),						(float)( getWidth() / 2 ),						(float)getHeight(),						getColorTo()						)					);		g2d.fillRect( 0, 0, getWidth(), getHeight() );		paintChildren( g );		paintBorder( g );	}}

⌨️ 快捷键说明

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