📄 jframe1.java
字号:
/* * JFrame.java * * Created on 2001年5月1日, 上午9:20 */package zc;/** * * @author Administrator * @version */public class JFrame1 extends javax.swing.JFrame { /** Creates new form JFrame */ public JFrame1() { initComponents (); pack (); } /** 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 FormEditor. */ private void initComponents() {//GEN-BEGIN:initComponents label1 = new java.awt.Label(); jButton1 = new javax.swing.JButton(); jButton2 = new javax.swing.JButton(); jButton3 = new javax.swing.JButton(); getContentPane().setLayout(new java.awt.GridBagLayout()); java.awt.GridBagConstraints gridBagConstraints1; setTitle("\u4e3b\u754c\u9762"); setBackground(java.awt.Color.lightGray); addKeyListener(new java.awt.event.KeyAdapter() { public void keyPressed(java.awt.event.KeyEvent evt) { formKeyPressed(evt); } } ); addWindowListener(new java.awt.event.WindowAdapter() { public void windowClosing(java.awt.event.WindowEvent evt) { exitForm(evt); } } ); label1.setFont(new java.awt.Font ("Dialog", 0, 14)); label1.setBackground(new java.awt.Color (204, 204, 204)); label1.setForeground(java.awt.Color.black); label1.setText("\u540e\u52e4\u7ba1\u7406\u7cfb\u7edf"); label1.setAlignment(java.awt.Label.CENTER); gridBagConstraints1 = new java.awt.GridBagConstraints(); gridBagConstraints1.gridx = 1; gridBagConstraints1.gridy = 1; gridBagConstraints1.gridwidth = 4; gridBagConstraints1.insets = new java.awt.Insets(7, 4, 32, 4); gridBagConstraints1.anchor = java.awt.GridBagConstraints.EAST; getContentPane().add(label1, gridBagConstraints1); jButton1.setActionCommand("JFrame2"); jButton1.setText("\u7ba1\u7406\u5458\u8fdb\u5165\u7cfb\u7edf"); jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt); } } ); jButton1.addKeyListener(new java.awt.event.KeyAdapter() { public void keyPressed(java.awt.event.KeyEvent evt) { jButton1KeyPressed(evt); } } ); gridBagConstraints1 = new java.awt.GridBagConstraints(); gridBagConstraints1.gridx = 0; gridBagConstraints1.gridy = 4; getContentPane().add(jButton1, gridBagConstraints1); jButton2.setText("\u666e\u901a\u7528\u6237\u8fdb\u5165\u7cfb\u7edf"); jButton2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton2ActionPerformed(evt); } } ); gridBagConstraints1 = new java.awt.GridBagConstraints(); gridBagConstraints1.gridx = 6; gridBagConstraints1.gridy = 4; getContentPane().add(jButton2, gridBagConstraints1); jButton3.setLayout(jButton3.getLayout()); jButton3.setText("\u9000\u51fa\u7cfb\u7edf"); jButton3.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton3ActionPerformed(evt); } } ); gridBagConstraints1 = new java.awt.GridBagConstraints(); gridBagConstraints1.gridx = 3; gridBagConstraints1.gridy = 9; gridBagConstraints1.gridwidth = 2; gridBagConstraints1.fill = java.awt.GridBagConstraints.VERTICAL; gridBagConstraints1.ipady = 4; gridBagConstraints1.insets = new java.awt.Insets(1, 9, 2, 6); getContentPane().add(jButton3, gridBagConstraints1); }//GEN-END:initComponents private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed zc.face.userInterface2 jf3=new zc.face.userInterface2(); jf3.setVisible(true); setVisible(false); // Add your handling code here: }//GEN-LAST:event_jButton2ActionPerformed private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed javax.swing.JFrame f=new javax.swing.JFrame("ConfirmDialog"); int returnValue=javax.swing.JOptionPane.CANCEL_OPTION; returnValue=javax.swing.JOptionPane.showConfirmDialog(f,"Are you sure to quit?","ask",javax.swing.JOptionPane.OK_CANCEL_OPTION); if(returnValue==javax.swing.JOptionPane.OK_OPTION){ System.exit(0); } else f.setDefaultCloseOperation(javax.swing.JFrame.EXIT_ON_CLOSE); }//GEN-LAST:event_jButton3ActionPerformed private void formKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_formKeyPressed // jButton1.setAction(this); }//GEN-LAST:event_formKeyPressed private void jButton1KeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jButton1KeyPressed setContentPane(this); }//GEN-LAST:event_jButton1KeyPressed private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed zc.JFrame2 jf2=new zc.JFrame2(); jf2.setVisible(true); setVisible(false); // Add your handling code here: }//GEN-LAST:event_jButton1ActionPerformed /** Exit the Application */ private void exitForm(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_exitForm System.exit (0); }//GEN-LAST:event_exitForm /** * @param args the command line arguments */ public static void main (String args[]) { JFrame1 jf1=new JFrame1(); jf1.setVisible(true); //new JFrame1().setVisible(true); } // Variables declaration - do not modify//GEN-BEGIN:variables private java.awt.Label label1; private javax.swing.JButton jButton1; private javax.swing.JButton jButton2; private javax.swing.JButton jButton3; // End of variables declaration//GEN-END:variables }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -