Example #1
0
  public void mouseClicked(MouseEvent e) {
    int x = e.getX();
    int y = e.getY();

    String randCode = bean.getRandCode();
    if (randCode == null) randCode = x + "," + y;
    else randCode += "," + x + "," + y;
    bean.setRandCode(randCode);

    Graphics graph = image.getGraphics();
    BufferedImage icon = Action.getImage();
    graph.drawImage(icon, x - 13, y - 13, null);
  }
Example #2
0
  public void actionPerformed(ActionEvent e) {
    if (e.getActionCommand().equals("刷新")) {
      this.getContentPane().remove(image);
      image = new ImagePanel(Action.getImage(url));

      this.getContentPane().add(image, BorderLayout.CENTER);
      this.validate();
      image.addMouseListener(this);
    } else {
      synchronized (bean) {
        bean.notify();
      }
      this.dispatchEvent(new WindowEvent(this, WindowEvent.WINDOW_CLOSING));
    }
  }
Example #3
0
  public void captcha() {
    // This is an empty content area in the frame
    image = new ImagePanel(Action.getImage(url));
    this.add(image);

    this.getContentPane().add(image, BorderLayout.CENTER);

    JButton button1 = new JButton("刷新");
    JButton button2 = new JButton("确定");

    JPanel panel = new JPanel();
    panel.add(button1);
    panel.add(button2);

    this.getContentPane().add(panel, BorderLayout.PAGE_END);

    image.addMouseListener(this);
    button1.addActionListener(this);
    button2.addActionListener(this);
    this.setVisible(true);
  }