介绍个人信息java代码 Java个人介绍
用java写一个程序,用变量保存自己的个人信息,并且输出
import java.util.Scanner;
创新互联公司专注于浏阳企业网站建设,响应式网站建设,成都商城网站开发。浏阳网站建设公司,为浏阳等地区提供建站服务。全流程按需定制开发,专业设计,全程项目跟踪,创新互联公司专业和态度为您提供的服务
public class 个人信息
{
public static void main(String[] args)
{
System.out.println("\n\t\t==========简单的个人信息录入==========\n");
init();
}//初始化!
private static void init()
{
/*int a1 = 073;
long b1 = 0xa38f;
System.out.println(a1+"....."+b1);*/
for (; ; )
{
System.out.println("请输入姓名:");
String a=Input.getName();
System.out.println("请输入年龄:");
int b=Input.getAge();
System.out.println("请输入学历:");
String c=Input.getEducation();
System.out.println("你输入的信息^_^\t名字:"+a+" 年龄:"+b+" 学历:"+c+"\n");
}
}
}
class Input
{
private static Scanner sc=new Scanner(System.in);
private Input(){}
static String getName()
{
String name=sc.next();
return name;
}
static int getAge()
{
int age=sc.nextInt();
return age;
}
static String getEducation()
{
String education=sc.next();
return education;
}
}
Java实现简单个人信息录入
数据库就要你自己建了.
import javax.swing.*;
import javax.swing.event.*;
import java.awt.*;
import java.awt.event.*;
import java.sql.*;
public class PersonInfoRecorder extends JFrame implements ActionListener{
private JLabel nameLabel,sexLabel,ageLabel,tipLabel;//用来显示姓名、性别、年龄和提示栏
private JTextField nameTextField,ageTextField;//用来输入姓名和年龄
private JComboBox sex;//用来选择性别
private JTextArea info;//用来显示输入的个人信息
private JButton ok;//确定按钮
private JPanel northPanel,centerPanel,bigPanel;
public PersonInfoRecorder(){
super("个人信息录入器");
nameLabel = new JLabel("姓名");
sexLabel = new JLabel("性别");
ageLabel = new JLabel("年龄");
nameTextField = new JTextField(6);
ageTextField = new JTextField(6);
String sexs[] = {"男","女" };
sex = new JComboBox(sexs);
/*sex.addItemListener(
new ItemListener(){
public void itemStateChanged(ItemEvent event){
if(event.getStateChange() == ItemEvent.SELECTED){
String fsex = (String)sex.getSelectedItem();
info.setText(fsex);
}
}
});*/
ok = new JButton("确定");
ok.addActionListener(this);
northPanel = new JPanel();
northPanel.add(nameLabel);
northPanel.add(nameTextField);
northPanel.add(sexLabel);
northPanel.add(sex);
northPanel.add(ageLabel);
northPanel.add(ageTextField);
northPanel.add(ok);
info = new JTextArea("输入个人简要信息",5,30);
info.setLineWrap(true);
centerPanel = new JPanel();
JScrollPane scroll = new JScrollPane(info);
scroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
scroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
centerPanel.add(scroll);
bigPanel = new JPanel();
bigPanel.add(northPanel);
bigPanel.add(centerPanel);
getContentPane().add(bigPanel);
setSize(400,200);
setVisible(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public void actionPerformed(ActionEvent e){
if(nameTextField.getText().equals("")){
JOptionPane.showMessageDialog(null, "姓名不能为空!请输入姓名.");
}else{
String inform = info.getText();
if(inform.equals("输入个人简要信息")){
inform = "";
}
info.setText("姓名:" + nameTextField.getText()
+ "\n性别:" + (String)sex.getSelectedItem()
+ "\n年龄:" +
"\n简介:\n" + inform);
try{ //这里的异常处理语句是必需的.否则不能通过编译!
String sqlStr = "insert into Person values(nameTextField.getText(),"+
"(String)sex.getSelectedItem(),ageTextField.getText(),inform)";
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
String url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=Person";
//Person为数据库
String user="sa";
String password="";
Connection con = DriverManager.getConnection(url,user,password);
Statement st = con.createStatement();
st.executeUpdate( sqlStr );
st.close();
con.close();
} catch(ClassNotFoundException exception) {
exception.printStackTrace(System.out);
}
catch(Exception err) {
err.printStackTrace(System.out);
}
}
}
public static void main(String[] args) {
PersonInfoRecorder application = new PersonInfoRecorder();
}
}
简单个人简历java录入程序 代码
我帮你写了那些JAVA代码了,效果包你满意!呵呵……
至于网页的代码嘛,这里就不贴了。你要的话HI我吧^_^。
JAVA代码如下:
import java.awt.BorderLayout;
import javax.swing.*;
import java.awt.Dimension;
import java.awt.Rectangle;
public class MyLuRu extends JFrame {
private static final long serialVersionUID = 1L;
private JPanel jContentPane = null;
private JLabel jLabel = null;
private JLabel jLabel1 = null;
private JLabel jLabel2 = null;
private JLabel jLabel3 = null;
private JTextField jTextField = null;
private JRadioButton jRadioButton = null;
private JRadioButton jRadioButton1 = null;
private JComboBox jComboBox = null;
private JComboBox jComboBox1 = null;
private JButton jButton = null;
private JButton jButton1 = null;
private JTextArea jTextArea = null;
private ButtonGroup mybg=new ButtonGroup();
/**
* This is the default constructor
*/
public MyLuRu() {
super();
initialize();
}
/**
* This method initializes this
*
* @return void
*/
private void initialize() {
this.setSize(268, 407);
this.setContentPane(getJContentPane());
this.setTitle("录入");
this.addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent e) {
System.exit(0);
}
});
this.setVisible(true);
}
/**
* This method initializes jContentPane
*
* @return javax.swing.JPanel
*/
private JPanel getJContentPane() {
if (jContentPane == null) {
jLabel3 = new JLabel();
jLabel3.setBounds(new Rectangle(16, 150, 65, 18));
jLabel3.setText("文化程度:");
jLabel2 = new JLabel();
jLabel2.setBounds(new Rectangle(16, 108, 39, 18));
jLabel2.setText("专业:");
jLabel1 = new JLabel();
jLabel1.setBounds(new Rectangle(16, 66, 39, 18));
jLabel1.setText("性别:");
jLabel = new JLabel();
jLabel.setBounds(new Rectangle(16, 24, 39, 18));
jLabel.setText("姓名:");
jContentPane = new JPanel();
jContentPane.setLayout(null);
jContentPane.add(jLabel, null);
jContentPane.add(jLabel1, null);
jContentPane.add(jLabel2, null);
jContentPane.add(jLabel3, null);
jContentPane.add(getJTextField(), null);
jContentPane.add(getJRadioButton(), null);
jContentPane.add(getJRadioButton1(), null);
mybg.add(jRadioButton);
mybg.add(jRadioButton1);
jContentPane.add(getJComboBox(), null);
jContentPane.add(getJComboBox1(), null);
jContentPane.add(getJButton(), null);
jContentPane.add(getJButton1(), null);
jContentPane.add(getJTextArea(), null);
}
return jContentPane;
}
/**
* This method initializes jTextField
*
* @return javax.swing.JTextField
*/
private JTextField getJTextField() {
if (jTextField == null) {
jTextField = new JTextField();
jTextField.setBounds(new Rectangle(61, 24, 180, 18));
}
return jTextField;
}
/**
* This method initializes jRadioButton
*
* @return javax.swing.JRadioButton
*/
private JRadioButton getJRadioButton() {
if (jRadioButton == null) {
jRadioButton = new JRadioButton();
jRadioButton.setBounds(new Rectangle(61, 62, 38, 26));
jRadioButton.setText("男");
}
return jRadioButton;
}
/**
* This method initializes jRadioButton1
*
* @return javax.swing.JRadioButton
*/
private JRadioButton getJRadioButton1() {
if (jRadioButton1 == null) {
jRadioButton1 = new JRadioButton();
jRadioButton1.setBounds(new Rectangle(117, 62, 38, 26));
jRadioButton1.setText("女");
}
return jRadioButton1;
}
/**
* This method initializes jComboBox
*
* @return javax.swing.JComboBox
*/
private JComboBox getJComboBox() {
if (jComboBox == null) {
String[] strcb={"计算机","电子","工商"};
jComboBox = new JComboBox(strcb);
jComboBox.setBounds(new Rectangle(62, 108, 93, 18));
}
return jComboBox;
}
/**
* This method initializes jComboBox1
*
* @return javax.swing.JComboBox
*/
private JComboBox getJComboBox1() {
if (jComboBox1 == null) {
String[] strcb2={"大专","本科","硕士","博士"};
jComboBox1 = new JComboBox(strcb2);
jComboBox1.setBounds(new Rectangle(92, 150, 125, 18));
}
return jComboBox1;
}
/**
* This method initializes jButton
*
* @return javax.swing.JButton
*/
private JButton getJButton() {
if (jButton == null) {
jButton = new JButton();
jButton.setBounds(new Rectangle(66, 181, 60, 28));
jButton.setText("提交");
jButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
String strname=jTextField.getText();
String strsex="男";
if(jRadioButton1.isSelected()){
strsex="女";
}
String strzy=jComboBox.getSelectedItem().toString();
String strwh=jComboBox1.getSelectedItem().toString();
jTextArea.setText("姓名:"+strname+"\r\n"+"性别:"+strsex+"\r\n"+"专业:"+strzy+"\r\n"+"文化:"+strwh);
}
});
}
return jButton;
}
/**
* This method initializes jButton1
*
* @return javax.swing.JButton
*/
private JButton getJButton1() {
if (jButton1 == null) {
jButton1 = new JButton();
jButton1.setBounds(new Rectangle(158, 181, 60, 28));
jButton1.setText("取消");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
System.exit(0);
}
});
}
return jButton1;
}
/**
* This method initializes jTextArea
*
* @return javax.swing.JTextArea
*/
private JTextArea getJTextArea() {
if (jTextArea == null) {
jTextArea = new JTextArea();
jTextArea.setBounds(new Rectangle(16, 225, 229, 130));
}
return jTextArea;
}
public static void main(String args[]){
new MyLuRu();
}
}
效果如下图:
编写一个JAVA程序,显示你的个人档案!
/*首先定义一个方法类*/
class method{
public String name;
public String sex;
public int age;
/*这里还可以定义很多关于你的档案信息成员变量*/
/*下面这两个是构造方法*/
method(){
name="";
sex="";
age=0;
}
method(String name,String sex,int age){
this.name=name;
this.sex=sex;
this.age=age;
}
/*下面写方法*/
String getName(String name){
return name;
}
String getSex(String sex){
return sex;
}
int getAge(int age){
return age;
}
}
/*写一个测试类*/
public class Test{
public static void main(String args[]){
method a=new method("浅浅de夕阳","男",20);
System.out.println("姓名:"+a.getName());
System.out.println("性别:"+a.getSex());
System.out.println("年龄:"+a.getAge());
}
}
我写的稍微复杂了点,但是也就完善了点,写那几个get方法,是为了更完整,那样就算是你的成员变量改为私有的,在后面通过调用get方法也能返回变量的值。
编写一个简单的java程序显示个人信息:姓名,性别,出生年月,爱好?
public class MyInfo {
public static void main(String []args) {
System.out.println("你好,以下是我的个人信息:");
System.out.println("姓名:李刚");
System.out.println("性别:女");
System.out.println("出生年月:1998-08");
System.out.println("爱好:上网");}
}
名称栏目:介绍个人信息java代码 Java个人介绍
文章地址:http://pwwzsj.com/article/dodcppj.html