Files
Aufgabe7_bandit/src/bandit/Schnittstelle/WertAdapter.java
T

74 lines
1.5 KiB
Java

/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package bandit.Schnittstelle;
import bandit.Model.WuerfelData;
import bandit.Model.Zahlengenerator;
import bandit.View.ZahlenView;
import java.util.ArrayList;
import java.util.concurrent.Flow;
import java.util.concurrent.Flow.Subscriber;
import java.util.concurrent.Flow.Subscription;
import javax.swing.Icon;
/**
*
* @author le
*/
public class WertAdapter implements Subscriber<WuerfelData>
{
private ZahlenView view;
private Zahlengenerator model;
private Subscription subscription;
public WertAdapter(ZahlenView view, Zahlengenerator model)
{
this.view = view;
this.model = model;
}
@Override
public void onSubscribe(Flow.Subscription subscription)
{
this.subscription = subscription;
this.subscription.request(1);
}
@Override
public void onNext(WuerfelData item)
{
String strWert = String.valueOf(item.getValue());
switch(item.getId()){
case 1:
view.getLblZahl1().setText(strWert);
break;
case 2:
view.getLblZahl2().setText(strWert);
break;
case 3:
view.getLblZahl3().setText(strWert);
break;
}
this.subscription.request(1);
}
@Override
public void onError(Throwable throwable)
{
}
@Override
public void onComplete()
{
}
}