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

📄 coloursampleicon.java

📁 FuncPlotter is a combined Java application and applet for displaying two-dimensional plots of explic
💻 JAVA
字号:
/*====================================================================*\ColourSampleIcon.javaColour sample icon class.------------------------------------------------------------------------This file is part of FuncPlotter, a combined Java application and appletfor plotting explicit functions in one variable.Copyright 2005-2007 Andy Morgan-Richards.FuncPlotter is free software: you can redistribute it and/or modify itunder the terms of the GNU General Public License as published by theFree Software Foundation, either version 3 of the License, or (at youroption) any later version.This program is distributed in the hope that it will be useful, butWITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNUGeneral Public License for more details.You should have received a copy of the GNU General Public License alongwith this program.  If not, see <http://www.gnu.org/licenses/>.\*====================================================================*/// PACKAGEpackage gui;//----------------------------------------------------------------------// IMPORTSimport java.awt.Color;import java.awt.Component;import java.awt.Graphics;import javax.swing.Icon;//----------------------------------------------------------------------// COLOUR SAMPLE ICON CLASSpublic class ColourSampleIcon    implements Icon{//////////////////////////////////////////////////////////////////////////  Constants////////////////////////////////////////////////////////////////////////    private static final    Color   BORDER_COLOUR           = Color.BLACK;    private static final    Color   DISABLED_BORDER_COLOUR  = new Color( 176, 176, 176 );//////////////////////////////////////////////////////////////////////////  Constructors////////////////////////////////////////////////////////////////////////    public ColourSampleIcon( int width,                             int height )    {        this.width = width;        this.height = height;    }    //------------------------------------------------------------------    public ColourSampleIcon( int   width,                             int   height,                             Color colour )    {        this( width, height );        this.colour = colour;    }    //------------------------------------------------------------------//////////////////////////////////////////////////////////////////////////  Instance methods : Icon interface////////////////////////////////////////////////////////////////////////    public int getIconWidth( )    {        return width;    }    //------------------------------------------------------------------    public int getIconHeight( )    {        return height;    }    //------------------------------------------------------------------    public void paintIcon( Component component,                           Graphics  gr,                           int       x,                           int       y )    {        gr.setColor( component.isEnabled( ) ? BORDER_COLOUR : DISABLED_BORDER_COLOUR );        gr.drawRect( x, y, width - 1, height - 1 );        gr.setColor( component.isEnabled( ) ? (colour == null) ? component.getForeground( ) : colour                                            : component.getBackground( ) );        gr.fillRect( x + 1, y + 1, width - 2, height - 2 );    }    //------------------------------------------------------------------//////////////////////////////////////////////////////////////////////////  Instance variables////////////////////////////////////////////////////////////////////////    private int     width;    private int     height;    private Color   colour;}//----------------------------------------------------------------------

⌨️ 快捷键说明

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