2021-05-21

这里给大家一些关于用数据流实现一个登录,注册的窗口

package bb;

import java.awt.GridLayout;
import java.awt.HeadlessException;
import java.awt.Label;
import java.awt.TextField;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;

import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPasswordField;

public class de4 {
    
    public void xie(String s,String s1)
    {
        
        File f=new File("tes.txt");
        FileOutputStream fos=null;
        try {
            fos=new FileOutputStream(f,true);
            byte[] b1=s.getBytes();
            
            byte[] b2=s1.getBytes();
            fos.write(b1);

            fos.write(b2);
            fos.write("\n".getBytes());
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }finally
        {
            try {
                fos.close();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
        
    }
    public boolean  duqu(String ss,String ss1) throws FileNotFoundException
    {
        BufferedReader breader=null;
        InputStream is = new FileInputStream(new File("tes.txt"));

        try {
            breader=new BufferedReader(new InputStreamReader(is));
            String bb=new String();
            bb=ss+ss1;
            
            try {
                if(bb.equals(breader.readLine()))
                {
                    return false;
                }
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }finally
        {
            try {
                
                breader.close();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
        return true;//没有匹配的
        
    }
    public void window()
    {
        JFrame f=new JFrame("小窗口");
        JPanel p1=new JPanel();
        JOptionPane jop=new JOptionPane();
        Label l1=new Label("用户名");
        TextField t1=new TextField(14);
        p1.add(l1);
        p1.add(t1);
        
        JPanel p2=new JPanel();
        Label l2=new Label("密码");
        JPasswordField t2=new JPasswordField(10);
        p2.add(l2);
        p2.add(t2);
        
        JButton b1=new JButton("注册");
        JButton b2=new JButton("登录");
        JPanel p3=new JPanel();
        p3.add(b1);
        p3.add(b2);
        
        f.setLayout(new GridLayout(3,1));
        
        f.add(p1);
        f.add(p2);
        f.add(p3);
        
        //对按钮设置监听器
        b1.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                // TODO Auto-generated method stub
                String s=t1.getText();
                String s1= new String(t2.getPassword());
                try {
                    if(duqu(s,s1)==false)
                    {
                        jop.showMessageDialog(null, "已经有该用户");
                    }
                    else
                    {
                        jop.showMessageDialog(null, "注册成功");
                    }
                } catch (HeadlessException e1) {
                    // TODO Auto-generated catch block
                    e1.printStackTrace();
                } catch (FileNotFoundException e1) {
                    // TODO Auto-generated catch block
                    e1.printStackTrace();
                }
                xie(s,s1);
            }
            
        });
        b2.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                // TODO Auto-generated method stub
                String s=t1.getText();
                String s1= new String(t2.getPassword());
                try {
                    if(duqu(s,s1)==false)
                    {
                        jop.showMessageDialog(null, "恭喜你登录成功");
                    }
                    else
                    {
                        jop.showMessageDialog(null, "用户名或密码错误");
                    }
                } catch (HeadlessException e1) {
                    // TODO Auto-generated catch block
                    e1.printStackTrace();
                } catch (FileNotFoundException e1) {
                    // TODO Auto-generated catch block
                    e1.printStackTrace();
                }
            }
            
        });
        
        f.setLocation(500, 100);
        f.setSize(300,200);
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        f.setVisible(true);
        
    }
    public static void main(String[] args) {
        de4 de=new de4();
        de.window();
    }
}
这边主要是通过一些简单的方法来实现,具体的功能还没去实现,可以供大家参考。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
2021-03-26 20:54:33,596 - Model - INFO - Epoch 1 (1/200): 2021-03-26 20:57:40,380 - Model - INFO - Train Instance Accuracy: 0.571037 2021-03-26 20:58:16,623 - Model - INFO - Test Instance Accuracy: 0.718528, Class Accuracy: 0.627357 2021-03-26 20:58:16,623 - Model - INFO - Best Instance Accuracy: 0.718528, Class Accuracy: 0.627357 2021-03-26 20:58:16,623 - Model - INFO - Save model... 2021-03-26 20:58:16,623 - Model - INFO - Saving at log/classification/pointnet2_msg_normals/checkpoints/best_model.pth 2021-03-26 20:58:16,698 - Model - INFO - Epoch 2 (2/200): 2021-03-26 21:01:26,685 - Model - INFO - Train Instance Accuracy: 0.727947 2021-03-26 21:02:03,642 - Model - INFO - Test Instance Accuracy: 0.790858, Class Accuracy: 0.702316 2021-03-26 21:02:03,642 - Model - INFO - Best Instance Accuracy: 0.790858, Class Accuracy: 0.702316 2021-03-26 21:02:03,642 - Model - INFO - Save model... 2021-03-26 21:02:03,643 - Model - INFO - Saving at log/classification/pointnet2_msg_normals/checkpoints/best_model.pth 2021-03-26 21:02:03,746 - Model - INFO - Epoch 3 (3/200): 2021-03-26 21:05:15,349 - Model - INFO - Train Instance Accuracy: 0.781606 2021-03-26 21:05:51,538 - Model - INFO - Test Instance Accuracy: 0.803641, Class Accuracy: 0.738575 2021-03-26 21:05:51,538 - Model - INFO - Best Instance Accuracy: 0.803641, Class Accuracy: 0.738575 2021-03-26 21:05:51,539 - Model - INFO - Save model... 2021-03-26 21:05:51,539 - Model - INFO - Saving at log/classification/pointnet2_msg_normals/checkpoints/best_model.pth 我有类似于这样的一段txt文件,请你帮我写一段代码来可视化这些训练结果
02-06

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值