rushmore.java

来自「struts框架的jsf组件的核心实用例子集合」· Java 代码 · 共 44 行

JAVA
44
字号
package com.corejsf;import java.awt.Point;import java.awt.Rectangle;import java.util.Map;import javax.faces.context.FacesContext;import javax.faces.event.ActionEvent;public class Rushmore {   private String outcome = null;   private Rectangle washingtonRect = new Rectangle(70, 30, 40, 40);   private Rectangle jeffersonRect = new Rectangle(115, 45, 40, 40);   private Rectangle rooseveltRect = new Rectangle(135, 65, 40, 40);   private Rectangle lincolnRect = new Rectangle(175, 62, 40, 40);   public void listen(ActionEvent e) {      FacesContext context = FacesContext.getCurrentInstance();      String clientId = e.getComponent().getClientId(context);      Map requestParams = context.getExternalContext().getRequestParameterMap();      int x = new Integer((String) requestParams.get(clientId + ".x"))            .intValue();      int y = new Integer((String) requestParams.get(clientId + ".y"))            .intValue();      outcome = null;      if (washingtonRect.contains(new Point(x, y)))         outcome = "washington";      if (jeffersonRect.contains(new Point(x, y)))         outcome = "jefferson";      if (rooseveltRect.contains(new Point(x, y)))         outcome = "roosevelt";      if (lincolnRect.contains(new Point(x, y)))         outcome = "lincoln";   }   public String act() {      return outcome;   }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?