?? exercise11_2.java
字號:
import javax.swing.*;import java.awt.*;public class Exercise11_2 extends JFrame { public Exercise11_2() { add(new Grid()); } /** Main method */ public static void main(String[] args) { Exercise11_2 frame = new Exercise11_2(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(100, 80); frame.setVisible(true); }}class Grid extends JPanel { protected void paintComponent(Graphics g) { super.paintComponent(g); g.setColor(Color.red); g.drawLine(getWidth() / 3, 0, getWidth() / 3, getHeight()); g.drawLine(getWidth() * 2 / 3, 0, getWidth() * 2 / 3, getHeight()); g.setColor(Color.blue); g.drawLine(0, getHeight() / 3, getWidth(), getHeight() / 3); g.drawLine(0, getHeight() * 2 / 3, getWidth(), getHeight() * 2 / 3); }}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -