📄 logindialog.java
字号:
/* * Copyright (c) 2006 guodongping. All Rights Reserved. * * E-mail: yayajike_0305@163.com * QQ: 445938759 *///package library;import javax.swing.JFrame;import javax.swing.JPanel;import javax.swing.JButton;import javax.swing.JPasswordField;import java.awt.GridLayout;import javax.swing.JTextField;import javax.swing.JLabel;//import javax.swing.JOptionPane;import java.awt.BorderLayout;import java.awt.event.ActionListener;import java.awt.event.ActionEvent;/*** This code was 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.* **************************************//** * @author guodongping * 创建日期 2006-1-13 * 登录界面 */public class LogInDialog extends javax.swing.JDialog { private JPanel jPanel1; private JButton cancelButton; private JButton okButton; private JPanel jPanel4; private JPasswordField passwordText; private JLabel jLabel2; private JPanel jPanel3; private JTextField userText; private JLabel jLabel1; private JPanel jPanel2; /** * Auto-generated main method to display this JDialog public static void main(String[] args) { JFrame frame = new JFrame(); LogInDialog inst = new LogInDialog(frame); inst.setVisible(true); }*/ public LogInDialog(JFrame frame) { super(frame,"登录"); initGUI(); } private void initGUI() { try { setSize(220, 200); setLocation(300,300); { jPanel1 = new JPanel(); GridLayout jPanel1Layout = new GridLayout(3, 1); jPanel1Layout.setRows(3); this.getContentPane().add(jPanel1, BorderLayout.CENTER); jPanel1.setLayout(jPanel1Layout); { jPanel2 = new JPanel(); jPanel1.add(jPanel2); { jLabel1 = new JLabel(); jPanel2.add(jLabel1); jLabel1.setText("用户:"); } { userText = new JTextField(10); jPanel2.add(userText); userText.setText("admin"); } } { jPanel3 = new JPanel(); jPanel1.add(jPanel3); { jLabel2 = new JLabel(); jPanel3.add(jLabel2); jLabel2.setText("密码:"); } { passwordText = new JPasswordField(10); jPanel3.add(passwordText); passwordText.setText("admin"); } } { jPanel4 = new JPanel(); jPanel1.add(jPanel4); { okButton = new JButton(); jPanel4.add(okButton); okButton.setText("确定"); } { cancelButton = new JButton(); jPanel4.add(cancelButton); cancelButton.setText("取消"); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { cancelPressed(); } }); } } } } catch (Exception e) { e.printStackTrace(); } } void cancelPressed(){ this.setVisible( false ); } JButton getOK(){ return okButton; } String getUser(){ return userText.getText().trim(); } String getPass( ){ return passwordText.getText().trim(); } /** * Auto-generated method for setting the popup menu for a component */ private void setComponentPopupMenu( final java.awt.Component parent, final javax.swing.JPopupMenu menu) { parent.addMouseListener(new java.awt.event.MouseAdapter() { public void mousePressed(java.awt.event.MouseEvent e) { if (e.isPopupTrigger()) menu.show(parent, e.getX(), e.getY()); } public void mouseReleased(java.awt.event.MouseEvent e) { if (e.isPopupTrigger()) menu.show(parent, e.getX(), e.getY()); } }); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -