重庆分公司,新征程启航
为企业提供网站建设、域名注册、服务器等服务
import java.util.*;
十余年的鄂州网站建设经验,针对设计、前端、开发、售后、文案、推广等六对一服务,响应快,48小时及时工作处理。全网营销推广的优势是能够根据用户设备显示端的尺寸不同,自动调整鄂州建站的显示方式,使网站能够适用不同显示终端,在浏览器中调整网站的宽度,无论在任何一种浏览器上浏览网站,都能展现优雅布局与设计,从而大程度地提升浏览体验。创新互联从事“鄂州网站设计”,“鄂州网站推广”以来,每个客户项目都认真落实执行。
import java.io.*;
import static java.lang.System.out;
public class Shurusuchu {
public static void main(String[] args)throws Exception {
try{
BufferedReader br=new BufferedReader(new FileReader("123.txt"));
out.println(br.readLine());
}catch(FileNotFoundException e){
new File("123.txt");
}
//输入语句
Scanner sc=new Scanner(System.in);
out.println("请输入您要输入的信息");
String message=sc.next();
BufferedWriter bw=new BufferedWriter(new FileWriter("123.txt"));
bw.write(message);
bw.close();
}
}
//编了一个很粗糙的程序,大概内容是实现了的,你看看
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;
}
}
public class student
{public static void main(String args[])
{
int iB=20;
String iA="姓名"; //这行如果是字符串要定义为String类型,而且赋值时要加上双引号。
System.out.println("姓名是:"+iA+"年龄"+iB); //这行里的逗号改为加号,否则报错。
}
}
一看就是新手入门,建议别着急写代码,现看看java的语法,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();
}
}
效果如下图:
本人急忙做的:有什么不合要求的请再告诉我:
package show;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class Test extends JFrame implements ActionListener
{
GridBagLayout g=new GridBagLayout();
GridBagConstraints c=new GridBagConstraints();
Test(String str)
{
super(str);
setSize(300,500);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLayout(g);
//调用方法
addComponent();
submit.addActionListener(this);
setVisible(true);
setLocationRelativeTo(null);//设居中显示;
}
//在这个方法中将会添加所有的组件;
//使用的网格包布局;希望楼主能看懂;
public void addComponent()
{
//个人信息登记
noteInformation=new JLabel("个人信息登记:");
add(g,c,noteInformation,0,0,1,1);
//用户名
userName=new JLabel("用户名:");
add(g,c,userName,0,1,1,1);
//用户名输入框
textUserName=new JTextField(10);
add(g,c,textUserName,1,1,2,1);
//密码:
password=new JLabel("密码:");
add(g,c,password,0,2,1,1);
//密码输入框
textUserPassword=new JTextField(10);
add(g,c,textUserPassword,1,2,2,1);
//性别
sex=new JLabel("性别:");
add(g,c,sex,0,3,1,1);
//男 女单选框
sexMan=new JRadioButton("男");
add(g,c,sexMan,1,3,1,1);
sexGirl=new JRadioButton("女");
add(g,c,sexGirl,2,3,1,1);
ButtonGroup group=new ButtonGroup();
group.add(sexMan);
group.add(sexGirl);
//出生日期
birthday=new JLabel("出生日期:");
add(g,c,birthday,0,4,1,1);
//复选框及其内容
String[] YEARS=new String[65];
for(int i=1950,k=0;i=2014;i++,k++)
{
YEARS[k]=i+"年";
}
year=new JComboBox(YEARS);
add(g,c,year,1,4,1,1);
//复选框及内容
month=new JComboBox(MONTH);
add(g,c,month,2,4,1,1);
//submit按钮
submit=new JButton("submit");
c.insets=new Insets(7,0,4,0);
add(g,c,submit,1,5,1,1);
result=new JTextArea(15,20);
add(g,c,result,0,6,3,4);
}
/* public void ActionPerformed(ActionEvent e)
{
String s=textUserName.getText();
String t=textUserPassword.getText();
String k=sexMan.getText();
String v=sexGirl.getText();
String a=(String) year.getSelectedItem();
String b=(String)month.getSelectedItem();
String num="用户名:"+s+"\n"+"密码: "+t+"性别: "+(k==null?v:k)+"\n"+"出生日期:"+a+" "+b;
result.append(num);
}*/
public void add(GridBagLayout g,GridBagConstraints c,JComponent jc,int x ,int y,int gw,int gh)
{
c.gridx=x;
c.gridy=y;
c.anchor=GridBagConstraints.WEST;
c.gridwidth=gw;
c.gridheight=gh;
g.setConstraints(jc,c);
add(jc);
}
public static void main(String args[])
{
new Test("个人信息登记表");
}
JLabel noteInformation,userName,password;
JLabel sex,birthday;
JTextField textUserName,textUserPassword;
JRadioButton sexMan,sexGirl;
JComboBox year,month;
JButton submit;
JTextArea result;
final String[] MONTH={"1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"};
@Override
public void actionPerformed(ActionEvent arg0)
{
String s=textUserName.getText();
String t=textUserPassword.getText();
String k=sexMan.getText();
String v=sexGirl.getText();
String a=(String) year.getSelectedItem();
String b=(String)month.getSelectedItem();
String num="用户名:"+s+"\n"+"密码: "+t+"\n 性别: "+(k==null?v:k)+"\n"+"出生日期:"+a+" "+b;
result.setText(num);
}
}