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

📄 i_p_lab2view.java

📁 encryption algorithm
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
/* * I_p_lab2View.java */package i_p_lab2;import java.util.logging.Level;import java.util.logging.Logger;import org.jdesktop.application.Action;import org.jdesktop.application.ResourceMap;import org.jdesktop.application.SingleFrameApplication;import org.jdesktop.application.FrameView;import org.jdesktop.application.TaskMonitor;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.io.File;import java.io.FileWriter;import java.io.IOException;import java.io.PrintWriter;import java.util.Scanner;import javax.swing.Timer;import javax.swing.Icon;import javax.swing.JDialog;import javax.swing.JFileChooser;import javax.swing.JFrame;/** * The application's main frame. */public class I_p_lab2View extends FrameView {         public static void WriteFile(String FileName,String Content) throws IOException       {           PrintWriter out = new PrintWriter(new FileWriter(FileName));           out.print(Content);           out.close();       }    public I_p_lab2View(SingleFrameApplication app) {        super(app);        initComponents();                        // status bar initialization - message timeout, idle icon and busy animation, etc        ResourceMap resourceMap = getResourceMap();        int messageTimeout = resourceMap.getInteger("StatusBar.messageTimeout");        messageTimer = new Timer(messageTimeout, new ActionListener() {            public void actionPerformed(ActionEvent e) {                statusMessageLabel.setText("");            }        });        messageTimer.setRepeats(false);        int busyAnimationRate = resourceMap.getInteger("StatusBar.busyAnimationRate");        for (int i = 0; i < busyIcons.length; i++) {            busyIcons[i] = resourceMap.getIcon("StatusBar.busyIcons[" + i + "]");        }        busyIconTimer = new Timer(busyAnimationRate, new ActionListener() {            public void actionPerformed(ActionEvent e) {                busyIconIndex = (busyIconIndex + 1) % busyIcons.length;                statusAnimationLabel.setIcon(busyIcons[busyIconIndex]);            }        });        idleIcon = resourceMap.getIcon("StatusBar.idleIcon");        statusAnimationLabel.setIcon(idleIcon);        progressBar.setVisible(false);        // connecting action tasks to status bar via TaskMonitor        TaskMonitor taskMonitor = new TaskMonitor(getApplication().getContext());        taskMonitor.addPropertyChangeListener(new java.beans.PropertyChangeListener() {            public void propertyChange(java.beans.PropertyChangeEvent evt) {                String propertyName = evt.getPropertyName();                if ("started".equals(propertyName)) {                    if (!busyIconTimer.isRunning()) {                        statusAnimationLabel.setIcon(busyIcons[0]);                        busyIconIndex = 0;                        busyIconTimer.start();                    }                    progressBar.setVisible(true);                    progressBar.setIndeterminate(true);                } else if ("done".equals(propertyName)) {                    busyIconTimer.stop();                    statusAnimationLabel.setIcon(idleIcon);                    progressBar.setVisible(false);                    progressBar.setValue(0);                } else if ("message".equals(propertyName)) {                    String text = (String)(evt.getNewValue());                    statusMessageLabel.setText((text == null) ? "" : text);                    messageTimer.restart();                } else if ("progress".equals(propertyName)) {                    int value = (Integer)(evt.getNewValue());                    progressBar.setVisible(true);                    progressBar.setIndeterminate(false);                    progressBar.setValue(value);                }            }        });                buttonGroup1.add(jRadioButton1);        buttonGroup1.add(jRadioButton3);        buttonGroup1.add(jRadioButton2);            }    @Action      /** This method is called from within the constructor to     * initialize the form.     * WARNING: Do NOT modify this code. The content of this method is     * always regenerated by the Form Editor.     */    @SuppressWarnings("unchecked")    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents    private void initComponents() {        mainPanel = new javax.swing.JPanel();        jLabel1 = new javax.swing.JLabel();        jTextField1 = new javax.swing.JTextField();        jButton1 = new javax.swing.JButton();        jButton2 = new javax.swing.JButton();        jButton3 = new javax.swing.JButton();        jLabel2 = new javax.swing.JLabel();        jTextField2 = new javax.swing.JTextField();        jRadioButton1 = new javax.swing.JRadioButton();        jRadioButton2 = new javax.swing.JRadioButton();        jRadioButton3 = new javax.swing.JRadioButton();        jLabel3 = new javax.swing.JLabel();        jTextField3 = new javax.swing.JTextField();        menuBar = new javax.swing.JMenuBar();        javax.swing.JMenu fileMenu = new javax.swing.JMenu();        javax.swing.JMenuItem exitMenuItem = new javax.swing.JMenuItem();        statusPanel = new javax.swing.JPanel();        javax.swing.JSeparator statusPanelSeparator = new javax.swing.JSeparator();        statusMessageLabel = new javax.swing.JLabel();        statusAnimationLabel = new javax.swing.JLabel();        progressBar = new javax.swing.JProgressBar();        buttonGroup1 = new javax.swing.ButtonGroup();        mainPanel.setName("mainPanel"); // NOI18N        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(i_p_lab2.I_p_lab2App.class).getContext().getResourceMap(I_p_lab2View.class);        jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N        jLabel1.setName("jLabel1"); // NOI18N        jTextField1.setText(resourceMap.getString("jTextField1.text")); // NOI18N        jTextField1.setName("jTextField1"); // NOI18N        jButton1.setText(resourceMap.getString("jButton1.text")); // NOI18N        jButton1.setName("jButton1"); // NOI18N        jButton1.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                jButton1ActionPerformed(evt);            }        });        jButton2.setText(resourceMap.getString("jButton2.text")); // NOI18N        jButton2.setName("jButton2"); // NOI18N        jButton2.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                jButton2ActionPerformed(evt);            }        });        jButton3.setText(resourceMap.getString("jButton3.text")); // NOI18N        jButton3.setName("jButton3"); // NOI18N        jButton3.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                jButton3ActionPerformed(evt);            }        });        jLabel2.setText(resourceMap.getString("jLabel2.text")); // NOI18N        jLabel2.setName("jLabel2"); // NOI18N        jTextField2.setText(resourceMap.getString("jTextField2.text")); // NOI18N        jTextField2.setName("jTextField2"); // NOI18N        jRadioButton1.setText(resourceMap.getString("jRadioButton1.text")); // NOI18N        jRadioButton1.setName("jRadioButton1"); // NOI18N        jRadioButton2.setText(resourceMap.getString("jRadioButton2.text")); // NOI18N        jRadioButton2.setName("jRadioButton2"); // NOI18N        jRadioButton3.setText(resourceMap.getString("jRadioButton3.text")); // NOI18N        jRadioButton3.setName("jRadioButton3"); // NOI18N        jLabel3.setText(resourceMap.getString("jLabel3.text")); // NOI18N        jLabel3.setName("jLabel3"); // NOI18N        jTextField3.setText(resourceMap.getString("jTextField3.text")); // NOI18N        jTextField3.setName("jTextField3"); // NOI18N        javax.swing.GroupLayout mainPanelLayout = new javax.swing.GroupLayout(mainPanel);        mainPanel.setLayout(mainPanelLayout);        mainPanelLayout.setHorizontalGroup(            mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)            .addGroup(mainPanelLayout.createSequentialGroup()                .addContainerGap()                .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)                    .addComponent(jLabel1)                    .addComponent(jLabel2)                    .addComponent(jLabel3)                    .addComponent(jRadioButton3)                    .addComponent(jRadioButton2)                    .addComponent(jRadioButton1))                .addGap(29, 29, 29)                .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)                    .addComponent(jButton3)                    .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)                        .addComponent(jTextField3, javax.swing.GroupLayout.Alignment.LEADING)                        .addComponent(jTextField2, javax.swing.GroupLayout.Alignment.LEADING)                        .addComponent(jTextField1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 86, Short.MAX_VALUE)                        .addComponent(jButton1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)                        .addComponent(jButton2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))                .addContainerGap(146, Short.MAX_VALUE))        );        mainPanelLayout.setVerticalGroup(            mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)            .addGroup(mainPanelLayout.createSequentialGroup()                .addContainerGap()                .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)                    .addComponent(jLabel1)                    .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))                .addGap(18, 18, 18)                .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)                    .addComponent(jLabel2)                    .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))                .addGap(20, 20, 20)                .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)                    .addComponent(jLabel3)                    .addComponent(jTextField3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))                .addGap(18, 18, 18)                .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)                    .addGroup(mainPanelLayout.createSequentialGroup()                        .addComponent(jRadioButton1)                        .addGap(63, 63, 63)                        .addComponent(jRadioButton3))                    .addGroup(mainPanelLayout.createSequentialGroup()                        .addGap(8, 8, 8)                        .addComponent(jButton1)                        .addGap(18, 18, 18)                        .addComponent(jButton2)                        .addGap(18, 18, 18)                        .addComponent(jButton3))                    .addGroup(mainPanelLayout.createSequentialGroup()                        .addGap(41, 41, 41)                        .addComponent(jRadioButton2)))                .addContainerGap(61, Short.MAX_VALUE))        );        menuBar.setName("menuBar"); // NOI18N        fileMenu.setText(resourceMap.getString("fileMenu.text")); // NOI18N        fileMenu.setName("fileMenu"); // NOI18N        javax.swing.ActionMap actionMap = org.jdesktop.application.Application.getInstance(i_p_lab2.I_p_lab2App.class).getContext().getActionMap(I_p_lab2View.class, this);        exitMenuItem.setAction(actionMap.get("quit")); // NOI18N        exitMenuItem.setName("exitMenuItem"); // NOI18N        fileMenu.add(exitMenuItem);        menuBar.add(fileMenu);        statusPanel.setName("statusPanel"); // NOI18N        statusPanelSeparator.setName("statusPanelSeparator"); // NOI18N        statusMessageLabel.setName("statusMessageLabel"); // NOI18N        statusAnimationLabel.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);        statusAnimationLabel.setName("statusAnimationLabel"); // NOI18N        progressBar.setName("progressBar"); // NOI18N        javax.swing.GroupLayout statusPanelLayout = new javax.swing.GroupLayout(statusPanel);        statusPanel.setLayout(statusPanelLayout);        statusPanelLayout.setHorizontalGroup(            statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)            .addComponent(statusPanelSeparator, javax.swing.GroupLayout.DEFAULT_SIZE, 433, Short.MAX_VALUE)            .addGroup(statusPanelLayout.createSequentialGroup()                .addContainerGap()                .addComponent(statusMessageLabel)                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 263, Short.MAX_VALUE)                .addComponent(progressBar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)                .addComponent(statusAnimationLabel)                .addContainerGap())        );        statusPanelLayout.setVerticalGroup(            statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)            .addGroup(statusPanelLayout.createSequentialGroup()                .addComponent(statusPanelSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, 2, javax.swing.GroupLayout.PREFERRED_SIZE)                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)                .addGroup(statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)                    .addComponent(statusMessageLabel)                    .addComponent(statusAnimationLabel)                    .addComponent(progressBar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))                .addGap(3, 3, 3))        );        setComponent(mainPanel);        setMenuBar(menuBar);        setStatusBar(statusPanel);    }// </editor-fold>//GEN-END:initComponents String s;    String st[];    int i; String matr[][]; String slovo; int razmer; String rezult="";   String str;   String strk="";   String slovo_sort="";   // str="абвгдежзиклмнопрстуфхцчшщъыьэюя., ";     private void matr_head() {   str="абвгдежзиклмнопрстуфхцчшщъыьэюя., ";               //создание матрицы     if (!(jTextField1.getText().equals(""))&&!(jTextField3.getText().equals(""))){slovo=jTextField1.getText(); razmer=Integer.parseInt(jTextField3.getText());    matr=new String [razmer][slovo.length()];           for (int i=0; i<slovo.length(); i++)    {matr[0][i]=slovo.substring(i,i+1);   // System.out.print(matr[0][i]+" ");

⌨️ 快捷键说明

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