debug15_4.java
来自「程序练习中包括书中实例程序代码和练习中要用到的代码,是压缩文件」· Java 代码 · 共 44 行
JAVA
44 行
package questions.c15;
import javax.swing.JPanel;
import java.awt.*;
public class Debug15_4 extends JPanel {
private String ovalHeight = "25";
private String ovalWidth = "50";
private static final Point START = new Point( 20, 20 );
public void setOvalHeight( String ovalHeight ) {
try {
listeners.fireVetoableChange( "ovalHeight",
this.ovalHeight,
ovalHeight );
this.ovalHeight = ovalHeight;
} catch ( PropertyVetoException pve ) {
// change was vetoed, nothing to do
}
}
public String getOvalHeight() {
return ovalHeight;
}
public void setOvalWidth( String ovalWidth ) {
try {
listeners.fireVetoableChange( "ovalWidth",
this.ovalWidth,
ovalWidth );
this.ovalWidth = ovalWidth;
} catch ( PropertyVetoException pve ) {
// change was vetoed, nothing to do
}
}
public String getOvalWidth() {
return ovalWidth;
}
public Dimension getPreferredSize() {
return new Dimension( 100, 100 );
}
public void paintComponent( Graphics g ) {
super.paintComponent( g );
int h = Integer.parseInt( ovalHeight );
int w = Integer.parseInt( ovalWidth );
g.fillOval( START.x, START.y, w, h );
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?