Java Code Examples for javax.swing.JPasswordField#setBounds()

The following examples show how to use javax.swing.JPasswordField#setBounds() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LoginFrame.java    From myqq with MIT License 4 votes vote down vote up
/**
 * Create the frame.
 */
public LoginFrame()
{
	setTitle("QQ2013");
	setIconImage(Toolkit.getDefaultToolkit().getImage(LoginFrame.class.getResource("/client/img/QQ_64.png")));
	setUndecorated(true);//设置窗体没有边框
	setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	setBounds(100, 100, 354, 272);
	
	contentPane = new MyPanel("../img/QQ2011_Login.png");
	contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
	setContentPane(contentPane);
	contentPane.setLayout(null);
	
	pwd密码 = new JPasswordField();
	pwd密码.setText("123");
	pwd密码.setEchoChar('●');
	pwd密码.setBounds(104, 163, 154, 26);
	contentPane.add(pwd密码);
	
	lblQQ2013 = new JLabel("QQ2013");
	lblQQ2013.setForeground(new Color(0, 0, 51));
	lblQQ2013.setFont(new Font("宋体", Font.BOLD, 16));
	lblQQ2013.setBounds(14, 6, 55, 18);
	contentPane.add(lblQQ2013);
	
	lbl头像 = new JLabel("");
	lbl头像.setIcon(new ImageIcon(LoginFrame.class.getResource("/client/img/headImage/head_boy_01_64.jpg")));
	lbl头像.setBounds(18, 127, 64, 64);
	contentPane.add(lbl头像);
	
	checkBox记住密码 = new JCheckBox("\u8BB0\u4F4F\u5BC6\u7801");
	checkBox记住密码.setBounds(156, 198, 76, 18);
	contentPane.add(checkBox记住密码);
	
	checkBox自动登录 = new JCheckBox("\u81EA\u52A8\u767B\u5F55");
	checkBox自动登录.setBounds(237, 198, 76, 18);
	contentPane.add(checkBox自动登录);
	
	lbl登录 = new JLabel("");
	lbl登录.setIcon(new ImageIcon(LoginFrame.class.getResource("/client/img/button/button_login_1.png")));
	lbl登录.setBounds(262, 237, 69, 22);
	contentPane.add(lbl登录);
	
	textField用户名 = new JTextField();
	textField用户名.setText("\u9A6C\u5316\u817E");
	textField用户名.setBounds(104, 128, 154, 26);
	contentPane.add(textField用户名);
	textField用户名.setColumns(10);
	
	lbl注册账号 = new JLabel("\u6CE8\u518C\u8D26\u53F7");
	lbl注册账号.setFont(new Font("SansSerif", Font.PLAIN, 13));
	lbl注册账号.setForeground(new Color(0, 51, 255));
	lbl注册账号.setBounds(288, 132, 55, 18);
	contentPane.add(lbl注册账号);
	
	lbl忘记密码 = new JLabel("\u5FD8\u8BB0\u5BC6\u7801");
	lbl忘记密码.setFont(new Font("SansSerif", Font.PLAIN, 13));
	lbl忘记密码.setForeground(new Color(0, 51, 255));
	lbl忘记密码.setBounds(288, 167, 55, 18);
	contentPane.add(lbl忘记密码);
	
	lbl最小化 = new JLabel("");
	lbl最小化.setIcon(new ImageIcon(LoginFrame.class.getResource("/client/img/button/login_minsize_1.png")));
	lbl最小化.setBounds(284, 0, 29, 19);
	contentPane.add(lbl最小化);
	
	lbl退出 = new JLabel("");
	lbl退出.setIcon(new ImageIcon(LoginFrame.class.getResource("/client/img/button/login_exit_1.png")));
	lbl退出.setBounds(312, -1, 37, 20);
	contentPane.add(lbl退出);
	
	lbl多账号 = new JLabel("");
	lbl多账号.setIcon(new ImageIcon(LoginFrame.class.getResource("/client/img/button/login_duozhanghao_1.png")));
	lbl多账号.setBounds(14, 237, 69, 21);
	contentPane.add(lbl多账号);
	
	lbl设置 = new JLabel("");
	lbl设置.setIcon(new ImageIcon(LoginFrame.class.getResource("/client/img/button/login_setting_1.png")));
	lbl设置.setBounds(93, 237, 69, 21);
	contentPane.add(lbl设置);
	
	comboBox状态 = new JComboBox();
	comboBox状态.setBounds(104, 195, 40, 24);
	contentPane.add(comboBox状态);
}
 
