关闭

JOptionPane_构造函数和变量

310人阅读 评论(1) 收藏 举报
class OptionDialogFrame extends JFrame {
 public OptionDialogFrame() {
  this.setTitle("OptionDialog Test");
  this.setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT);
  
  JPanel gridPanel = new JPanel();
  gridPanel.setLayout(new GridLayout(2, 3));//2行3列
  
  typePanel = new ButtonPanel("Type", "Message", "Confirm", "Option", "Input");
  messageTypePanel = new ButtonPanel("Message Type", "ERROR_MESSAGE", "INFORMATION_MESSAGE",
    "WARNING_MESSAGE", "QUESTION_MESSAGE", "PLAIN_MESSAGE");
  messagePanel = new ButtonPanel("Message", "String", "Icon", "Component", "Other", "Object[]");
  optionTypePanel = new ButtonPanel("Confirm", "DEFAULT_OPTION", "YES_NO_OPTION",
    "YES_NO_CANCEL_OPTION", "OK_CANCEL_OPTION");
  optionsPanel = new ButtonPanel("Option", "String[]", "Icon[]", "Object[]");
  inputPanel = new ButtonPanel("Input", "Text field", "Combo box");
  
  gridPanel.add(typePanel);
  gridPanel.add(messageTypePanel);
  gridPanel.add(messagePanel);
  gridPanel.add(optionTypePanel);
  gridPanel.add(optionsPanel);
  gridPanel.add(inputPanel);
  
  JPanel showPanel = new JPanel();
  JButton showButton = new JButton("Show");
  showButton.addActionListener(new ShowAction());
  showPanel.add(showButton);
  
  this.add(gridPanel, BorderLayout.CENTER);
  this.add(showPanel, BorderLayout.SOUTH);
 }
 
 public static final int DEFAULT_WIDTH = 600;
 public static final int DEFAULT_HEIGHT = 400;
 
 private ButtonPanel typePanel;
 private ButtonPanel messagePanel;
 private ButtonPanel messageTypePanel;
 private ButtonPanel optionTypePanel;
 private ButtonPanel optionsPanel;
 private ButtonPanel inputPanel;
 
 private String messageString = "Message";
 private Icon messageIcon = new ImageIcon("c:/picture/1.gif");
 private Object messageObject = new Date();
 private Component messageComponent = new SampleComponent();
}
0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:103822次
    • 积分:1770
    • 等级:
    • 排名:千里之外
    • 原创:85篇
    • 转载:0篇
    • 译文:0篇
    • 评论:37条
    文章分类
    最新评论