成都创新互联网站制作重庆分公司

java档案代码,java编写个人档案

求JAVA小项目的完整代码

给你个做好了的Java的源程序的记事本,自己看看就行了的,不怎么难的···

创新互联公司是一家集成都网站设计、成都网站制作、外贸网站建设、网站页面设计、网站优化SEO优化为一体的专业的建站公司,已为成都等多地近百家企业提供网站建设服务。追求良好的浏览体验,以探求精品塑造与理念升华,设计最适合用户的网站页面。 合作只是第一步,服务才是根本,我们始终坚持讲诚信,负责任的原则,为您进行细心、贴心、认真的服务,与众多客户在蓬勃发展的市场环境中,互促共生。

import java.awt.*;

import java.awt.event.*;

import java.io.*;

import javax.swing.*;

public class MyNotepad implements ActionListener{

private JFrame frame=new JFrame("新记事本");

private JTextArea jta=new JTextArea();

private String result="";

private boolean flag=true;

private File f;

private JButton jb=new JButton("开始");

private JTextField jtf=new JTextField(15);

private JTextField jt=new JTextField(15);

private JButton jbt=new JButton("替换为");

private JButton jba=new JButton("全部替换");

private Icon ic=new ImageIcon("D:\\java课堂笔记\\GUI\\11.gif");

private String value;

private int start=0;

private JFrame jf=new JFrame("查找");

private JFrame jfc=new JFrame("替换");

@Override

public void actionPerformed(ActionEvent e) {

String comm=e.getActionCommand();

if("新建".equals(comm)){

if(!(frame.getTitle().equals("新记事本"))){

if(!flag){

write();

newNew();

}else{

JFileChooser jfc=new JFileChooser("D:\\java课堂笔记");

int returnVal = jfc.showDialog(null,"保存为");

if(returnVal == JFileChooser.APPROVE_OPTION) {//选择文件后再执行下面的语句,保证了程序的健壮性

f=jfc.getSelectedFile();

flag=false;

write();

}

}

}else if(!(jta.getText().isEmpty())){

JFileChooser jfc=new JFileChooser("D:\\java课堂笔记");

int returnVal = jfc.showDialog(null,"保存为");

if(returnVal == JFileChooser.APPROVE_OPTION) {//选择文件后再执行下面的语句,保证了程序的健壮性

f=jfc.getSelectedFile();

flag=false;

write();

newNew();

}

}else{

newNew();

}

}else if("打开".equals(comm)){

JFileChooser jfc=new JFileChooser("D:\\java课堂笔记");

jfc.setDialogType(JFileChooser.OPEN_DIALOG);

int returnVal = jfc.showOpenDialog(null);

if(returnVal == JFileChooser.APPROVE_OPTION) {//选择文件后再执行下面的语句,保证了程序的健壮性

f=jfc.getSelectedFile();

frame.setTitle(f.getName());

result=read();

flag=false;

value=result;

jta.setText(result);

}

}else if("保存".equals(comm)){

JFileChooser jfc=new JFileChooser("D:\\java课堂笔记");

if(flag){

int returnVal = jfc.showDialog(null,"保存为");

if(returnVal == JFileChooser.APPROVE_OPTION) {//选择文件后再执行下面的语句,保证了程序的健壮性

f=jfc.getSelectedFile();

flag=false;

write();

}

}else{

write();

}

}else if("另存".equals(comm)){

JFileChooser jfc=new JFileChooser("D:\\java课堂笔记");

int returnVal = jfc.showDialog(null,"另存");

if(returnVal == JFileChooser.APPROVE_OPTION) {//选择文件后再执行下面的语句,保证了程序的健壮性

f=jfc.getSelectedFile();

write();

}

}else if("退出".equals(comm)){

System.exit(0);

}else if("撤销".equals(comm)){

jta.setText(value);

}else if("剪切".equals(comm)){

value=jta.getText();

jta.cut();

}else if("复制".equals(comm)){

jta.copy();

}else if("粘贴".equals(comm)){

value=jta.getText();

jta.paste();

}else if("删除".equals(comm)){

value=jta.getText();

jta.replaceSelection(null);

}else if("全选".equals(comm)){

jta.selectAll();

}else if("查找".equals(comm)){

value=jta.getText();

jf.add(jtf,BorderLayout.CENTER);

jf.add(jb,BorderLayout.SOUTH);

jf.setLocation(300,300);

jf.pack();

jf.setVisible(true);

jf.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

}else if("替换".equals(comm)){

value=jta.getText();

GridLayout gl=new GridLayout(3,3);

JLabel jl1=new JLabel("查找内容:");

JLabel jl2=new JLabel("替换为:");

jfc.setLayout(gl);

jfc.add(jl1);

jfc.add(jtf);

jfc.add(jb);

jfc.add(jl2);

jfc.add(jt);

jfc.add(jbt);

JLabel jl3=new JLabel();

JLabel jl4=new JLabel();

jfc.add(jl3);

jfc.add(jl4);

jfc.add(jba);

jfc.setLocation(300,300);

jfc.pack();

jfc.setVisible(true);

jfc.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

}else if("版本".equals(comm)){

JDialog jd=new JDialog(frame,"关于对话框");

jd.setSize(200,200);

JLabel l=new JLabel("哈哈哈哈哈哈哈哈哈哈呵呵呵呵呵呵呵呵呵呵呵呵呵");

jd.add(l,BorderLayout.CENTER);

jd.setLocation(100,200);

jd.setSize(300,300);

jd.setVisible(true);

// jd.pack();

jd.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);

}else if("开始".equals(comm)||"下一个".equals(comm)){

String temp=jtf.getText();

int s=value.indexOf(temp,start);

if(value.indexOf(temp,start)!=-1){

jta.setSelectionStart(s);

jta.setSelectionEnd(s+temp.length());

jta.setSelectedTextColor(Color.GREEN);

start=s+1;

jb.setText("下一个");

// value=value.substring(s+temp.length());//不能截取字串

}else {

JOptionPane.showMessageDialog(jf, "查找完毕!", "提示", 0, ic);

jf.dispose();

}

}else if("替换为".equals(comm)){

String temp=jtf.getText();

int s=value.indexOf(temp,start);

if(value.indexOf(temp,start)!=-1){

jta.setSelectionStart(s);

jta.setSelectionEnd(s+temp.length());

jta.setSelectedTextColor(Color.GREEN);

start=s+1;

jta.replaceSelection(jt.getText());

}else {

JOptionPane.showMessageDialog(jf, "查找完毕!", "提示", 0, ic);

jf.dispose();

}

}else if("全部替换".equals(comm)){

String temp=jta.getText();

temp=temp.replaceAll(jtf.getText(), jt.getText());

jta.setText(temp);

}

}

public String read(){

String temp="";

try {

FileInputStream fis = new FileInputStream(f.getAbsolutePath());

byte[] b=new byte[1024];

while(true){

int num=fis.read(b);

if(num==-1)break;

temp=temp+new String(b,0,num);

}

fis.close();

} catch (Exception e1) {

e1.printStackTrace();

}

return temp;

}

public void write(){

try {

FileOutputStream fos=new FileOutputStream(f);

fos.write(jta.getText().getBytes());

fos.close();

} catch (Exception e) {

e.printStackTrace();

}

}

public void newNew(){

frame.dispose();

new MyNotepad();

flag=true;

}

public MyNotepad(){

JMenuBar jmb=new JMenuBar();

String[] menuLab={"文件","编辑","帮助"};

String[][] menuItemLab={{"新建","打开","保存","另存","退出"},

{"撤销","剪切","复制","粘贴","删除","全选","查找","替换"},

{"版本"}};

for(int i=0;imenuLab.length;i++){

JMenu menu=new JMenu(menuLab[i]);

jmb.add(menu);

for(int j=0;jmenuItemLab[i].length;j++){

JMenuItem jmi=new JMenuItem(menuItemLab[i][j]);

menu.add(jmi);

jmi.addActionListener(this);

}

}

frame.setJMenuBar(jmb);

jta.setLineWrap(true);//自动换行

JScrollPane jsp=new JScrollPane(jta);//滚动窗口面板

frame.add(jsp);

jb.addActionListener(this);

jbt.addActionListener(this);

jba.addActionListener(this);

frame.setLocation(200,50);

frame.setSize(620,660);

frame.setVisible(true);

frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

}

public static void main(String[] args) {

new MyNotepad();

}

}

企业档案管理系统的全部Java代码

这个采用 java web 进行开发

确认需求 设计表 coding

数据库:mysql or sqlserver

服务器:Tomcat

see my (baid u) name

java怎么调试代码?

步骤:

1、在cmd中切换到编写的代码所保存的目录下;

2、在cmd中输入javac然后点空格,再点击文件名和包括后缀名确定后,在存放编写代码的文件下会生成一个class的字节码文件;

3、在cmd中输入java然后点空格,输入第二步中生成的字节码的文件名,不需要后缀名,点击确定即可运行代码。

代码就是程序员用开发工具所支持的语言写出来的源文件,是一组由字符、符号或信号码元以离散形式表示信息的明确的规则体系。计算机代码称为源代码,是相对目标代码和可执行代码而言的。 源代码就是用汇编语言和高级语言写出来的地代码,目标代码是指源代码经过编译程序产生的能被cpu直接识别二进制代码。

java练习题求完整代码

按照题目要求编写的用javaBean规范设计的学生类Student的Java程序如下

需要创建user.java.test包,把Student.java文件和Test.java文件放入包中,编译Student.java文件并且编译运行Test.java文件得到运行结果

Student.java文件代码如下

package user.java.test;

import java.io.Serializable;

public class Student implements Serializable{

private static final long serialVersionUID = 1L;

private String no;

private String name;

private double score;

public Student(){}

public Student(String no,String name,double score){

this.no=no;

this.name=name;

this.score=score;

}

public String getNo(){ return no;}

public void setNo(String no){ this.no=no;}

public String getName(){ return name;}

public void setName(String name){ this.name=name;}

public double getScore(){ return score;}

public void setScore(double score){ this.score=score;}

public String toString(){

return "学号:"+no+",姓名:"+name+",成绩:"+score;

}

public static double getAvg(Student[] sArray){

double sum=0,avg;

for(int i=0;isArray.length;i++){

sum=sum+sArray[i].getScore();

}

avg=sum/sArray.length;

return avg;

}

}

Test.java文件代码如下

package user.java.test;

public class Test{

public static void main(String[] args){

Student[] sArray=new Student[5];

sArray[0]=new Student("001","张三",89.5);

sArray[1]=new Student("002","李四",82.5);

sArray[2]=new Student("003","王五",93);

sArray[3]=new Student("004","赵六",73.5);

sArray[4]=new Student("005","孙七",66);

System.out.println("这些学生的平均分:"+Student.getAvg(sArray));

for(int i=0;isArray.length;i++){

System.out.println(sArray[i].toString());

}

}

}

编写一个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代码

连连看java源代码

import javax.swing.*;

import java.awt.*;

import java.awt.event.*;

public class lianliankan implements ActionListener

{

JFrame mainFrame; //主面板

Container thisContainer;

JPanel centerPanel,southPanel,northPanel; //子面板

JButton diamondsButton[][] = new JButton[6][5];//游戏按钮数组

JButton exitButton,resetButton,newlyButton; //退出,重列,重新开始按钮

JLabel fractionLable=new JLabel("0"); //分数标签

JButton firstButton,secondButton; //分别记录两次被选中的按钮

int grid[][] = new int[8][7];//储存游戏按钮位置

static boolean pressInformation=false; //判断是否有按钮被选中

int x0=0,y0=0,x=0,y=0,fristMsg=0,secondMsg=0,validateLV; //游戏按钮的位置坐标

int i,j,k,n;//消除方法控制

public void init(){

mainFrame=new JFrame("JKJ连连看");

thisContainer = mainFrame.getContentPane();

thisContainer.setLayout(new BorderLayout());

centerPanel=new JPanel();

southPanel=new JPanel();

northPanel=new JPanel();

thisContainer.add(centerPanel,"Center");

thisContainer.add(southPanel,"South");

thisContainer.add(northPanel,"North");

centerPanel.setLayout(new GridLayout(6,5));

for(int cols = 0;cols 6;cols++){

for(int rows = 0;rows 5;rows++ ){

diamondsButton[cols][rows]=new JButton(String.valueOf(grid[cols+1][rows+1]));

diamondsButton[cols][rows].addActionListener(this);

centerPanel.add(diamondsButton[cols][rows]);

}

}

exitButton=new JButton("退出");

exitButton.addActionListener(this);

resetButton=new JButton("重列");

resetButton.addActionListener(this);

newlyButton=new JButton("再来一局");

newlyButton.addActionListener(this);

southPanel.add(exitButton);

southPanel.add(resetButton);

southPanel.add(newlyButton);

fractionLable.setText(String.valueOf(Integer.parseInt(fractionLable.getText())));

northPanel.add(fractionLable);

mainFrame.setBounds(280,100,500,450);

mainFrame.setVisible(true);

}

public void randomBuild() {

int randoms,cols,rows;

for(int twins=1;twins=15;twins++) {

randoms=(int)(Math.random()*25+1);

for(int alike=1;alike=2;alike++) {

cols=(int)(Math.random()*6+1);

rows=(int)(Math.random()*5+1);

while(grid[cols][rows]!=0) {

cols=(int)(Math.random()*6+1);

rows=(int)(Math.random()*5+1);

}

this.grid[cols][rows]=randoms;

}

}

}

public void fraction(){

fractionLable.setText(String.valueOf(Integer.parseInt(fractionLable.getText())+100));

}

public void reload() {

int save[] = new int[30];

int n=0,cols,rows;

int grid[][]= new int[8][7];

for(int i=0;i=6;i++) {

for(int j=0;j=5;j++) {

if(this.grid[i][j]!=0) {

save[n]=this.grid[i][j];

n++;

}

}

}

n=n-1;

this.grid=grid;

while(n=0) {

cols=(int)(Math.random()*6+1);

rows=(int)(Math.random()*5+1);

while(grid[cols][rows]!=0) {

cols=(int)(Math.random()*6+1);

rows=(int)(Math.random()*5+1);

}

this.grid[cols][rows]=save[n];

n--;

}

mainFrame.setVisible(false);

pressInformation=false; //这里一定要将按钮点击信息归为初始

init();

for(int i = 0;i 6;i++){

for(int j = 0;j 5;j++ ){

if(grid[i+1][j+1]==0)

diamondsButton[i][j].setVisible(false);

}

}

}

public void estimateEven(int placeX,int placeY,JButton bz) {

if(pressInformation==false) {

x=placeX;

y=placeY;

secondMsg=grid[x][y];

secondButton=bz;

pressInformation=true;

}

else {

x0=x;

y0=y;

fristMsg=secondMsg;

firstButton=secondButton;

x=placeX;

y=placeY;

secondMsg=grid[x][y];

secondButton=bz;

if(fristMsg==secondMsg secondButton!=firstButton){

xiao();

}

}

}

public void xiao() { //相同的情况下能不能消去。仔细分析,不一条条注释

if((x0==x (y0==y+1||y0==y-1)) || ((x0==x+1||x0==x-1)(y0==y))){ //判断是否相邻

remove();

}

else{

for (j=0;j7;j++ ) {

if (grid[x0][j]==0){ //判断第一个按钮同行哪个按钮为空

if (yj) { //如果第二个按钮的Y坐标大于空按钮的Y坐标说明第一按钮在第二按钮左边

for (i=y-1;i=j;i-- ){ //判断第二按钮左侧直到第一按钮中间有没有按钮

if (grid[x][i]!=0) {

k=0;

break;

}

else //K=1说明通过了第一次验证

}

if (k==1) {

linePassOne();

}

}

if (yj){ //如果第二个按钮的Y坐标小于空按钮的Y坐标说明第一按钮在第二按钮右边

for (i=y+1;i=j ;i++ ){ //判断第二按钮左侧直到第一按钮中间有没有按钮

if (grid[x][i]!=0){

k=0;

break;

}

else

}

if (k==1){

linePassOne();

}

}

if (y==j ) {

linePassOne();

}

}

if (k==2) {

if (x0==x) {

remove();

}

if (x0x) {

for (n=x0;n=x-1;n++ ) {

if (grid[n][j]!=0) {

k=0;

break;

}

if(grid[n][j]==0 n==x-1) {

remove();

}

}

}

if (x0x) {

for (n=x0;n=x+1 ;n-- ) {

if (grid[n][j]!=0) {

k=0;

break;

}

if(grid[n][j]==0 n==x+1) {

remove();

}

}

}

}

}

for (i=0;i8;i++ ) { //列

if (grid[i][y0]==0) {

if (xi) {

for (j=x-1;j=i ;j-- ) {

if (grid[j][y]!=0) {

k=0;

break;

}

else

}

if (k==1) {

rowPassOne();

}

}

if (xi) {

for (j=x+1;j=i;j++ ) {

if (grid[j][y]!=0) {

k=0;

break;

}

else

}

if (k==1) {

rowPassOne();

}

}

if (x==i) {

rowPassOne();

}

}

if (k==2){

if (y0==y) {

remove();

}

if (y0y) {

for (n=y0;n=y-1 ;n++ ) {

if (grid[i][n]!=0) {

k=0;

break;

}

if(grid[i][n]==0 n==y-1) {

remove();

}

}

}

if (y0y) {

for (n=y0;n=y+1 ;n--) {

if (grid[i][n]!=0) {

k=0;

break;

}

if(grid[i][n]==0 n==y+1) {

remove();

}

}

}

}

}

}

}

public void linePassOne(){

if (y0j){ //第一按钮同行空按钮在左边

for (i=y0-1;i=j ;i-- ){ //判断第一按钮同左侧空按钮之间有没按钮

if (grid[x0][i]!=0) {

k=0;

break;

}

else //K=2说明通过了第二次验证

}

}

if (y0j){ //第一按钮同行空按钮在与第二按钮之间

for (i=y0+1;i=j ;i++){

if (grid[x0][i]!=0) {

k=0;

break;

}

else

}

}

}

public void rowPassOne(){

if (x0i) {

for (j=x0-1;j=i ;j-- ) {

if (grid[j][y0]!=0) {

k=0;

break;

}

else

}

}

if (x0i) {

for (j=x0+1;j=i ;j++ ) {

if (grid[j][y0]!=0) {

k=0;

break;

}

else

}

}

}

public void remove(){

firstButton.setVisible(false);

secondButton.setVisible(false);

fraction();

pressInformation=false;

k=0;

grid[x0][y0]=0;

grid[x][y]=0;

}

public void actionPerformed(ActionEvent e) {

if(e.getSource()==newlyButton){

int grid[][] = new int[8][7];

this.grid = grid;

randomBuild();

mainFrame.setVisible(false);

pressInformation=false;

init();

}

if(e.getSource()==exitButton)

System.exit(0);

if(e.getSource()==resetButton)

reload();

for(int cols = 0;cols 6;cols++){

for(int rows = 0;rows 5;rows++ ){

if(e.getSource()==diamondsButton[cols][rows])

estimateEven(cols+1,rows+1,diamondsButton[cols][rows]);

}

}

}

public static void main(String[] args) {

lianliankan llk = new lianliankan();

llk.randomBuild();

llk.init();

}

}

//old 998 lines

//new 318 lines


当前标题:java档案代码,java编写个人档案
本文路径:http://cxhlcq.com/article/hdpsdi.html

其他资讯

在线咨询

微信咨询

电话咨询

028-86922220(工作日)

18980820575(7×24)

提交需求

返回顶部