close
參考答案:
import javax.swing.*; public class JDD01 { public static void main(String args[]) { new MyApp(); } } class MyApp { MyApp() { Object[] options = {"500*500","300*300","100*100"}; int n = JOptionPane.showOptionDialog(null, "What size window do you prefer?", "Window Size", 0, JOptionPane.QUESTION_MESSAGE, null, options, options[2]); JFrame f = new JFrame(); if(n==0) f.setSize(500, 500); else if(n==1) f.setSize(300, 300); else f.setSize(100, 100); f.setLocationRelativeTo(null); f.setVisible(true); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } }
執行結果:
全站熱搜
留言列表