NC对话框
来源:互联网 发布:淘宝宝贝被同行举报 编辑:程序博客网 时间:2024/05/29 07:44
//1.只有确认与取消的对话框
import nc.ui.pub.beans.MessageDialog;
//1为确认 2为取消
int a= MessageDialog.showOkCancelDlg(null, "是否确认取消", "确认取消作废");
//该方法有返回值,可以进行判断选择的是确认还是取消
//2. 需要i输入文字的对话框
package nc.ui.so.m4331.billui.action;
import java.awt.Container;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JTextField;
import nc.ui.pub.beans.UIDialog;
/**
* 自定义对话框 对话框包括一个label、一个文本框和2个按钮。
*/
public class CancelReasonDialog extends UIDialog implements ActionListener {
String reason;
public String getReason() {
return reason;
}
public void setReason(String reason) {
this.reason = reason;
}
// 是否关闭
public boolean isOK;
public boolean isOK() {
return isOK;
}
public void setOK(boolean isOK) {
this.isOK = isOK;
}
// 文本框,用于输入字符串
JTextField field;
// 按钮
JButton setButton;
JButton cancelButton;
/**
* 构造函数,参数为父窗体和对话框的标题
*/
public CancelReasonDialog(Object object,Container conter,boolean t) {
// 添加Label和输入文本框
super(conter,t);
setTitle("请填作废原因(必填)");
JPanel p1 = new JPanel();
field = new JTextField(40);
field.addActionListener(this);
p1.add(field);
getContentPane().add("Center", p1);
// 添加确定和取消按钮
JPanel p2 = new JPanel();
p2.setLayout(new FlowLayout(FlowLayout.RIGHT));
cancelButton = new JButton("取 消");
cancelButton.addActionListener(this);
setButton = new JButton("确 定");
setButton.addActionListener(this);
p2.add(setButton);
p2.add(cancelButton);
getContentPane().add("South", p2);
// 调整对话框布局大小
pack();
this.setModal(true);
registerAction();
}
/**
* 事件处理
*/
@Override
public void actionPerformed(ActionEvent event) {
Object source = event.getSource();
if ((source == setButton)) {
// 如果确定按钮被按下,则将文本矿的文本添加到父窗体的文本域中
if(field.getText()!=null&&!"".equals(field.getText())){
this.setReason(field.getText());
isOK = true;
this.dispose();
// setVisible(false);
// setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}else{
// 隐藏对话框
isOK=false;
this.dispose();
// setVisible(false);
// setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
/** 注册按钮事件 */
public void registerAction() {
this.cancelButton.addActionListener(this);
this.setButton.addActionListener(this);
this.addWindowListener(new WindowListener() {
public void windowActivated(WindowEvent e) {
}
public void windowClosed(WindowEvent e) {
}
public void windowDeactivated(WindowEvent e) {
}
public void windowDeiconified(WindowEvent e) {
}
public void windowIconified(WindowEvent e) {
}
public void windowOpened(WindowEvent e) {
}
public void windowClosing(WindowEvent e) {
isOK = false;
}
});
}
}
//调用需要输入文字的对话框
CancelReasonDialog dialog = new CancelReasonDialog(null, WorkbenchEnvironment.getInstance().getWorkbench().getParent(), false);
dialog.showModal();
if (!dialog.isOK) {
return;
}
- NC对话框
- nc
- nc
- NC
- NC
- nc
- nc
- nc
- nc使用
- NC教程
- NC语录
- nc上传
- nc命令
- NC常用命令
- nc 常用命令
- NC 介绍
- NC弹框
- tcpdump、nc
- ES6代码规范(整理)
- 重载、覆盖、隐藏的区别
- Rxjava用法
- 安装cocoapods及使用详解
- 架构设计:系统间通信(14)——RPC实例Apache Thrift 下篇(2)
- NC对话框
- 理解 R summary
- 静态内部类和非静态内部类的区别
- 解决perl: warning: Setting locale failed. perl: warning: Please check that your locale settings:
- 【奇葩问题-1】error 997:重叠I/O正在进行中(mircosoft vc++ 2008 Redisturbute x64 )
- 鸟哥的Linux私房菜学习笔记--重要的几个热键
- 史上最全的CDR快捷键大全
- 使用Eclipse上传java工程到github
- 深入学习String (一) 字符串串联