package test
import java
import java
import javax
import javax
import javax
import javax
public class TestJOptionPane implements ActionListener{
private JFrame jf = new JFrame("標准對話框測試");
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto
new TestJOptionPane()
}
public void createUI(){
JToolBar jtb = new JToolBar();
String[] s = {"錯誤"
int size = s
JButton[] button = new JButton[size];
for(int i =
button[i] = new JButton(s[i]);
button[i]
jtb
}
jf
jf
jf
jf
jf
}
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto
String s = e
if(s
JOptionPane
"錯誤提示"
}
else if(s
int result = JOptionPane
"推出前是否保存程序?");
if(result == JOptionPane
System
System
}
else if(result == JOptionPane
System
}
}
else if(s
int result = JOptionPane
if(result == JOptionPane
System
System
}
else if(result == JOptionPane
System
}
}
else if(s
Object[] options = {"繼續"
int result = JOptionPane
"本操作可能導致數據丟失"
JOptionPane
if(result ==
System
}
}
else if(s
String name = JOptionPane
if(name != null){
System
}
}
else if(s
Object[] possibleValues = {"體育"
Object selectedValue = JOptionPane
"Choose one"
possibleValues
String choose = (String)selectedValue;
if(choose != null){
System
}
}
}
}






From:http://tw.wingwit.com/Article/program/Java/JSP/201311/20143.html