?? exercise11_3.java
字號:
import javax.swing.*;
import java.awt.*;
public class Exercise11_3 extends JFrame {
// Create two buttons
private OvalButton jbtOk = new OvalButton("OK");
private OvalButton jbtCancel = new OvalButton("Cancel");
/** Default constructor */
public Exercise11_3() {
// Set the window title
setTitle("Exercise11_3");
// Set FlowLayout manager to arrange the components
// inside the frame
getContentPane().setLayout(new FlowLayout());
// Add buttons to the frame
getContentPane().add(jbtOk);
getContentPane().add(jbtCancel);
}
/** Main method */
public static void main(String[] args) {
Exercise11_3 frame = new Exercise11_3();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(100, 80);
frame.setVisible(true);
}
}
class OvalButton extends JButton {
public OvalButton() {
}
public OvalButton(String text) {
super(text);
}
protected void paintComponent(Graphics g) {
// Draw an oval
super.paintComponent(g);
g.drawOval(5, 5, getWidth() - 10, getHeight() - 10);
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -