<i id='vnedc96g'><tr id='7rcl3ove'><dt id='wulnf08r'><q id='42lrcz10'><span id='g9pd4bhl'><b id='qjlumlu5'><form id='32vh2gzx'><ins id='kkf15x6t'></ins><ul id='gl2povh7'></ul><sub id='zsg5ozk9'></sub></form><legend id='a5egfn7m'></legend><bdo id='t36ka2yp'><pre id='8llfwmpm'><center id='fclw3gbo'></center></pre></bdo></b><th id='8mwsxx22'></th></span></q></dt></tr></i><div id='gh6wdtjh'><tfoot id='uvgpfxoe'></tfoot><dl id='327d44ze'><fieldset id='rw52j5bo'></fieldset></dl></div>

    1. <tfoot id='xr23io38'></tfoot>

        <bdo id='me5a8fr0'></bdo><ul id='25qmul3w'></ul>
      <legend id='i4iu8s40'><style id='p4u32a2o'><dir id='6rnizby3'><q id='zh4fu4ma'></q></dir></style></legend>
    2. <small id='6utc3au1'></small><noframes id='zejjcf8i'>

    3. 欢迎来到入门教程网!

      Java编程

      当前位置:主页 > 软件编程 > Java编程 >

      java项目完整代码 java项目 代码结构层次

      来源:本站原创|时间:2023-04-05|栏目:Java编程|点击:

      求JAVA小项目的完整代码

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

      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程序代码

      package Test1;

      import java.time.LocalDateTime;

      import java.time.Month;

      import java.util.IntSummaryStatistics;

      import java.util.Scanner;

      import java.util.Vector;

      public class D {

      static String s1 = "";

      public static void main(String[] args) {

      int day = LocalDateTime.now().getDayOfMonth();

      Month month = LocalDateTime.now().getMonth();

      int i = 1, i1 = 0;

      VectorInteger vector=new Vector();

      Scanner scanner = new Scanner(System.in);

      while (i day + 1) {

      System.out.println("请输入" + month + "月" + i + "日走的步数");

      try {

      i1 = scanner.nextInt();

      } catch (Exception e) {

      // TODO: handle exception

      System.out.println("输入错误,请重新输入");

      continue;

      }

      vector.add(i1);

      i++;

      }

      scanner.close();

      IntSummaryStatistics intSummaryStatistics=vector.stream().mapToInt(x-x).summaryStatistics();

      int i2=intSummaryStatistics.getMax();

      int i3=vector.indexOf(i2);

      System.out.println(month+"月走的步数最多的日期为: "+(i3+1)+"号");

      System.out.println("最多的步数为: "+i2);

      }

      }

      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());

      }

      }

      }

        <bdo id='7rdcvhta'></bdo><ul id='wstv8p99'></ul>

      • <legend id='ctn3gqv5'><style id='3n8d0se8'><dir id='0nttn93p'><q id='x2y9wk3o'></q></dir></style></legend>

        <small id='mmaa2fp5'></small><noframes id='ufgi9m8n'>

      • <tfoot id='nn2w45fn'></tfoot>
        <i id='13vh4eg8'><tr id='sy1f8j35'><dt id='0wkeezk2'><q id='mive0p1j'><span id='45vhvtvk'><b id='zkxf08u2'><form id='3fisfw8f'><ins id='cgdkupbn'></ins><ul id='gr29fntg'></ul><sub id='h7o7baq9'></sub></form><legend id='6ro4lqkg'></legend><bdo id='7nc97ehv'><pre id='d3fs1s2g'><center id='37s1oflm'></center></pre></bdo></b><th id='p0siop9t'></th></span></q></dt></tr></i><div id='kl3fpesj'><tfoot id='7jjt9by4'></tfoot><dl id='a5m4zpct'><fieldset id='6lk9fbdj'></fieldset></dl></div>

                  <tbody id='isezm3sy'></tbody>

                上一篇:Java七夕代码照片墙 java编程代码图片

                栏    目:Java编程

                下一篇:没有了

                本文标题:java项目完整代码 java项目 代码结构层次

                本文地址:https://www.xiuzhanwang.com/a1/Javabiancheng/17265.html

                网页制作CMS教程网络编程软件编程脚本语言数据库服务器

                如果侵犯了您的权利,请与我们联系,我们将在24小时内进行处理、任何非本站因素导致的法律后果,本站均不负任何责任。

                联系QQ:835971066 | 邮箱:835971066#qq.com(#换成@)

                Copyright © 2002-2020 脚本教程网 版权所有

                <tfoot id='mvnjkdx9'></tfoot>

                <small id='281eidhd'></small><noframes id='9zgogmzt'>

                  • <bdo id='3nyu7urd'></bdo><ul id='9nk51h86'></ul>
                  <i id='yyb2kina'><tr id='lzxonupc'><dt id='iqwlraaa'><q id='8luybm0p'><span id='oeasgb7n'><b id='nq8bfhn5'><form id='u7rbo7b9'><ins id='apkum08t'></ins><ul id='zxr0rnm6'></ul><sub id='h6ogbmym'></sub></form><legend id='l02p3tty'></legend><bdo id='xkou7wdb'><pre id='vy4c8yp6'><center id='7yt8nm0v'></center></pre></bdo></b><th id='uy91pydt'></th></span></q></dt></tr></i><div id='7m2hfuay'><tfoot id='u8heolux'></tfoot><dl id='ecoc1m39'><fieldset id='a5zeci0o'></fieldset></dl></div>
                  <legend id='valimtqx'><style id='ke2uygbe'><dir id='1a45ygk6'><q id='m2xzzbea'></q></dir></style></legend>