找回密码
 注册账号

QQ登录

只需一步,快速开始

手机号码,快捷登录

手机号码,快捷登录

初学者课程:T3自学|T6自学|U8自学软件下载课件下载工具下载资料:通资料|U8资料|NC|培训|年结积分规则 | 使用常见问题Q&A
知识库:U8 | | NC | U9 | OA | 政务U8|U9|NCC|NC65|NC65客开|NCC客开新手必读 | 任务 | 快速增金币用友QQ群[微信群]
查看: 8274|回复: 5

[经验] 制作自己的对话框!

[复制链接]
发表于 2009-10-14 11:39:58 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?注册账号

×
可以继承UIDialog类来自己“画”一个个性的对话框,具体的空间使用参照Swing的使用
一下给个例子
一 画界面
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.DefaultComboBoxModel;
import nc.ui.pub.beans.UIDialog;
public class QueryDialog extends UIDialog implements ActionListener {
        private nc.ui.pub.beans.UIButton UIButtonComm = null;//按钮
        private nc.ui.pub.beans.UIButton UIButtonCanel = null;
        private javax.swing.JPanel ivjUIDialogContentPane = null;//主pane
        private nc.ui.pub.beans.UILabel UILabel1 = null;//标签
        private nc.ui.pub.beans.UILabel UILabel2 = null;
        private nc.ui.pub.beans.UILabel UILabel3 = null;
        private nc.ui.pub.beans.UIComboBox ComboBoxto = null;//下拉
        private nc.ui.pub.beans.UITextField chooseField = null;//文本框
        private String value = null;//使用value变量来告诉外界是点击什么按钮
        @SuppressWarnings("deprecation")
        public QueryDialog() {
                super();
                initialize();
        }
       // 初始话
        private void initialize() {
                setName("QueryDialog");
                this.setTitle("查询条件");//设置标题
                setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);//关闭就退出
                setSize(330, 180);//大小
                setContentPane(getUIDialogContentPane());//主panne
                getUIButtonComm().addActionListener(this);//两个按钮添加监听
                getUIButtonCanel().addActionListener(this);//
        }
        // 按钮的初始
        private nc.ui.pub.beans.UIButton getUIButtonComm() {
                if (UIButtonComm == null) {
                        UIButtonComm = new nc.ui.pub.beans.UIButton();
                        UIButtonComm.setName("UIButtonComm");
                        UIButtonComm.setText("确定");
                        UIButtonComm.setBounds(90, 110, 55, 22);
                }
                return UIButtonComm;
        }
        // 按钮初始
        private nc.ui.pub.beans.UIButton getUIButtonCanel() {
                if (UIButtonCanel == null)
                        UIButtonCanel = new nc.ui.pub.beans.UIButton();
                UIButtonCanel.setName("UIButtonCanel");
                UIButtonCanel.setText("取消");
                UIButtonCanel.setBounds(170, 110, 55, 22);
                return UIButtonCanel;
        }

        // 增加按钮等工作,主panne的初始
        private javax.swing.JPanel getUIDialogContentPane() {
                if (ivjUIDialogContentPane == null) {
                        ivjUIDialogContentPane = new javax.swing.JPanel();
                        ivjUIDialogContentPane.setName("UIDialogContentPane"); //名称
                        ivjUIDialogContentPane.setLayout(null);//布局
                        getUIDialogContentPane().add(getUIButtonComm(),
                                        getUIButtonComm().getName()); //按钮
                        getUIDialogContentPane().add(getUIButtonCanel(),
                                        getUIButtonCanel().getName()); //按钮
                        getUIDialogContentPane()
                                        .add(getUILabel1(), getUILabel1().getName()); //
                        getUIDialogContentPane()
                                        .add(getUILabel2(), getUILabel2().getName()); //
                        getUIDialogContentPane()
                                        .add(getUILabel3(), getUILabel3().getName()); //标签
                        getUIDialogContentPane().add(getComboBoxto(),
                                        getComboBoxto().getName()); //下拉
                        getUIDialogContentPane().add(getUITextField(),
                                        getUITextField().getName()); //文本
                }
                return ivjUIDialogContentPane;
        }
        private Component getUILabel1() {//标签初始
                if (UILabel1 == null) {
                        UILabel1 = new nc.ui.pub.beans.UILabel();
                        UILabel1.setName("Label1");
                        UILabel1.setText("查询条件:");
                        UILabel1.setBounds(10, 15, 60, 20);
                }
                return UILabel1;
        }
        private Component getUILabel2() {
                if (UILabel2 == null) {
                        UILabel2 = new nc.ui.pub.beans.UILabel();
                        UILabel2.setName("Label2");
                        UILabel2.setText("从第");
                        UILabel2.setBounds(20, 55, 40, 20);
                }
                return UILabel2;
        }
        private Component getUILabel3() {
                if (UILabel3 == null) {
                        UILabel3 = new nc.ui.pub.beans.UILabel();
                        UILabel3.setName("Label3");
                        UILabel3.setText("位开始的查询值为:");
                        UILabel3.setBounds(110, 55, 100, 20);
                }
                return UILabel3;
        }
        private Component getComboBoxto() {//下拉初始
                if (ComboBoxto == null) {
                        ComboBoxto = new nc.ui.pub.beans.UIComboBox();
                        DefaultComboBoxModel invalue = new DefaultComboBoxModel(
                                        new String[] { "1", "2", "3", "4", "5", "6", "7", "8" });
                        ComboBoxto.setModel(invalue);
                        ComboBoxto.setName("ComboBoxto");
                        ComboBoxto.setBounds(60, 55, 40, 20);
                }
                return ComboBoxto;
        }
        private Component getUITextField() {//文本初始
                if (chooseField == null) {
                        chooseField = new nc.ui.pub.beans.UITextField();
                        chooseField.setName("chooseField");
                        chooseField.setBounds(220, 55, 80, 20);
                }
                return chooseField;
        }
        public void actionPerformed(ActionEvent e) {//点击按钮时调用
                if (e.getSource() == getUIButtonComm()) {
                        value = UIButtonComm.getText();
                        getPriceVo();
                        this.closeOK();
                }
                if (e.getSource() == getUIButtonCanel()) {
                        value = UIButtonCanel.getText();
                        this.closeOK();
                }
        }
        public String[] getPriceVo() {//确认是调用
                String[] values = new String[2];
                String ComboBoxt = ComboBoxto.getSelectdItemValue() == null ? ""
                                : ComboBoxto.getSelectdItemValue().toString();
                String chooseF = chooseField.getText();
                values[0] = ComboBoxt;
                values[1] = chooseF;
                return values;
        }
        public String getOkCanel() {//取消时调用
                return value;
        }
}
画出的结果如下:

二 使用对话框
一般这个对话框在点击某个按钮是弹出,所以在某个按钮处理方法里使用以下代码处理业务

QueryDialog dialog = new QueryDialog(); //new 一个
dialog.showModal(); //显示
String OkorNo=dialog.getOkCanel()==null?"":dialog.getOkCanel();//按钮点击判断
if(OkorNo.equals("")||OkorNo.equals("取消")){ //如果没有点击或点击取消则退出
        return;
}
String[] queryConditon=dialog.getPriceVo();//否者,取得参数,进行业务操作
备注:
        对对话框的初始是和Swing相同,可以参照Swing的使用来使用它
发表于 2011-12-28 17:11:56 | 显示全部楼层
回复 点赞 拍砖

使用道具 举报

发表于 2013-1-29 09:51:01 | 显示全部楼层
不错,很有帮助!!!!!
回复 点赞 拍砖

使用道具 举报

发表于 2016-2-29 15:35:45 | 显示全部楼层
学习学习。。。。。
回复 点赞 拍砖

使用道具 举报

发表于 2018-3-11 17:42:03 | 显示全部楼层
怎么在对话框上写出大文本框
回复 点赞 拍砖

使用道具 举报

您需要登录后才可以回帖 登录 | 注册账号

本版积分规则

QQ|站长微信|Archiver|手机版|小黑屋|用友之家 ( 蜀ICP备07505338号|51072502110008 )

GMT+8, 2024-5-12 02:19 , Processed in 0.025293 second(s), 12 queries , Gzip On, Redis On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表