From f24200b2f2ce752ac2d35751d6d615b72642bbaf Mon Sep 17 00:00:00 2001 From: Benoit Foucher Date: Thu, 3 Dec 2009 17:09:19 +0100 Subject: Fixed demos to use Ice.Dispatcher --- java/demo/Ice/swing/Client.java | 85 +++++++++++------------------------------ 1 file changed, 22 insertions(+), 63 deletions(-) (limited to 'java/demo/Ice/swing/Client.java') diff --git a/java/demo/Ice/swing/Client.java b/java/demo/Ice/swing/Client.java index 1c758cb621d..ffdac41877e 100644 --- a/java/demo/Ice/swing/Client.java +++ b/java/demo/Ice/swing/Client.java @@ -70,6 +70,14 @@ public class Client extends JFrame Ice.InitializationData initData = new Ice.InitializationData(); initData.properties = Ice.Util.createProperties(); initData.properties.load("config.client"); + initData.dispatcher = new Ice.Dispatcher() + { + public void + dispatch(Runnable runnable, Ice.Connection connection) + { + SwingUtilities.invokeLater(runnable); + } + }; _communicator = Ice.Util.initialize(args, initData); } catch(Throwable ex) @@ -371,13 +379,7 @@ public class Client extends JFrame String host = _hostname.getText().toString().trim(); if(host.length() == 0) { - SwingUtilities.invokeLater(new Runnable() - { - public void run() - { - _status.setText("No hostname"); - } - }); + _status.setText("No hostname"); return null; } @@ -399,13 +401,7 @@ public class Client extends JFrame { assert (!_response); _response = true; - SwingUtilities.invokeLater(new Runnable() - { - public void run() - { - _status.setText("Ready"); - } - }); + _status.setText("Ready"); } @Override @@ -413,14 +409,7 @@ public class Client extends JFrame { assert (!_response); _response = true; - - SwingUtilities.invokeLater(new Runnable() - { - public void run() - { - handleException(ex); - } - }); + handleException(ex); } @Override @@ -431,20 +420,14 @@ public class Client extends JFrame return; } - SwingUtilities.invokeLater(new Runnable() + if(_deliveryMode == DeliveryMode.TWOWAY || _deliveryMode == DeliveryMode.TWOWAY_SECURE) { - public void run() - { - if(_deliveryMode == DeliveryMode.TWOWAY || _deliveryMode == DeliveryMode.TWOWAY_SECURE) - { - _status.setText("Waiting for response"); - } - else - { - _status.setText("Ready"); - } - } - }); + _status.setText("Waiting for response"); + } + else + { + _status.setText("Ready"); + } } private boolean _response = false; @@ -499,25 +482,13 @@ public class Client extends JFrame @Override public void response() { - SwingUtilities.invokeLater(new Runnable() - { - public void run() - { - _status.setText("Ready"); - } - }); + _status.setText("Ready"); } @Override public void exception(final Ice.LocalException ex) { - SwingUtilities.invokeLater(new Runnable() - { - public void run() - { - handleException(ex); - } - }); + handleException(ex); } }); if(_deliveryMode == DeliveryMode.TWOWAY || _deliveryMode == DeliveryMode.TWOWAY_SECURE) @@ -550,13 +521,7 @@ public class Client extends JFrame } catch(final Ice.LocalException ex) { - SwingUtilities.invokeLater(new Runnable() - { - public void run() - { - handleException(ex); - } - }); + handleException(ex); } } }).start(); @@ -605,13 +570,7 @@ public class Client extends JFrame return; } ex.printStackTrace(); - SwingUtilities.invokeLater(new Runnable() - { - public void run() - { - _status.setText(ex.getClass().getName()); - } - }); + _status.setText(ex.getClass().getName()); } private static class SliderListener implements ChangeListener -- cgit v1.2.3