重庆分公司,新征程启航

为企业提供网站建设、域名注册、服务器等服务

用户类java代码 java客户端代码

求JAVA实现用户登录界面代码?

你要先学会截图哦,你发的看不清楚,重新写了一个你参考参考!

10年积累的成都网站设计、成都做网站经验,可以快速应对客户对网站的新想法和需求。提供各种问题对应的解决方案。让选择我们的客户得到更好、更有力的网络服务。我虽然不认识你,你也不认识我。但先网站设计后付款的网站建设流程,更有常州免费网站建设让你可以放心的选择与我们合作。

import java.awt.GridLayout;

import javax.swing.ButtonGroup;

import javax.swing.JButton;

import javax.swing.JComboBox;

import javax.swing.JFrame;

import javax.swing.JLabel;

import javax.swing.JPanel;

import javax.swing.JRadioButton;

import javax.swing.JTextField;

public class Day30A extends JFrame {

private static final long serialVersionUID = 1L;

private JLabel labelName,labelId,labelPass,labelMoney,labelSelect,labelCar;

private JComboBoxString jcb;

private JPanel jp1,jp2,jp3,jp4,jp5,jp6,jp7;

private ButtonGroup btg;

private JRadioButton jr1,jr2;

Day30A(){

this.setTitle("注册账户");

this.setLayout(new GridLayout(7,1));

this.setSize(300,280);

this.setLocationRelativeTo(null);

this.setDefaultCloseOperation(EXIT_ON_CLOSE);

init();

this.setVisible(true);

}

private void init() {

String str="卡片类型1,卡片类型2,卡片类型3,卡片类型4,卡片类型5";

jcb=new JComboBox(str.split(","));

labelId=new JLabel("账号: ");

labelName=new JLabel("姓名: ");

labelPass=new JLabel("密码: ");

labelMoney=new JLabel("开户金额:");

labelSelect=new JLabel("存款类型:");

labelCar=new JLabel("卡片类型:");

addFun1();

addFun2();

}

private void addFun2() {

this.add(jp1);

this.add(jp2);

this.add(jp3);

this.add(jp4);

this.add(jp5);

this.add(jp6);

this.add(jp7);

}

private void addFun1() {

jp1=new JPanel();

jp1.add(labelId);

jp1.add(new JTextField(15));

jp2=new JPanel();

jp2.add(labelName);

jp2.add(new JTextField(15));

jp3=new JPanel();

jp3.add(labelPass);

jp3.add(new JTextField(15));

jp4=new JPanel();

jp4.add(labelMoney);

jp4.add(new JTextField(13));

jp5=new JPanel();

jp5.add(labelSelect);

btg=new ButtonGroup();

jr1=new JRadioButton("定期");

jr2=new JRadioButton("活期",true);

btg.add(jr1);

btg.add(jr2);

jp5.add(jr1);

jp5.add(jr2);

jp6=new JPanel();

jp6.add(labelCar);

jp6.add(jcb);

jp7=new JPanel();

jp7.add(new JButton("确定"));

jp7.add(new JButton("取消"));

}

public static void main(String[] args) {

new Day30A();

}

}

java设计一个表示用户的User类

public class Use {

public static void main(String args[]){

User user1=new User();

user1.setUsername("joyce717533");

user1.setPassword("千总四级");

System.out.println("user1:"+user1.toString());

User user2=new User("joyce717533");

user2.setPassword("千总四级");

System.out.println("user2:"+user2.toString());

User user3=new User("joyce717533","千总四级");

System.out.println("user3:"+user3.toString());

}

}

class User {

public String username;

public String password;

public static int record;

public User() {

}

public User(String username){

this.username=username;

}

public User(String username,String password){

this.username=username;

this.password=password;

}

public String getPassword() {

return password;

}

public void setPassword(String password) {

this.password = password;

}

public String getUsername() {

return username;

}

public void setUsername(String username) {

this.username = username;

}

public String toString(){

return "username: "+username+",passwrod: "+password;

}

}

已经给楼主写好了...祝楼主早日成功哈!!!!!

用java编写四个类。用户类(User)角色类(Role ) 权限类(Right)测试类(test)

程序如下:

class User{

private String userName;

private String passWord;

private Role role;

public User(String userName, String passWord, Role role){

this.userName = userName;

this.passWord = passWord;

this.role = role;

}

public Role getRole() {

return role;

}

public String getUserName() {

return userName;

}

}

class Role{

private int roleId;

private String roleText;

private String users;

private Right rights;

public Role(int roleId, String roleText, String users, Right rights){

this.roleId = roleId;

this.roleText = roleText;

this.users = users;

this.rights = rights;

}

public int getRoleId() {

return roleId;

}

}

class Right{

private int rightId;

private String rightText;

private String roles;

public Right(int rightId, String rightText, String roles){

this.rightId =rightId;

this.rightText= rightText;

this.roles = roles;

}

}

public class Test {

public static void main(String[] args) {

Right rights = new Right(2013012701, "banana", "host");

Role role = new Role(20130127, "apple", "Zhang San", rights);

User user = new User("Zhang San", "zhangsan123", role);

System.out.println("The ID of user: " + user.getUserName() + "'s role is " + (user.getRole()).getRoleId());

}

}


本文题目:用户类java代码 java客户端代码
文章来源:http://cqcxhl.com/article/dodoiso.html

其他资讯

在线咨询
服务热线
服务热线:028-86922220
TOP