Example 2
Source File: StudentSystemLoginFrame.java    From StudentSystem with Apache License 2.0 4 votes vote down vote up
public StudentSystemLoginFrame(){
	super("ѧ���ɼ�����ϵͳ��¼����");
	this.jf = this;
	this.setLayout(null);//����Ϊ�ղ��֡�
	this.setSize(400,300);//���ô�С��
	Container c = this.getContentPane();
	c.setBackground(Color.WHITE);//���ñ�����ɫ��
	username_Label = new JLabel("�û���:");	//����"�û���"��ǩ��
	username_Label.setBounds(100, 60, 50, 20);	//����"�û���"��ǩλ�á�
	c.add(username_Label);	//���"�û���"��ǩ��
	
	username_Text = new JTextField();	//����"�û���"�ı���
	username_Text.setBounds(160, 60, 120, 20);	//����"�û���"�ı���λ�á�
	username_Text.grabFocus();//��ù�ꡣ
	c.add(username_Text);	//���"�û���"�ı���
	
	password_Label = new JLabel("����:");	//����"����"��ǩ��
	password_Label.setBounds(100, 140, 50, 20);
	c.add(password_Label);	//���"����"��ǩ��
	
	password_Text = new JPasswordField();	//����"����"�ı���
	password_Text.setBounds(160, 140, 120, 20);	//����"����"�ı���λ�á�
	c.add(password_Text);	//���"����"�ı���
	 
	login_Button = new JButton("��¼");	//����"��¼"��ť��
	login_Button.setBounds(100, 210, 60, 20);	//����"��¼"��ťλ�á�
	//ע��"��¼"��ť�¼�������
	login_Button.addActionListener(new ActionListener() {
		
		@Override
		public void actionPerformed(ActionEvent arg0) {
			String username = username_Text.getText().trim();
			String password = new String(password_Text.getPassword());
			if(username.equals("")){
				JOptionPane.showMessageDialog(jf, "�û�������Ϊ��","",JOptionPane.WARNING_MESSAGE);
				return ;
			}
			if(password.equals("")){
				JOptionPane.showMessageDialog(jf, "���벻��Ϊ��","",JOptionPane.WARNING_MESSAGE);
				return ;
			}
			//��¼ҵ����
			User user = new User();//�����û�����
			user.setUsername(username);
			user.setPassword(password);
			ManageHelper helper = new ManageHelper();//�������ݿ�ҵ�������
			if(helper.Login(user)){	//��½ҵ����
				if(helper.Check_IsLogin(user)){
					JOptionPane.showMessageDialog(jf, "�ظ���½��","",JOptionPane.WARNING_MESSAGE);
					return ;
				}else{
					JOptionPane.showMessageDialog(jf, "��½�ɹ���");
					jf.dispose();//�رյ�ǰ���ڡ�
					//�޸ĵ�½���
					user.setIsLogin(1);//�޸ij�Ϊ�Ѿ���½��
					helper.Update_IsLogin(user);
					//��������
					user.setPassword("");//��������
					StudentSystemMainFrame frame = new StudentSystemMainFrame(user);
					return ;
				}
			}else{
				JOptionPane.showMessageDialog(jf, "�û������������");
				 Reset();	//����
				return ;
			}
			
		}
	});
	c.add(login_Button);	//���"��¼"��ť ��
	
	
	register_Button = new JButton("ע��");	//����"ע��"��ť��
	register_Button.setBounds(250, 210, 60, 20);	//����"ע��"��ťλ�á�
	//ע��"ע��"��ť�¼�������
	register_Button.addActionListener(new ActionListener() {
		
		@Override
		public void actionPerformed(ActionEvent e) {
			jf.dispose();	//��ǰ���ڹرա�
			StudentSystemRegisterFrame studentSystemRegisterFrame = new StudentSystemRegisterFrame();	//��ע�����		
			
		}
	});
	c.add(register_Button);	//���"ע��"��ť��
	
	this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	this.setResizable(false);	//���ô�С���ɸı䡣
	WindowUtil.setFrameCenter(this);//���ô��ھ��С�
	try {
		Image img = ImageIO.read(this.getClass().getResource("/2.png"));
		this.setIconImage(img);
		
	} catch (IOException e1) {
		// TODO Auto-generated catch block
		e1.printStackTrace();
	}
	
	this.setVisible(true);	//���ô���ɼ���
}