⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bijiao.java

📁 一些平时可能用到的工具,比如导出数据,比较数据
💻 JAVA
字号:
package gongju;

import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextPane;

/**
 * This code was edited or generated using CloudGarden's Jigloo SWT/Swing GUI
 * Builder, which is free for non-commercial use. If Jigloo is being used
 * commercially (ie, by a corporation, company or business for any purpose
 * whatever) then you should purchase a license for each developer using Jigloo.
 * Please visit www.cloudgarden.com for details. Use of Jigloo implies
 * acceptance of these licensing terms. A COMMERCIAL LICENSE HAS NOT BEEN
 * PURCHASED FOR THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED LEGALLY FOR
 * ANY CORPORATE OR COMMERCIAL PURPOSE.
 */
//比较两个文本是否相同
public class Bijiao extends JFrame {
	private JPanel jPanel1;

	private JPanel timePane;

	private JTextArea jTextArea3;

	private JScrollPane jScrollPane2;

	private JScrollPane jScrollPane1;

	private JTextPane jTextPane2;

	private JTextPane jTextPane1;

	private JButton jButton3;

	private JButton jButton2;

	private JButton jButton1;

	private JLabel jLabel2;

	private JLabel jLabel1;

	private Showtime showtime;

	public Bijiao() {
		initGUI();
		Exit();
	}

	public void Exit() {
		this.addWindowListener(new WindowAdapter() {
			public void windowClosing(WindowEvent evt) {
				// System.exit(0);
				showtime.stop();
				dispose();
			}
		});
	}

	public static void main(String args[]) {
		new Bijiao();
	}

	private void initGUI() {
		try {
			{
				this.setSize(800, 600);
			}
			setVisible(true);
			{
				jPanel1 = new JPanel();
				getContentPane().add(jPanel1, BorderLayout.CENTER);
				jPanel1.setPreferredSize(new java.awt.Dimension(889, 630));
				jPanel1.setLayout(null);
				{
					jLabel1 = new JLabel();
					jPanel1.add(jLabel1);
					jLabel1.setText("\u6587\u672c\u4e00");
					jLabel1.setBounds(119, 7, 133, 28);
				}
				{
					jLabel2 = new JLabel();
					jPanel1.add(jLabel2);
					jLabel2.setText("\u6587\u672c\u4e8c");
					jLabel2.setBounds(574, 7, 154, 28);
				}
				{
					jButton1 = new JButton();
					jPanel1.add(jButton1);
					jButton1.setText("\u6bd4\u8f83");
					jButton1.setBounds(322, 497, 126, 28);
					jButton1.addActionListener(new ActionListener() {
						public void actionPerformed(ActionEvent evt) {
							String aa = jTextPane1.getText();
							String bb = jTextPane2.getText();
							String ee = "";
							String ff = "";
							StringBuffer sb1 = new StringBuffer();
							StringBuffer sb2 = new StringBuffer();
							ee = aa.replaceAll(" ", "");
							aa = ee.replaceAll("\r", "");
							ee = aa.replaceAll("\n", "");
							ff = bb.replaceAll(" ", "");
							bb = ff.replaceAll("\r", "");
							ff = bb.replaceAll("\n", "");
							if (ee.equalsIgnoreCase(ff)) {
								jTextArea3.setText("\u76f8\u540c");
							} else {
								jTextArea3.setText("\u4e0d\u540c");
								int i = ee.length();
								int j = ff.length();
								int k = i - j;
								// 1比2长
								if (k > 0) {
									for (int l = 0; l < j; l++) {
										if (ee.charAt(l) != ff.charAt(l)) {
											sb1.append(ee.charAt(l));// 存放1中的不同字符
											sb2.append(ff.charAt(l));// 存放2中的不同字符
										}
									}
									sb1.append(ee.substring(j));
								}
								// 2比1长
								else {
									for (int l = 0; l < i; l++) {
										if (ee.charAt(l) != ff.charAt(l)) {
											sb1.append(ee.charAt(l));// 存放1中的不同字符
											sb2.append(ff.charAt(l));// 存放2中的不同字符
										}
									}
									sb2.append(ff.substring(i));
								}
							}
							System.out.print(ee + "\n");
							// jTextArea1.setText(ee);
							System.out.print(ff + "\n");
							// jTextArea2.setText(ff);
							System.out.print(sb1.toString() + "\n");
							System.out.print(sb2.toString() + "\n");
						}
					});
				}
				{
					jButton2 = new JButton();
					jPanel1.add(jButton2);
					jButton2.setText("\u6e05\u7a7a");
					jButton2.setBounds(112, 497, 126, 28);
					jButton2.addActionListener(new ActionListener() {
						public void actionPerformed(ActionEvent evt) {
							jTextPane1.setText("");
							jTextArea3.setText("");
						}
					});
				}
				{
					jButton3 = new JButton();
					jPanel1.add(jButton3);
					jButton3.setText("\u6e05\u7a7a");
					jButton3.setBounds(532, 497, 112, 28);
					jButton3.addActionListener(new ActionListener() {
						public void actionPerformed(ActionEvent evt) {
							jTextPane2.setText("");
						}
					});
				}
				{
					jScrollPane1 = new JScrollPane();
					jPanel1.add(jScrollPane1);
					jScrollPane1.setBounds(21, 49, 343, 434);
					{
						jTextPane1 = new JTextPane();
						jScrollPane1.setViewportView(jTextPane1);
						jTextPane1.setBounds(455, 14, 329, 434);
					}
				}
				{
					jScrollPane2 = new JScrollPane();
					jPanel1.add(jScrollPane2);
					jScrollPane2.setBounds(413, 49, 357, 434);
					{
						jTextPane2 = new JTextPane();
						jScrollPane2.setViewportView(jTextPane2);
						jTextPane2.setBounds(448, 532, 343, 14);
					}
				}
				{
					jTextArea3 = new JTextArea();
					jPanel1.add(jTextArea3);
					jTextArea3.setBounds(364, 203, 49, 35);
				}
				{
					showtime = new Showtime();
					timePane = new JPanel();
					CardLayout timePaneLayout = new CardLayout();
					timePane.setLayout(timePaneLayout);
					jPanel1.add(timePane);
					timePane.setBounds(343, 0, 84, 42);
					timePane.add(showtime, "showtime");
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -