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

📄 demojdialog.java

📁 基于netbeans的java桌面应用程序合集
💻 JAVA
字号:
/*
 * DemoJDialog.java
 *
 * Created on 2007年8月2日, 下午12:10
 */

package org.Adam;
import java.awt.Rectangle;
import java.lang.String;
/**
 *
 * @author  Administrator
 */
public class DemoJDialog extends javax.swing.JDialog {
    
    /** Creates new form DemoJDialog */
    public DemoJDialog(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
    }
    
    /** 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=" 生成的代码 ">//GEN-BEGIN:initComponents
    private void initComponents() {
        jLabelMessage = new javax.swing.JLabel();
        jButtonEnter = new javax.swing.JButton();
        jButtonCancel = new javax.swing.JButton();
        jButton1 = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("JDialog\u5e94\u7528\u793a\u4f8b");
        setAlwaysOnTop(true);
        setModal(true);
        jLabelMessage.setText("\u8fd9\u662f\u4e00\u4e2a\u5bf9\u8bdd\u6846");

        jButtonEnter.setText("\u786e\u5b9a");
        jButtonEnter.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonEnterActionPerformed(evt);
            }
        });
        jButtonEnter.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                jButtonEnterMouseEntered(evt);
            }
        });

        jButtonCancel.setText("\u53d6\u6d88");
        jButtonCancel.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonCancelActionPerformed(evt);
            }
        });

        jButton1.setText("jButton1");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .add(118, 118, 118)
                .add(jLabelMessage, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 158, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(124, Short.MAX_VALUE))
            .add(layout.createSequentialGroup()
                .add(93, 93, 93)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(layout.createSequentialGroup()
                        .add(jButton1)
                        .addContainerGap())
                    .add(layout.createSequentialGroup()
                        .add(jButtonEnter)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 103, Short.MAX_VALUE)
                        .add(jButtonCancel)
                        .add(90, 90, 90))))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .add(50, 50, 50)
                .add(jLabelMessage, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 33, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 119, Short.MAX_VALUE)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jButtonEnter)
                    .add(jButtonCancel))
                .add(34, 34, 34)
                .add(jButton1)
                .add(50, 50, 50))
        );
        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
// TODO 将在此处添加您的处理代码:
      
        if(a==false){
            jButtonCancel.setVisible(true);
        }
    }//GEN-LAST:event_jButton1ActionPerformed

    private void jButtonEnterMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButtonEnterMouseEntered
// TODO 将在此处添加您的处理代码:
        jButtonCancel.setVisible(false);
       // String a=(String)this.jButtonCancel.getVisibleRect();
    }//GEN-LAST:event_jButtonEnterMouseEntered

    private void jButtonCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonCancelActionPerformed
// TODO 将在此处添加您的处理代码:
        this.jLabelMessage.setText("一边呆着去!");
    }//GEN-LAST:event_jButtonCancelActionPerformed

    private void jButtonEnterActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonEnterActionPerformed
// TODO 将在此处添加您的处理代码:
        this.jLabelMessage.setText("是的,这是一个对话框!");
    }//GEN-LAST:event_jButtonEnterActionPerformed
    
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new DemoJDialog(new javax.swing.JFrame(), true).setVisible(true);
            }
        });
    }
    
    // 变量声明 - 不进行修改//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButtonCancel;
    private javax.swing.JButton jButtonEnter;
    private javax.swing.JLabel jLabelMessage;
    // 变量声明结束//GEN-END:variables

    private boolean a;
    
}
//boolean a=new boolean();

⌨️ 快捷键说明

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