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