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

📄 imagebutton.html

📁 算法集合,说明java 中的各种算法的应用,带有源代码,可运行调试
💻 HTML
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN"><!--NewPage--><html><head><!-- Generated by javadoc on Tue Nov 03 15:31:36 EST 1998 --><title>  Class ImageButton</title></head><body><a name="_top_"></a><h1>  Class ImageButton</h1><pre>java.lang.Object   |   +----java.awt.Component           |           +----java.awt.Button                   |                   +----ImageButton</pre><hr><dl>  <dt> public class <b>ImageButton</b>  <dt> extends Button</dl>The <code>ImageButton</code> class extends the original <code>java.awt.Button</code> to display graphical images in  <code>gif</code> format. In this particular implementation, the images to be loaded have to be located in the same directory as the <code>code base</code> (which can be accessed using <code>Applet.getCodeBase()</code>). <p> In order to work around the bug in some of the older java complient web browser, in particular, the <code>class not found</code> exception during the initilization of the frame using Netscape 2.0, this class is casted to its parent class <code>Button</code> and explicitly casted back to <code>ImageButton</code> when the  customized methods are required.<p><dl>    <dt> <b>See Also:</b>    <dd> Button</dl><hr><a name="index"></a><h2>  <img src="images/constructor-index.gif" width=275 height=38 alt="Constructor Index"></h2><dl>  <dt> <img src="images/yellow-ball-small.gif" width=6 height=6 alt=" o ">	<a href="#ImageButton(java.lang.String, AlgAnimApp, ControlPanel)"><b>ImageButton</b></a>(String, AlgAnimApp, ControlPanel)  <dd>  Creates an <code>ImageButton</code> using the <code>gif</code> file specified by the first parameter on the panel defined by the third parameter.</dl><h2>  <img src="images/method-index.gif" width=207 height=38 alt="Method Index"></h2><dl>  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">	<a href="#getPreferredSize()"><b>getPreferredSize</b></a>()  <dd>  Specify the dimension of the button.  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">	<a href="#paint(java.awt.Graphics)"><b>paint</b></a>(Graphics)  <dd>  Method to draw image on the button  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">	<a href="#preferredSize()"><b>preferredSize</b></a>()  <dd>  Specify the dimension of the button.  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">	<a href="#print(java.awt.Graphics)"><b>print</b></a>(Graphics)  <dd>  Method to draw image on the button  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">	<a href="#setDisable()"><b>setDisable</b></a>()  <dd>  Disable the image button and set the current image to <code>imageFileDisable.gif</code>.  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">	<a href="#setEnable()"><b>setEnable</b></a>()  <dd>  Enable the image button and set the current image to <code>imageFile.gif</code>  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">	<a href="#update(java.awt.Graphics)"><b>update</b></a>(Graphics)  <dd>  This method is invokes when the <code>repaint</code> method is called.</dl><a name="constructors"></a><h2>  <img src="images/constructors.gif" width=231 height=38 alt="Constructors"></h2><a name="ImageButton"></a><a name="ImageButton(java.lang.String, AlgAnimApp, ControlPanel)"><img src="images/yellow-ball.gif" width=12 height=12 alt=" o "></a><b>ImageButton</b><pre> public ImageButton(String imageFile,                    <a href="AlgAnimApp.html#_top_">AlgAnimApp</a> app,                    <a href="ControlPanel.html#_top_">ControlPanel</a> parent)</pre><dl>  <dd> Creates an <code>ImageButton</code> using the <code>gif</code> file specified by the first parameter on the panel defined by the third parameter. <p> Before calling this constructor, make sure that the image file <code>imageFile.gif</code> exists. It is also required to have another gif image <code>imageFileDisable.gif</code>, which appears to be the disabled button.<p>  <dd><dl>    <dt> <b>Parameters:</b>    <dd> imageFile - The gif image file without the <code>.gif</code> extension. The extension will be appended when calling the <code>Applet.getImage()</code> method. <p>    <dd> app - An instance to an applet. The only applet in this cluster of classes, an instance of <code>AlgAnimApp</code>, is usually passed in here. This particular applet is used to obtain the code base, i.e. the location of the image files. <p>    <dd> parent - The panel where this image button is going to reside. This paremeter is passed in so that the repaint method for the panel can be called when a refreshing is required.  </dl></dd></dl><a name="methods"></a><h2>  <img src="images/methods.gif" width=151 height=38 alt="Methods"></h2><a name="getPreferredSize()"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a><a name="getPreferredSize"><b>getPreferredSize</b></a><pre> public Dimension getPreferredSize()</pre><dl>  <dd> Specify the dimension of the button. In this particular application, images with resolution of 42x52 are used. Therefore, this method always returns <code>Dimension</code> with <code>width</code> 42 and <code>height</code> 52. This method is only called by the system layout manager.<p>  <dd><dl>    <dt> <b>Returns:</b>    <dd> The dimention of the button.    <dt> <b>Overrides:</b>    <dd> <a href="java.awt.Component.html#getPreferredSize()">getPreferredSize</a> in class Component  </dl></dd></dl><a name="preferredSize()"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a><a name="preferredSize"><b>preferredSize</b></a><pre> public Dimension preferredSize()</pre><dl>  <dd> Specify the dimension of the button. In this particular application, images with resolution of 42x52 are used. Therefore, this method always returns <code>Dimension</code> with <code>width</code> 42 and <code>height</code> 52. This method is only called by the system layout manager.<p>  <dd><dl>    <dt> <b>Returns:</b>    <dd> The dimention of the button.    <dt> <b>Overrides:</b>    <dd> <a href="java.awt.Component.html#preferredSize()">preferredSize</a> in class Component  </dl></dd></dl><a name="setDisable()"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a><a name="setDisable"><b>setDisable</b></a><pre> public void setDisable()</pre><dl>  <dd> Disable the image button and set the current image to <code>imageFileDisable.gif</code>.<p></dl><a name="setEnable()"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a><a name="setEnable"><b>setEnable</b></a><pre> public void setEnable()</pre><dl>  <dd> Enable the image button and set the current image to <code>imageFile.gif</code><p></dl><a name="print(java.awt.Graphics)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a><a name="print"><b>print</b></a><pre> public void print(Graphics g)</pre><dl>  <dd> Method to draw image on the button<p>  <dd><dl>    <dt> <b>Overrides:</b>    <dd> <a href="java.awt.Component.html#print(java.awt.Graphics)">print</a> in class Component  </dl></dd></dl><a name="update(java.awt.Graphics)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a><a name="update"><b>update</b></a><pre> public void update(Graphics g)</pre><dl>  <dd> This method is invokes when the <code>repaint</code> method is called.<p>  <dd><dl>    <dt> <b>Overrides:</b>    <dd> <a href="java.awt.Component.html#update(java.awt.Graphics)">update</a> in class Component  </dl></dd></dl><a name="paint(java.awt.Graphics)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a><a name="paint"><b>paint</b></a><pre> public void paint(Graphics g)</pre><dl>  <dd> Method to draw image on the button<p>  <dd><dl>    <dt> <b>Overrides:</b>    <dd> <a href="java.awt.Component.html#paint(java.awt.Graphics)">paint</a> in class Component  </dl></dd></dl></body></html>

⌨️ 快捷键说明

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