📄 custompanel.java
字号:
// A customized JPanel class.
import java.awt.*;
import javax.swing.*;
public class CustomPanel extends JPanel {
public final static int CIRCLE = 1, SQUARE = 2;
private int shape;
public void paintComponent( Graphics g )
{
super.paintComponent( g );
if ( shape == CIRCLE )
g.fillOval( 50, 10, 60, 60 );
else if ( shape == SQUARE )
g.fillRect( 50, 10, 60, 60 );
}
public void draw( int s )
{
shape = s;
repaint();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -