zoukankan      html  css  js  c++  java
  • 字符查找的界面建立

    import java.awt.Button;
    import java.awt.Color;
    import java.awt.FlowLayout;
    import java.awt.Frame;
    import java.awt.GridLayout;
    import java.awt.Label;
    import java.awt.Panel;
    import java.awt.TextField;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;

    import javax.swing.JOptionPane;


    public class QueryMFrame extends Frame implements ActionListener {
    TextField tfdName,tfdUnicode;
    Button btn1,btn2,btn3;
    public QueryMFrame(String str)
    {setTitle(str);
    setBounds(100,200,300,300);
    setLayout(new GridLayout(3,1));
    setBackground(Color.CYAN);


    Panel p1=new Panel();
    p1.setLayout(new FlowLayout(FlowLayout.RIGHT));
    p1.add(new Label("字符"));
    tfdName=new TextField(20);
    p1.add(tfdName);
    add(p1);

    Panel p2=new Panel();
    p2.setLayout(new FlowLayout(FlowLayout.RIGHT));
    p2.add( new Label("Unicode码"));
    tfdUnicode=new TextField(20);
    p2.add(tfdUnicode);
    add(p2);


    Panel p3=new Panel();
    btn1=new Button("查询Unicode");
    btn2=new Button("查询字符");
    btn3=new Button("EXIT");
    btn3.setActionCommand("EX");
    p3.add(btn1);
    p3.add(btn2);
    p3.add(btn3);
    add(p3);


    btn1.addActionListener(this);
    btn2.addActionListener(this);
    btn3.addActionListener(this);

    setVisible(true);



    }

    public static void main(String[] args) {
    new QueryMFrame("华南城市学院");

    }
    public void actionPerformed(ActionEvent e) {
    if(e.getSource()==btn1){
    String str=tfdName.getText();
    char ch=str.charAt(0);
    tfdUnicode.setText(""+(int)ch);

    }
    if(e.getSource()==btn2){
    String str=tfdUnicode.getText();
    try{
    int n=Integer.parseInt(str);
    tfdName.setText(""+(char)n);

    }catch(NumberFormatException e1){
    JOptionPane.showMessageDialog( this, str+"不是整数,无法查询Unicode码");

    }

    }
    if(e.getActionCommand().equals("EX")){
    System.exit(0);

    }



    }

    }

  • 相关阅读:
    文件系列--截取路径字符串,获取文件名
    ASP.NET State Service (ASP.NET 状态服务)已启动,并且客户端端口与服务器端口相同
    大小写字母,特殊字符,数字,四选一组合或者全组合,长度至少八位,验证
    设计模式-23种设计模式介绍
    &和&&区别
    GridView中Button多参数传参
    HTTP 错误 500.19
    Windows系统添加端口号
    win10安装IIS服务
    2019最新整理PHP面试题附答案
  • 原文地址:https://www.cnblogs.com/1314wamm/p/5603424.html
Copyright © 2011-2022 走看看