?? bookquery.java
字號:
//package vivo.mediamanager;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class BookQuery extends JDialog {
public String key;
public int type;
JTextField text;
BookQuery(Frame owner,String title,boolean modal){
super(owner,title,modal);
key=null;
type=0;
setLocation(350,300);
setSize(new Dimension(540,130));
setResizable(false);
Container pane=this.getContentPane();
pane.setLayout(new FlowLayout());
JLabel label1 = new JLabel("需要查詢的關鍵字");
JLabel label2 = new JLabel("關鍵字歸屬的類型");
text = new JTextField(68);
JRadioButton button0 = new JRadioButton("名稱");
button0.setSelected(true);
button0.addActionListener
(
new ActionListener() {
public void actionPerformed(ActionEvent e) {
BookQuery.this.type=0;
}
}
);
JRadioButton button1 = new JRadioButton("作者");
button1.addActionListener
(
new ActionListener() {
public void actionPerformed(ActionEvent e) {
BookQuery.this.type=1;
}
}
);
JRadioButton button2 = new JRadioButton("編輯");
button2.addActionListener
(
new ActionListener() {
public void actionPerformed(ActionEvent e) {
BookQuery.this.type=2;
}
}
);
JRadioButton button3 = new JRadioButton("出版社");
button3.addActionListener
(
new ActionListener() {
public void actionPerformed(ActionEvent e) {
BookQuery.this.type=3;
}
}
);
JRadioButton button4 = new JRadioButton("價格");
button4.addActionListener
(
new ActionListener() {
public void actionPerformed(ActionEvent e) {
BookQuery.this.type=4;
}
}
);
JRadioButton button5 = new JRadioButton("出版日期");
button5.addActionListener
(
new ActionListener() {
public void actionPerformed(ActionEvent e) {
BookQuery.this.type=5;
}
}
);
JRadioButton button6 = new JRadioButton("ISBN");
button6.addActionListener
(
new ActionListener() {
public void actionPerformed(ActionEvent e) {
BookQuery.this.type=6;
}
}
);
JPanel radioPane = new JPanel();
radioPane.add(button0);
radioPane.add(button1);
radioPane.add(button2);
radioPane.add(button3);
radioPane.add(button4);
radioPane.add(button5);
radioPane.add(button6);
ButtonGroup group = new ButtonGroup();
group.add(button0);
group.add(button1);
group.add(button2);
group.add(button3);
group.add(button4);
group.add(button5);
group.add(button6);
JButton ok = new JButton("確定查詢(O)");
ok.setMnemonic('O');
JButton cancel = new JButton("放棄查詢(C)");
cancel.setMnemonic('C');
ok.addActionListener
(
new ActionListener() {
public void actionPerformed(ActionEvent e) {
BookQuery.this.key = BookQuery.this.text.getText();
BookQuery.this.setVisible(false);
}
}
);
cancel.addActionListener
(
new ActionListener() {
public void actionPerformed(ActionEvent e) {
BookQuery.this.setVisible(false);
}
}
);
pane.add(label1);
pane.add(text);
pane.add(label2);
pane.add(radioPane);
pane.add(ok);
pane.add(cancel);
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -