📄 myframe.java
字号:
package com.tw.net;import java.awt.event.ActionEvent;import javax.swing.AbstractAction;import javax.swing.JButton;import javax.swing.JLabel;import javax.swing.JOptionPane;import javax.swing.JTextField;import javax.swing.WindowConstants;import javax.swing.SwingUtilities;import com.tw.net.service.IUer;import com.tw.net.service.UserManager;/*** This code was edited or generated using CloudGarden's Jigloo* SWT/Swing GUI Builder, which is free for non-commercial* use. If Jigloo is being used commercially (ie, by a corporation,* company or business for any purpose whatever) then you* should purchase a license for each developer using Jigloo.* Please visit www.cloudgarden.com for details.* Use of Jigloo implies acceptance of these licensing terms.* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.*/public class MyFrame extends javax.swing.JFrame { private JButton jButton1; private JTextField idT; private JLabel jLabel2; private AbstractAction loginAction; private JTextField pwT; private JLabel jLabel1; IUer iusr= new UserManager(); /** * Auto-generated main method to display this JFrame */ public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { public void run() { MyFrame inst = new MyFrame(); inst.setLocationRelativeTo(null); inst.setVisible(true); } }); } public MyFrame() { super(); initGUI(); } private void initGUI() { try { setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); getContentPane().setLayout(null); { jButton1 = new JButton(); getContentPane().add(jButton1); jButton1.setText("jButton1"); jButton1.setBounds(103, 173, 62, 22); jButton1.setAction(getLoginAction()); } { idT = new JTextField(); getContentPane().add(idT); idT.setBounds(126, 34, 89, 22); } { jLabel1 = new JLabel(); getContentPane().add(jLabel1); jLabel1.setText("ID:"); jLabel1.setBounds(56, 38, 18, 15); } { jLabel2 = new JLabel(); getContentPane().add(jLabel2); jLabel2.setText("PW:"); jLabel2.setBounds(56, 98, 18, 15); } { pwT = new JTextField(); getContentPane().add(pwT); pwT.setBounds(126, 94, 89, 22); } pack(); setSize(400, 300); } catch (Exception e) { e.printStackTrace(); } } private AbstractAction getLoginAction() { if(loginAction == null) { loginAction = new AbstractAction("\u767b\u9646", null) { public void actionPerformed(ActionEvent evt) { executeLogin(evt); } }; } return loginAction; } private void executeLogin(ActionEvent evt){ String id = this.idT.getText(); String pw = this.pwT.getText(); boolean loginResult = iusr.login(Integer.parseInt(id), pw); if(loginResult){ JOptionPane.showMessageDialog(this, "login success"); } else JOptionPane.showMessageDialog(this, "id or pw is error"); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -