📄 downtriangle.java
字号:
// Figure 14.21import javax.swing.JComponent;import java.awt.*;public class DownTriangle extends JComponent { /** post: getX() == x-h/2 and getY() == y+h/2 * and getWdith()==h/2 and getHeight()==h/2 */ public DownTriangle(int x, int y, int h ) { super(); setBounds(x-h/4, y+h/2, h/2, h/2); } /** post: a black triangle is drawn with vertices at upper * left, upper right and center bottom of the * bounding rectangle */ public void paint(Graphics g) { g.setColor(Color.black); g.drawLine(0, 0, getWidth()-1, 0); g.drawLine(0, 0, getWidth()/2, getHeight()-1); g.drawLine(getHeight()-1, 0, getWidth()/2, getHeight()-1); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -