예제 #1
0
  RProgressBarImpl(Signal<Integer> source) {
    _source = source;

    _component.setStringPainted(true);

    _toAvoidGc =
        _source.addReceiver(
            new Consumer<Integer>() {
              @Override
              public void consume(final Integer progress) {
                _component.setValue(Math.min(100, progress));
              }
            });
  }
예제 #2
0
 private void startReceiving() {
   _referenceToAvoidGc =
       _source.addReceiver(
           new Consumer<Object>() {
             @Override
             public void consume(final Object text) {
               my(GuiThread.class)
                   .invokeAndWaitForWussies(
                       new Runnable() {
                         @Override
                         public void run() {
                           if (!_notified) return;
                           setText(valueToString(text));
                         }
                       });
             }
           });
 }
예제 #3
0
  public ActionsPanel(
      final Closure pass, final Closure resign, StoneColor side, Signal<StoneColor> nextToPlay) {
    _side = side;

    final JButton passButton = new JButton("Pass");

    final JButton resignButton = new JButton("Resign");

    add(passButton);
    add(resignButton);

    ActionListener listener =
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent arg0) {
            pass.run();
          }
        };
    passButton.addActionListener(ProxyInEnvironment.newInstance(listener));

    listener =
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent arg0) {
            resign.run();
          }
        };
    resignButton.addActionListener(ProxyInEnvironment.newInstance(listener));

    _refToAvoidGc =
        nextToPlay.addReceiver(
            new Consumer<StoneColor>() {
              @Override
              public void consume(StoneColor nextColor) {
                boolean isMyTurn = nextColor == _side;
                passButton.setEnabled(isMyTurn);
                resignButton.setEnabled(isMyTurn);
              }
            });

    setVisible(true);
  }