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

📄 jbutton.java

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

package jbutton;
import java.awt.*;
import javax.swing.JButton;
        
/**
 *
 * @author  Administrator
 */
public class jbutton extends javax.swing.JFrame {
    //private JButton jButtonEnter;
    /** Creates new form jbutton */
    public jbutton() {
        initComponents();
        
        //jButtonEnter.setBounds(80,90,60,20);
    }
    
    /** 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() {
        jButtonEnter = new javax.swing.JButton();
        jButtonCancel = new javax.swing.JButton();
        jLabelMessage = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        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 mouseClicked(java.awt.event.MouseEvent evt) {
                jButtonEnterMouseClicked(evt);
            }
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                jButtonEnterMouseReleased(evt);
            }
        });

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

        jLabelMessage.setText("\u4f60\u8fd8\u6ca1\u6709\u6309\u4e0b\u6309\u94ae");

        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(78, 78, 78)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, jLabelMessage, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .add(layout.createSequentialGroup()
                        .add(jButtonEnter)
                        .add(80, 80, 80)
                        .add(jButtonCancel)))
                .addContainerGap(128, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
                .add(78, 78, 78)
                .add(jLabelMessage, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 34, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 72, Short.MAX_VALUE)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jButtonEnter)
                    .add(jButtonCancel))
                .add(138, 138, 138))
        );
        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButtonEnterMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButtonEnterMouseReleased
// TODO 将在此处添加您的处理代码:
      this.jLabelMessage.setText("好啊!");
    }//GEN-LAST:event_jButtonEnterMouseReleased

    private void jButtonCancelMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButtonCancelMouseClicked
// TODO 将在此处添加您的处理代码:
        this.jLabelMessage.setText("你单击了取消按钮!");
    }//GEN-LAST:event_jButtonCancelMouseClicked

    private void jButtonEnterMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButtonEnterMouseClicked
// TODO 将在此处添加您的处理代码:
       // this.jLabelMessage.setText("你单击了确定按钮!");
    }//GEN-LAST:event_jButtonEnterMouseClicked

    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 jbutton().setVisible(true);
            }
        });
   JButton myJButton=new JButton("确定");
    }
    
    // 变量声明 - 不进行修改//GEN-BEGIN:variables
    private javax.swing.JButton jButtonCancel;
    private javax.swing.JButton jButtonEnter;
    private javax.swing.JLabel jLabelMessage;
    // 变量声明结束//GEN-END:variables
    
}

⌨️ 快捷键说明

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