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

📄 dsblmainframe.java

📁 JAVA开发的
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
package ly.util;

import java.io.*;
import java.sql.Date;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.GridBagLayout;
import java.awt.GridBagConstraints;
import java.awt.Toolkit;
import javax.swing.*;
import javax.swing.text.*;
import javax.swing.JLabel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import java.sql.*;
import javax.swing.JButton;
import javax.swing.JPopupMenu;
import javax.swing.JMenuItem;
import javax.swing.table.DefaultTableModel;
import java.security.*;
import java.security.spec.RSAPublicKeySpec;
import java.security.spec.RSAPrivateKeySpec;
import java.security.spec.InvalidKeySpecException;
import java.security.interfaces.RSAPrivateKey;
import java.security.interfaces.RSAPublicKey;
import javax.swing.JTextField;

public class DSBLMainFrame extends JFrame {
	
	public SimpleAttributeSet sas = new SimpleAttributeSet();
	
	private jtableMouseListener jml1=new jtableMouseListener(this);
	
	private jtable1MouseListener jml2=new jtable1MouseListener(this);
	
	private File fc;
	
	private RSAPublicKey pubKey =null;
	private RSAPrivateKey priKey =null;
	
	private RSAPublicKey recoveryPubKey =null;
	private RSAPrivateKey recoveryPriKey = null;

	private RSAPublicKey inspectPubKey=null;
	
	private Connection con;
	
	private JPanel jContentPane = null;

	private JScrollPane jScrollPane = null;

	private JTextPane jTextPane = null;

	private JPopupMenu jPopupMenu = null; // @jve:decl-index=0:visual-constraint="653,293"

	private JMenuItem jMenuItem = null;

	private JTabbedPane jTabbedPane = null;

	private JPanel jPanel = null;

	private JPanel jPanel2 = null;

	private JPanel jPanel3 = null;

	private JLabel jLabel = null;

	private JLabel jLabel1 = null;

	private JScrollPane jScrollPane1 = null;

	private JTextPane jTextPane1 = null;

	private JButton jButton = null;

	private JLabel jLabel2 = null;

	private JTextField jTextField = null;

	private JLabel jLabel3 = null;

	private JButton jButton1 = null;

	private JButton jButton2 = null;

	private JMenuItem jMenuItem1 = null;

	private JLabel jLabel4 = null;

	private JScrollPane jScrollPane2 = null;

	public JTable jTable = null;

	private JPopupMenu jPopupMenu1 = null; // @jve:decl-index=0:visual-constraint="628,207"

	private JMenuItem jMenuItem2 = null;

	private JMenuItem jMenuItem3 = null;

	private JMenuItem jMenuItem4 = null;

	private JMenuItem jMenuItem5 = null;

	private JMenuItem jMenuItem6 = null;

	private JMenuItem jMenuItem7 = null;

	private JMenuItem jMenuItem8 = null;

	private JMenuItem jMenuItem9 = null;

	private JLabel jLabel5 = null;

	private JTextField jTextField1 = null;

	private JLabel jLabel7 = null;

	private JTextField jTextField3 = null;

	private JButton jButton4 = null;

	private JButton jButton5 = null;

	private JTextField jTextField4 = null;

	private JLabel jLabel8 = null;

	private JButton jButton6 = null;

	private JLabel jLabel6 = null;

	private JScrollPane jScrollPane3 = null;

	public JTable jTable1 = null;

	private JLabel jLabel9 = null;

	private JTextField jTextField2 = null;

	private JButton jButton3 = null;

	private JLabel jLabel10 = null;

	private JTextField jTextField5 = null;

	private JButton jButton7 = null;

	private JLabel jLabel11 = null;

	private JTextField jTextField6 = null;

	private JButton jButton8 = null;

	private JButton jButton9 = null;

	private JPopupMenu jPopupMenu2 = null;  //  @jve:decl-index=0:visual-constraint="647,114"

	private JMenuItem jMenuItem10 = null;

	private JMenuItem jMenuItem11 = null;

	private JMenuItem jMenuItem12 = null;

	private JMenuItem jMenuItem13 = null;

	private JMenuItem jMenuItem14 = null;

	private JMenuItem jMenuItem15 = null;

	/**
	 * This is the default constructor
	 */
	public DSBLMainFrame() {
		super();
		initialize();
	}

	/**
	 * This method initializes this
	 * 
	 * @return void
	 */
	private void initialize() {
		this.setSize(594, 438);
		this.con=this.getConnection();
		this.setContentPane(getJContentPane());
		this.setResizable(false);
		this.setTitle("简单数字签名DEMO   贵大2005级研究生刘胤");

		this.addWindowListener(new java.awt.event.WindowAdapter() {
			public void windowClosing(java.awt.event.WindowEvent e) {
				System.exit(0); 
			}
		});
	}
	
	public Connection getConnection(){
		if(con==null){
		try{
		String conURL = "jdbc:odbc:driver={MicroSoft Access Driver (*.mdb)};DBQ=db\\MyRSAStore.mdb";
		String password = "123";
		Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
		Connection con1 = DriverManager.getConnection(conURL, password,password);
		return con1;
		}catch(Exception e2){
			System.out.println(e2);
		}
		}
		return con;
	}
	/**
	 * This method initializes jContentPane
	 * 
	 * @return javax.swing.JPanel
	 */
	private JPanel getJContentPane() {
		if (jContentPane == null) {
			jContentPane = new JPanel();
			jContentPane.setLayout(null);
			jContentPane.setBackground(new java.awt.Color(238, 238, 238));
			jContentPane.add(getJScrollPane(), null);
			jContentPane.add(getJTabbedPane(), null);
		}
		return jContentPane;
	}

	/**
	 * This method initializes jScrollPane
	 * 
	 * @return javax.swing.JScrollPane
	 */
	private JScrollPane getJScrollPane() {
		if (jScrollPane == null) {
			jScrollPane = new JScrollPane();
			jScrollPane.setBounds(new java.awt.Rectangle(4, 288, 581, 121));
			jScrollPane.setViewportView(getJTextPane());
		}
		return jScrollPane;
	}

	/**
	 * This method initializes jTextPane
	 * 
	 * @return javax.swing.JTextPane
	 */
	public JTextPane getJTextPane() {
		if (jTextPane == null) {
			jTextPane = new JTextPane();
			jTextPane.setEditable(false);
			jTextPane.addMouseListener(new MyMouseListener(this));
		}
		return jTextPane;
	}

	/**
	 * This method initializes jPopupMenu
	 * 
	 * @return javax.swing.JPopupMenu
	 */
	private JPopupMenu getJPopupMenu() {
		if (jPopupMenu == null) {
			jPopupMenu = new JPopupMenu();
			jPopupMenu.add(getJMenuItem());
			jPopupMenu.addSeparator();
			jPopupMenu.add(getJMenuItem1());
		}
		return jPopupMenu;
	}

	/**
	 * This method initializes jMenuItem
	 * 
	 * @return javax.swing.JMenuItem
	 */
	private JMenuItem getJMenuItem() {
		if (jMenuItem == null) {
			jMenuItem = new JMenuItem();
			jMenuItem.setText("清空记录");
			jMenuItem.addActionListener(new MyJMenuItemActionListener(this));
		}
		return jMenuItem;
	}

	private class MyMouseListener extends java.awt.event.MouseAdapter {
		private DSBLMainFrame father;

		MyMouseListener(DSBLMainFrame f) {
			super();
			father = f;
		}

		public void mouseClicked(java.awt.event.MouseEvent e) {
			if (e.getButton() == java.awt.event.MouseEvent.BUTTON3) {
				father.getJPopupMenu().show(e.getComponent(), e.getX(),
						e.getY());
			}
		}
	}

	private class jtableMouseListener extends java.awt.event.MouseAdapter {
		private DSBLMainFrame father;

		jtableMouseListener(DSBLMainFrame f) {
			super();
			father = f;
		}

		public void mouseClicked(java.awt.event.MouseEvent e) {
			
			if (e.getButton() == java.awt.event.MouseEvent.BUTTON3) {
				int i[]=father.getJTable().getSelectedRows();
				
				if(i.length==0){
					father.getJMenuItem3().setEnabled(false);
					father.getJMenuItem8().setEnabled(false);
					father.getJMenuItem6().setEnabled(false);
					father.getJMenuItem7().setEnabled(false);
					father.getJMenuItem3().setEnabled(false);
					father.getJMenuItem9().setEnabled(false);
				}
				if(i.length>0){
					father.getJMenuItem3().setEnabled(true);
					father.getJMenuItem3().setText("删除这"+i.length+"行");
					if(i.length>1) {
						father.getJMenuItem8().setEnabled(false);
						father.getJMenuItem6().setEnabled(false);
						father.getJMenuItem7().setEnabled(false);
						father.getJMenuItem9().setEnabled(false);
					}else {
						father.getJMenuItem8().setEnabled(true);
						father.getJMenuItem6().setEnabled(true);
						father.getJMenuItem7().setEnabled(true);
						father.getJMenuItem9().setEnabled(true);
					}
					/*
				for(int j=0;j<i.length;j++){
					for(int k=0;k<5;k++){
					if(father.getJTable().getCellRect(i[j],k,true).contains(e.getPoint())) {
						father.getJMenuItem3().setText("删除这"+i.length+"行");
						
						
						flag=1;
						break;
					}
					}
					if(flag==1) break;
				}
				if(flag==0) {
					father.getJMenuItem3().setText("删除行");
					father.getJMenuItem3().setEnabled(false);
				}
				*/
				}
				father.getJPopupMenu1().show(e.getComponent(), e.getX(),
						e.getY());
			}
		}
	}

	private class MyJMenuItemActionListener implements
			java.awt.event.ActionListener {
		private DSBLMainFrame father;

		MyJMenuItemActionListener(DSBLMainFrame f) {
			super();
			father = f;
		}

		public void actionPerformed(java.awt.event.ActionEvent e) {
			try {
				father.getJTextPane().setText("");
			} catch (Exception e1) {
				System.out.println(e1);
			}
		}
	}

	private class ICActionListener implements java.awt.event.ActionListener {
		private DSBLMainFrame father;

		ICActionListener(DSBLMainFrame f) {
			super();
			father = f;
		}

		public void actionPerformed(java.awt.event.ActionEvent e) {
			try {
				
				lyMD5 md5 = new lyMD5();
				String md5digest = md5.getMD5Digest(father.getJTextPane1()
						.getText());
				// java.sql.Date dtmp=new java.sql.Date(new
				// java.util.Date().getTime());
				father.getJTextPane().getDocument().insertString(
						father.getJTextPane().getDocument().getLength(),
						"(" + new java.util.Date() + ":)文本消息摘要=" + md5digest
								+ "\n", sas);
			} catch (Exception e1) {
				System.out.println(e1);
			}
		}
	}

	private class MyJMenuItem1ActionListener implements
			java.awt.event.ActionListener {
		private DSBLMainFrame father;

		MyJMenuItem1ActionListener(DSBLMainFrame f) {
			super();
			father = f;
		}

		public void actionPerformed(java.awt.event.ActionEvent e) {
			JFileChooser fileChooser = new JFileChooser();
			fileChooser.setFileFilter(new JAVAFileFilter("txt"));
			fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
			int result = fileChooser.showSaveDialog(father);
			if (result == JFileChooser.APPROVE_OPTION) {
				File f = fileChooser.getSelectedFile();
				String fileName=f.getName();
				int index=fileName.lastIndexOf('.');

⌨️ 快捷键说明

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