📄 linesrectsovals.java
字号:
// Fig. 12.14: LinesRectsOvals.java
// Drawing lines, rectangles and ovals.
import java.awt.*;
import javax.swing.*;
public class LinesRectsOvals extends JFrame {
// set window's title bar String and dimensions
public LinesRectsOvals()
{
super( "Drawing lines, rectangles and ovals" );
setSize( 400, 165 );
setVisible( true );
}
// display various lines, rectangles and ovals
public void paint( Graphics g )
{
super.paint( g ); // call superclass's paint method
g.setColor( Color.RED );
g.drawLine( 5, 30, 350, 30 );
g.setColor( Color.BLUE );
g.drawRect( 5, 40, 90, 55 );
g.fillRect( 100, 40, 90, 55 );
g.setColor( Color.CYAN );
g.fillRoundRect( 195, 40, 90, 55, 50, 50 );
g.drawRoundRect( 290, 40, 90, 55, 20, 20 );
g.setColor( Color.YELLOW );
g.draw3DRect( 5, 100, 90, 55, true );
g.fill3DRect( 100, 100, 90, 55, false );
g.setColor( Color.MAGENTA );
g.drawOval( 195, 100, 90, 55 );
g.fillOval( 290, 100, 90, 55 );
} // end method paint
// execute application
public static void main( String args[] )
{
LinesRectsOvals application = new LinesRectsOvals();
application.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
}
} // end class LinesRectsOvals
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -