⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 newokcanceldialog.java

📁 能简单的实现商品的查询
💻 JAVA
字号:
/* * NewOkCancelDialog.java * * Created on 2008年1月4日, 下午12:52 *///package shop;/** * * @author  ldwin */public class NewOkCancelDialog extends javax.swing.JDialog {    /** A return status code - returned if Cancel button has been pressed */    public static final int RET_CANCEL = 0;    /** A return status code - returned if OK button has been pressed */    public static final int RET_OK = 1;        /** Creates new form NewOkCancelDialog */    public NewOkCancelDialog(java.awt.Frame parent, boolean modal) {        super(parent, modal);        initComponents();    }        /** @return the return status of this dialog - one of RET_OK or RET_CANCEL */    public int getReturnStatus() {        return returnStatus;    }        /** This method is called from within the constructor to     * initialize the form.     * WARNING: Do NOT modify this code. The content of this method is     * always regenerated by the Form Editor.     */    // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents    private void initComponents() {        okButton = new javax.swing.JButton();        cancelButton = new javax.swing.JButton();        jLabel1 = new javax.swing.JLabel();        addWindowListener(new java.awt.event.WindowAdapter() {            public void windowClosing(java.awt.event.WindowEvent evt) {                closeDialog(evt);            }        });        okButton.setText("OK");        okButton.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                okButtonActionPerformed(evt);            }        });        cancelButton.setText("Cancel");        cancelButton.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                cancelButtonActionPerformed(evt);            }        });        jLabel1.setText("\u7528\u6237\u540d\u6216\u5bc6\u7801\u9519\u8bef");        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());        getContentPane().setLayout(layout);        layout.setHorizontalGroup(            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)            .addGroup(layout.createSequentialGroup()                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)                    .addGroup(layout.createSequentialGroup()                        .addContainerGap()                        .addComponent(okButton, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE)                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 246, Short.MAX_VALUE)                        .addComponent(cancelButton))                    .addGroup(layout.createSequentialGroup()                        .addGap(154, 154, 154)                        .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 114, javax.swing.GroupLayout.PREFERRED_SIZE)))                .addContainerGap())        );        layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {cancelButton, okButton});        layout.setVerticalGroup(            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()                .addContainerGap()                .addComponent(jLabel1)                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 41, Short.MAX_VALUE)                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)                    .addComponent(cancelButton)                    .addComponent(okButton))                .addContainerGap())        );        pack();    }// </editor-fold>//GEN-END:initComponents        private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed        doClose(RET_OK);    }//GEN-LAST:event_okButtonActionPerformed        private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonActionPerformed        doClose(RET_CANCEL);    }//GEN-LAST:event_cancelButtonActionPerformed        /** Closes the dialog */    private void closeDialog(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_closeDialog        doClose(RET_CANCEL);    }//GEN-LAST:event_closeDialog        private void doClose(int retStatus) {        returnStatus = retStatus;        setVisible(false);        dispose();    }        /**     * @param args the command line arguments     */    public static void main(String args[]) {        java.awt.EventQueue.invokeLater(new Runnable() {            public void run() {                NewOkCancelDialog dialog = new NewOkCancelDialog(new javax.swing.JFrame(), true);                dialog.addWindowListener(new java.awt.event.WindowAdapter() {                    public void windowClosing(java.awt.event.WindowEvent e) {                        System.exit(0);                    }                });                dialog.setVisible(true);            }        });    }        // Variables declaration - do not modify//GEN-BEGIN:variables    private javax.swing.JButton cancelButton;    private javax.swing.JLabel jLabel1;    private javax.swing.JButton okButton;    // End of variables declaration//GEN-END:variables        private int returnStatus = RET_CANCEL;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -