zoukankan      html  css  js  c++  java
  • 左边窗口内容复制到右边窗口--简单

    package copy.com;

    import java.awt.BorderLayout;

    import java.awt.event.*;

    import java.awt.Color;

    import java.awt.GridLayout;

    import java.awt.event.ActionEvent;

    import javax.swing.*;

    import javax.swing.JFrame;

    import javax.swing.JTextField;

    import javax.swing.JButton;

    public class copy extends JFrame{

      JButton b;

      JTextField L,R;

      public void display()

      {

        JPanel f=new JPanel(new GridLayout(1,2));

        f.setSize(300,100);

        f.setBackground(Color.lightGray);

        L=new JTextField();

        R=new JTextField();

        f.add(L);

        f.add(R);

        b=new JButton("复制");

        this.add(f);

        this.add(b,BorderLayout.SOUTH);

        this.setTitle("复制");

        this.setBounds(300,200,380,120);

        this.setDefaultCloseOperation(EXIT_ON_CLOSE);

        this.setVisible(true);

        b.addActionListener(new ActionListener()

        {

          public void actionPerformed(ActionEvent e)

          {

            String str=L.getText();  //读取左边字符

            R.setText(str);   //左边字符复制到右边

          }

        });

      }

      public static void main(String []args)

      {

        copy m=new copy();

        m.display();

      }

    }

    运行结果:

  • 相关阅读:
    Python 中多线程之 _thread
    Python ftplib 模块关于 ftp的下载
    nessus 漏洞扫描安装和使用
    实战medusa暴力破解
    浅谈python 中正则的一些函数
    一句话木马和中国菜刀的结合拿webshell
    浅说套接字socket做个小小的监控
    小巧的ssh客户端
    统计字符串的数字,英文字母,空格及其他的个数
    mysql字符串函数
  • 原文地址:https://www.cnblogs.com/duanqibo/p/11134025.html
Copyright © 2011-2022 走看看