Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void DoSomething(){ //this method is invoked when button is clicked
- ExampleService s = new ExampleService();
- s.setValue1(s1.getValue()); //s1,s2 - UI elements
- s.setValue2(s2.getValue());
- s.start();
- };
- private static class ExampleService extends Service<Void> {
- double value1,value2;
- public double getValue1() {
- return value1;
- }
- public void setValue1(double value1) {
- this.value1 = value1;
- }
- public double getValue2() {
- return value2;
- }
- public void setValue2(double value2) {
- this.value2 = value2;
- }
- @Override
- protected Task<Void> createTask() {
- return new Task() {
- final double v1 = value1;
- final double v2 = value2;
- @Override
- protected Object call() throws Exception {
- while(!isCancelled())
- ExampleMethod(v1,v2); // I want this method to take arguments from UI elements at each iteration
- return null;
- }
- };
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement