java.beans.EventHandler.<init>()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(6.8k)|赞(0)|评价(0)|浏览(236)

本文整理了Java中java.beans.EventHandler.<init>()方法的一些代码示例,展示了EventHandler.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。EventHandler.<init>()方法的具体详情如下:
包路径:java.beans.EventHandler
类名称:EventHandler
方法名:<init>

EventHandler.<init>介绍

暂无

代码示例

代码示例来源:origin: stackoverflow.com

EventHandler eh = new EventHandler<ActionEvent>() {
  @Override
  public void handle(ActionEvent event) {
    if (event.getSource() instanceof CheckBox) {
      CheckBox chk = (CheckBox) event.getSource();
      System.out.println("Action performed on checkbox " + chk.getText());
      if ("chk 1".equals(chk.getText())) {
        chk2.setSelected(!chk1.isSelected());
      } else if ("chk 2".equals(chk.getText())) {
        chk1.setSelected(!chk2.isSelected());
      }
    }
  }
};

chk1.setOnAction(eh);
chk2.setOnAction(eh);

代码示例来源:origin: openmrs/openmrs-core

/**
   * @throws SerializationException
   * @see SimpleXStreamSerializer#serialize(Object)
   */
  @Test
  public void serialize_shouldNotSerializeProxies() throws SerializationException {
    EventHandler h = new EventHandler(new ProcessBuilder("someApp"), "start", null, null);
    Object proxy = Proxy.newProxyInstance(this.getClass().getClassLoader(), new Class[] { OpenmrsObject.class }, h);
    expectedException.expect(XStreamException.class);
    new SimpleXStreamSerializer().serialize(proxy);
  }
}

代码示例来源:origin: stackoverflow.com

this.setContextMenu(menu);
  this.getContextMenu().setAutoHide(true);

   EventHandler event = new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent me) {
  if (me.getButton() == MouseButton.SECONDARY) {
 tableView.getContextMenu().show(tableView, me.getSceneX(), me.getSceneY());
  }
 }
};    
   this.addEventHandler(MouseEvent.MOUSE_CLICKED,event);

代码示例来源:origin: stackoverflow.com

this.email = new TextBox({
  size: [300, 40],
  placeholder:'email'
});

var event_handler = new EventHandler();

event_handler.on('surface-has-rendered', function(control){
  control.focus();
});

this.email.pipe(event_handler);

代码示例来源:origin: stackoverflow.com

EventHandler boatHandler = new EventHandler<javafx.scene.input.MouseEvent>(){
    public void handle(javafx.scene.input.MouseEvent event){
    //code used for retrieving x,y values
    canvas.removeEventHandler(MouseEvent.MOUSE_PRESSED, this);

    }
}

代码示例来源:origin: stackoverflow.com

EventHandler handler = new EventHandler<ActionEvent>() {
  public void handle(InputEvent event) {
    // do something 
    event.consume();
  }
};

代码示例来源:origin: stackoverflow.com

EventHandler evChb = new EventHandler<ActionEvent>() {
  @Override
  public void handle(ActionEvent event) {  
    if (event.getSource() instanceof CheckBox) {
      CheckBox chb = (CheckBox) event.getSource();
      chb.setSelected(!chb.isSelected());
    }
  }
};

代码示例来源:origin: stackoverflow.com

EventHandler eventHandler = new EventHandler<MouseEvent>()
   {
     @Override
     public void handle(MouseEvent me)
     {
      if (mouseEvent.getButton().equals(MouseButton.PRIMARY)) {
       if (mouseEvent.getClickCount() == 2) {
        ...
        ...
        ...
      } }
     }
   }

代码示例来源:origin: stackoverflow.com

EventHandler handler = new EventHandler(btn1, btn2);
btn1.addActionListener(handler);
btn2.addActionListener(handler);

代码示例来源:origin: stackoverflow.com

EventHandler handler = new AppStartupCompleteEventHandler();

ContextInjectionFactory.inject(handler, context);

代码示例来源:origin: stackoverflow.com

EventHandler eh = new EventHandler <MouseEvent>() {
  ...
};

代码示例来源:origin: stackoverflow.com

public void setOnLoadCompleteListener(SoundPool.OnLoadCompleteListener listener)
{
  synchronized(mLock) {
    if (listener != null) {
      // setup message handler
      Looper looper;
      if ((looper = Looper.myLooper()) != null) {
        mEventHandler = new EventHandler(mProxy, looper);
      } else if ((looper = Looper.getMainLooper()) != null) {
        mEventHandler = new EventHandler(mProxy, looper);
      } else {
        mEventHandler = null;
      }
    } else {
      mEventHandler = null;
    }
    mOnLoadCompleteListener = listener;
  }
}

代码示例来源:origin: stackoverflow.com

getWidget().getDrawFeaturePoint().eventListeners.addListener(getWidget().getDrawFeaturePoint(), featurePointAddedlistener, EventType.VECTOR_FEATURE_ADDED, new EventHandler() {
  @Override
  public void onHandle(EventObject eventObject) {
    FeatureAddedEvent e = new FeatureAddedEvent(eventObject);
    featurePointAddedlistener.onFeatureAdded(e);
  }
});

代码示例来源:origin: stackoverflow.com

EventHandler mouseHandler = new EventHandler<MouseEvent>() {
  @Override
  public void handle(MouseEvent t) {
    ImageView imageView = (ImageView) t.getSource();
    System.out.println("You clicked " + imageView.getImage());
  }
};

for (int i = 0; i < 8; i++) {
  ImageView imageView = new ImageView(im[i]);
  imageView.setOnMouseClicked(mouseHandler);
  flowpane.getChildren().add(imageView);
}

代码示例来源:origin: stackoverflow.com

FirefoxDriver driver = new FirefoxDriver();
 EventFiringWebDriver eventDriver = new EventFiringWebDriver(driver);

EventHandler handler = new EventHandler();
eventDriver.register(handler);

代码示例来源:origin: stackoverflow.com

public void initBubbles(){
  final Image image = new Image("file:src/bubbles/images/bubble.png");
  // Create an event handler to be re-used for all the ImageView's
  final EventHandler eventHandler = new EventHandler<MouseEvent> () {
    @Override
    public void handle(MouseEvent event) {
      final ImageView iv = (ImageView) (event.getTarget());
      iv.setImage(new Image("popped.png"));
    }
  }
  for (int i = 0; i < bubbles.length; i++) {
    //Creates a new bubble
    bubbles[i] = new Bubble(image, 'A', 1);
    //Creates a new image view
    ivs[i] = new ImageView(image);
    // Register the event handler
    ivs[i].addEventHandler(MouseEvent.MOUSE_CLICKED, eventHandler);
  }
}

代码示例来源:origin: stackoverflow.com

SimpleMessageListenerContainer listenerContainer = new SimpleMessageListenerContainer();
listenerContainer.setMessageListener(new MessageListenerAdapter(new EventHandler(), new JsonMessageConverter()));

代码示例来源:origin: stackoverflow.com

public TreeModel() {
   MenuItem addMenuItem = new MenuItem("Create Tab");
   addMenu.getItems().add(addMenuItem);
   addMenuItem.setOnAction(new EventHandler() {
     @Override
     public void handle(Event t) {
       TreeItem newEmployee = 
         new TreeItem<>("New Tab");
           getTreeItem().getChildren().add(newEmployee);
     }
   });
   contextMenuProperty().bind(
Bindings.when(Bindings.equal(itemProperty(),"TABS"))
.then(addMenu)
.otherwise((ContextMenu)null));
 }

代码示例来源:origin: stackoverflow.com

TextField text = new TextField();
Label label1 = new Label("hello");
Label label2 = new Label("world");
Label label3 = new Label("java");

label1.setContextMenu(createContextMenu(label1, text));       
label2.setContextMenu(createContextMenu(label2, text));            
label3.setContextMenu(createContextMenu(label3, text));

// ...

private void createContextMenu(Label label, TextField text) {
  ContextMenu menu = new ContextMenu();
  MenuItem item = new MenuItem("copy to text field");
  menu.getItems().add(item);
  item.setOnAction(new EventHandler(){
    public void handle(Event event) {
      text.setText(label.getText());
    }
  });
  return menu ;
}

代码示例来源:origin: stackoverflow.com

class foo
{
  public void setListeners(EventHandler handler)
  {
    this.setListener(handler);
  }
}

class bar
{
  foo fooObject = new foo();

  EventHandler eventH = new eventhandler()
  { 
    @override
    public void handle(event args)
    {
      functionToDo();
    }
  };

  private void functionToDo(){ do stuff }

  // call in some method
  {
    fooObject.setListeners(eventH);
  }
}

相关文章