📄 lose.java
字号:
//package library2;import java.awt.BorderLayout;import javax.swing.JFrame;import javax.swing.JLabel;import java.awt.*;import javax.swing.JButton;import javax.swing.JTextField;import javax.swing.JCheckBox;import javax.swing.JTextArea;import javax.swing.JToggleButton;import java.io.*;import java.text.*;import java.awt.event.*;import java.awt.*;import java.util.*;import javax.swing.*;/** * <p>Title: </p> * * <p>Description: </p> * * <p>Copyright: Copyright (c) 2005</p> * * <p>Company: </p> * * @author not attributable * @version 1.0 */public class lose extends JFrame implements ActionListener{ JLabel jLabel1 = new JLabel(); JButton 确定 = new JButton(); JButton 取消 = new JButton(); public lose() { try { jbInit(); } catch (Exception exception) { exception.printStackTrace(); } } private void jbInit() throws Exception { setTitle("英语一百"); getContentPane().setLayout(null); setSize(300,150); jLabel1.setText("确定要删除您的信息吗?"); jLabel1.setBounds(new Rectangle(63, 7, 159, 42)); 取消.setBounds(new Rectangle(44, 69, 77, 30)); 取消.setText("取消");取消.addActionListener(this); this.getContentPane().add(取消); this.getContentPane().add(确定); this.getContentPane().add(jLabel1); 确定.setBounds(new Rectangle(147, 69, 77, 30)); 确定.setText("确定");确定.addActionListener(this); setVisible(true); setDefaultCloseOperation(EXIT_ON_CLOSE); } public static void main(String[] args) throws IOException { lose lose_object = new lose(); } public void actionPerformed(ActionEvent e) { if(e.getActionCommand().equals("确定")) { try{ setVisible(false); boolean juge = false; String str = custom.custom_name + " " + custom.custom_id; //str1 = tokenizer.nextToken(";"); BufferedReader inFile = new BufferedReader (new FileReader("custom.txt")); FileWriter outData = new FileWriter("副本.txt"); PrintWriter outFile = new PrintWriter(outData); String custom_information = inFile.readLine(); while(custom_information != null) { if(str.equals(custom_information)) { juge = true; break; } else { outFile.println(custom_information); custom_information = inFile.readLine(); } } if(custom_information != null) { File file_object = new File (custom.custom_name + ".txt"); file_object.delete(); custom_information = inFile.readLine(); while(custom_information != null) { outFile.println(custom_information); custom_information = inFile.readLine(); } outFile.close(); BufferedReader inFile2 = new BufferedReader (new FileReader("副本.txt")); PrintWriter outFile2 = new PrintWriter (new FileWriter("custom.txt")); str = inFile2.readLine(); while(str != null) { outFile2.println(str); str = inFile2.readLine(); } outFile2.close(); JOptionPane.showMessageDialog(null, "您的信息已成功删除", "output", JOptionPane.PLAIN_MESSAGE); } else { JOptionPane.showMessageDialog(null, "您还没有注册!", "output", JOptionPane.PLAIN_MESSAGE); } } catch (FileNotFoundException er) { System.exit(0); } catch(IOException er) { System.exit(0); } } else if(e.getActionCommand().equals("取消")) { setVisible(false); } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -