学习2

来源:互联网 发布:淘宝网免费开店流程 编辑:程序博客网 时间:2024/05/16 00:37

1.myEvent()

2.button2.addActionListener(new ActionListener()

    3.public void actionPerformed(ActionEvent e)

              4.JOptionPane.showMessageDialog(null, "程序即将退出...");

             4.System.exit(0);

2.button.addActionListener(new ActionListener()

  3.public void actionPerformed(ActionEvent e)

          4.inname = txt.getText();

           4.System.out.println(inname);System.out.println(inname.toString());

          4.Boolean GBK = gbk(inname);

             if ("".equals(inname))  System.out.println("未输入注册名!");  txt.setText("请输入英文或数字注册名!");txt.setBackground(Color.red);else if(GBK)System.out.println("请输入英文或数字注册名!");txt.setText("请输入英文或数字注册名!");txt.setBackground(Color.red);else MyEclipseGen myeclipsegen = new MyEclipseGen();String res = getSerial(inname, "5");txt2.setText(res);System.out.println(res);

  2.txt.addMouseListener(new MouseListener() 3.public void mouseClicked(MouseEvent e)                  txt.setText("");
                txt.setBackground(txt2.getBackground());

public static boolean gbk(String str)

char[] chars = str.toCharArray();

boolean isGB2312 = false;

for (int i = 0; i < chars.length; i++)

byte[] bytes = ("" + chars[i]).getBytes();

if (bytes.length == 2)

int[] ints = new int[2];

ints[0] = bytes[0] & 0xff;

ints[1] = bytes[1] & 0xff;

                  if (ints[0] >= 0x81 && ints[0] <= 0xFE && ints[1] >= 0x40 && ints[1] <= 0xFE)                     isGB2312 = true;
                    break;

return isGB2312;

原创粉丝点击