求java编写的登陆界面代码
发布网友
发布时间:2022-06-03 05:49
我来回答
共3个回答
热心网友
时间:2023-10-12 18:23
import javax.swing.JFrame;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Rectangle;
import java.awt.GridBagLayout;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JButton;
public class LoginFrame {
private JFrame jFrame = null; // @jve:decl-index=0:visual-constraint="293,25"
private JPanel jContentPane = null;
private JPanel jPanel = null;
private JLabel jLabel = null;
private JLabel jLabel1 = null;
private JTextField jTextField = null;
private JTextField jTextField1 = null;
private JButton jButton = null;
/**
* This method initializes jFrame
*
* @return javax.swing.JFrame
*/
private JFrame getJFrame() {
if (jFrame == null) {
jFrame = new JFrame();
jFrame.setSize(new Dimension(330, 222));
jFrame.setTitle("登陆");
jFrame.setContentPane(getJContentPane());
}
return jFrame;
}
/**
* This method initializes jContentPane
*
* @return javax.swing.JPanel
*/
private JPanel getJContentPane() {
if (jContentPane == null) {
jContentPane = new JPanel();
jContentPane.setLayout(null);
jContentPane.add(getJPanel(), null);
}
return jContentPane;
}
/**
* This method initializes jPanel
*
* @return javax.swing.JPanel
*/
private JPanel getJPanel() {
if (jPanel == null) {
jLabel1 = new JLabel();
jLabel1.setBounds(new Rectangle(45, 76, 54, 22));
jLabel1.setText("密 码:");
jLabel = new JLabel();
jLabel.setBounds(new Rectangle(47, 39, 53, 25));
jLabel.setText("用户名:");
jPanel = new JPanel();
jPanel.setLayout(null);
jPanel.setBounds(new Rectangle(2, 7, 305, 167));
jPanel.add(jLabel, null);
jPanel.add(jLabel1, null);
jPanel.add(getJTextField(), null);
jPanel.add(getJTextField1(), null);
jPanel.add(getJButton(), null);
}
return jPanel;
}
/**
* This method initializes jTextField
*
* @return javax.swing.JTextField
*/
private JTextField getJTextField() {
if (jTextField == null) {
jTextField = new JTextField();
jTextField.setBounds(new Rectangle(106, 40, 154, 24));
}
return jTextField;
}
/**
* This method initializes jTextField1
*
* @return javax.swing.JTextField
*/
private JTextField getJTextField1() {
if (jTextField1 == null) {
jTextField1 = new JTextField();
jTextField1.setBounds(new Rectangle(105, 76, 154, 23));
}
return jTextField1;
}
/**
* This method initializes jButton
*
* @return javax.swing.JButton
*/
private JButton getJButton() {
if (jButton == null) {
jButton = new JButton();
jButton.setBounds(new Rectangle(187, 103, 66, 25));
jButton.setText("登陆");
}
return jButton;
}
}
热心网友
时间:2023-10-12 18:23
我觉得你自己写会更快。
public class Login extends JFrame{
public static void main(String[] args){
JFrame f = new Login();
f.add(new JTextField());
f.add(new JTextField());
f.add(new JButton("登录"));
f.add(new JButton("清空"));
f.setSize(400,400);
f.setLocation(250,250);
f.setVisible(true);
}
}
热心网友
时间:2023-10-12 18:24
package org.jbit.;
import java.util.List;
import org.jbit.bean.Person;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
public class PersonDao extends HibernateDaoSupport implements IPersonDao {
//登录
public Object personLogin(Object example) {
List<Person> list = null;
try {
list = this.getHibernateTemplate().findByExample(example);
} catch (Exception e) {
e.printStackTrace();
}
if(list!=null && list.size()>0){
return list.get(0);
}
return null;
}
//增删改
public boolean modifyObject(Object obj,String type) {
boolean flag = true;
try {
if("delete".equals(type)){
this.getHibernateTemplate().delete(obj);
}else {
this.getHibernateTemplate().saveOrUpdate(obj);
}
} catch (Exception e) {
e.printStackTrace();
flag = false;
}
return flag;
}
}