SmOptionPane 是提示信息对话框。其接口说明可参见 SmOptionPane 接口说明文档。
示范代码
SmOptionPane 控件使用的示例代码如下:
private void initComponents() {
this.button1 = new JButton("提示信息框1");
this.button2 = new JButton("提示信息框2");
this.button3 = new JButton("提示信息框3");
this.button4 = new JButton("提示信息框4");
}
private void initListeners() {
this.button1.addActionListener(new ActionListener() {
@Override
//显示默认提示框
public void actionPerformed(ActionEvent e) {
UICommonToolkit.showConfirmDialog("提示信息","提示标题");
}
});
this.button2.addActionListener(new ActionListener() {
@Override
//显示带有是、否、取消按钮的提示框
public void actionPerformed(ActionEvent e) {
UICommonToolkit.showConfirmDialogWithCancel("是否保存");
}
});
this.button3.addActionListener(new ActionListener() {
@Override
//显示只有是、否按钮的提示框
public void actionPerformed(ActionEvent e) {
UICommonToolkit.showConfirmDialogYesNo("是否保存");
}
});
this.button4.addActionListener(new ActionListener() {
@Override
//显示错误信息提示框
public void actionPerformed(ActionEvent e) {
UICommonToolkit.showErrorMessageDialog("错误提示");
}
});
}
private void initLayouts() {
this.setLayout(new FlowLayout());
this.add(this.button1);
this.add(this.button2);
this.add(this.button3);
this.add(this.button4);
}
SmOptionPane 控件显示效果如下: