现在已经取得了 两个文本的路径
然后需要什么知识点复制过来呢 
其实算是截取 
例如文本1-----2,3,4,5,6 
在自己做的界面输入3个逗号 
截取在文本2----得到的是4

解决方案 »

  1.   

     import java.awt.FileDialog;
    public class NewJFrame extends javax.swing.JFrame {
        public FileDialog fsave;  //windows对话框
        public FileDialog fload;    /** Creates new form NewJFrame */
        public NewJFrame() {
            initComponents();
            aaa();
        }    private void aaa() {        fload = new FileDialog(this, "Open", FileDialog.LOAD);
            fsave = new FileDialog(this, "Save", FileDialog.SAVE);
        }    @SuppressWarnings("unchecked")
        // <editor-fold defaultstate="collapsed" desc="Generated Code">
        private void initComponents() {        textField1 = new java.awt.TextField();//打开路径
            textField2 = new java.awt.TextField();//保存到路径
            jButton1 = new javax.swing.JButton();//打开
            jButton2 = new javax.swing.JButton();//保存到
            jRadioButton1 = new javax.swing.JRadioButton();//逗号
            jRadioButton2 = new javax.swing.JRadioButton();//TAB
            textField3 = new java.awt.TextField();//这在里添加数字,选择逗号后写入数字,后处理,选择TAB同理
            label1 = new java.awt.Label();
            jButton3 = new javax.swing.JButton();//保存        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);       //还有些关于按钮之类设置 太长下边添加
            pack();
        }// </editor-fold>  
        private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//监听打开按钮
            fload.setVisible(true);
            String name = fload.getFile();
            String name1 = fload.getDirectory();
            if (name != null) {
                textField1.setText(name1 + name);//得到打开文件的路径
            } else {
                textField2.setText(" null");
            }
        }    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//监听保存到按钮
            fsave.setVisible(true);
            String name = fsave.getFile();
            String name1 = fsave.getDirectory();
            if (name != null) {
                textField1.setText(name1 + name);//得到保存到文件的路径
            } else {
                textField2.setText(" null");
            }
        }
      private void jRadioButton1ActionPerformed(java.awt.event.ActionEvent evt) {
        //在这里就是得到选择逗号隔开,没用过,不知道怎么办呢
    }    private void jRadioButton2ActionPerformed(java.awt.event.ActionEvent evt) {
            // TODO add your handling code here:  //同上    }    private void textField3ActionPerformed(java.awt.event.ActionEvent evt) {
            // TODO add your handling code here://这里就是添加数字,对以上两个符号的个数
        }    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
            // TODO add your handling code here://保存  就是把打开的文件内容保存到文件2内容,内容有所改变,
    被符号给截取了,
        }    public static void main(String args[]) {
            java.awt.EventQueue.invokeLater(new Runnable() {            public void run() {
                    new NewJFrame().setVisible(true);
                }
            });
        }    // Variables declaration - do not modify
        private javax.swing.JButton jButton1;
        private javax.swing.JButton jButton2;
        private javax.swing.JButton jButton3;
        private javax.swing.JRadioButton jRadioButton1;
        private javax.swing.JRadioButton jRadioButton2;
        private java.awt.Label label1;
        private java.awt.TextField textField1;
        private java.awt.TextField textField2;
        private java.awt.TextField textField3;
        // End of variables declaration
    }
    谢谢  这个应该怎么实现呢
      

  2.   

     jButton1.setText("open");
            jButton1.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jButton1ActionPerformed(evt);
                }
            });        jButton2.setText("save");
            jButton2.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jButton2ActionPerformed(evt);
                }
            });        jRadioButton1.setText("カンマ");
            jRadioButton1.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jRadioButton1ActionPerformed(evt);
                }
            });        jRadioButton2.setText("タブー");
            jRadioButton2.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jRadioButton2ActionPerformed(evt);
                }
            });        textField3.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    textField3ActionPerformed(evt);
                }
            });        label1.setText("個目を出力する。");        jButton3.setText("出力");
            jButton3.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jButton3ActionPerformed(evt);
                }
            });        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
            getContentPane().setLayout(layout);
            layout.setHorizontalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(layout.createSequentialGroup()
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(layout.createSequentialGroup()
                                    .addGap(24, 24, 24)
                                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                        .addComponent(textField2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .addComponent(textField1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 106, Short.MAX_VALUE)))
                                .addGroup(layout.createSequentialGroup()
                                    .addComponent(jRadioButton1)
                                    .addGap(18, 18, 18)
                                    .addComponent(jRadioButton2)))
                            .addGap(33, 33, 33)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(layout.createSequentialGroup()
                                    .addComponent(textField3, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(label1, javax.swing.GroupLayout.PREFERRED_SIZE, 91, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addComponent(jButton2)
                                .addComponent(jButton1)))
                        .addGroup(layout.createSequentialGroup()
                            .addGap(95, 95, 95)
                            .addComponent(jButton3)))
                    .addContainerGap(37, Short.MAX_VALUE))
            );
            layout.setVerticalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                    .addGap(29, 29, 29)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(textField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jButton1))
                    .addGap(31, 31, 31)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(jButton2)
                        .addComponent(textField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(layout.createSequentialGroup()
                            .addGap(24, 24, 24)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jRadioButton1)
                                .addComponent(jRadioButton2)))
                        .addGroup(layout.createSequentialGroup()
                            .addGap(22, 22, 22)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(label1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(textField3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                    .addGap(18, 18, 18)
                    .addComponent(jButton3)
                    .addContainerGap(12, Short.MAX_VALUE))
            );