?? test.java
字號:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Test extends JApplet {
private JComboBox comboBox = new JComboBox();
public void init() {
Container contentPane = getContentPane();
comboBox.addItem("Top");
comboBox.addItem("Center");
comboBox.addItem("Bottom");
contentPane.setLayout(new FlowLayout());
contentPane.add(comboBox);
comboBox.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent event) {
int state = event.getStateChange();
String item = (String)event.getItem(), s;
if(event.getStateChange() == ItemEvent.SELECTED)
s = " selected";
else
s = " deselected";
JOptionPane.showMessageDialog(
comboBox, // parent component
item + s, // message
"JComboBox Selection", // title
JOptionPane.INFORMATION_MESSAGE); // type
}
});
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -