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

📄 triangle.java

📁 Java程序设计(美) David D. Riley著 机械工业出版社 书籍配套 代码
💻 JAVA
字号:
// (Figure 8.17)import java.awt.Graphics;import javax.swing.JComponent;public class Triangle extends JComponent {	/**		post:	getbackGround() is an invisible color	 *				and  getWidth() == getHeight() == 0 	 */  	public Triangle( )   {		super( );	}		/**	post:	a Triangle is drawn with vertices at (getWidth()/2, 0),	 *					(0, getHeight()-1) and (getWidth()-1, getHeight()-1)	 *			and  the color of thhe triangle is getBackground() 	 */	public  void  paint( Graphics g )   {		g.setColor( getBackground() );		g.drawLine( getWidth()/2, 0, 0, getHeight()-1 );		g.drawLine( 0, getHeight()-1, getWidth()-1, getHeight()-1 );		g.drawLine( getWidth()/2, 0, getWidth()-1, getHeight()-1 );	}}

⌨️ 快捷键说明

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