my name is Michael Finney Cara this is Ryan Kubrick we both work for a company called SEO systems may not have heard of us but we’re a big software company we have about 11,000 employees lots of customers you may not have heard of us and yet we’ve been in the what we call the PLM business for a long time we define we create we used to just do 3d software and now we’re going into more enterprise software mode with trying to follow the trends and then the next one so you may not have heard of us but in fact we actually act in lots and lots of different industries we built its our software it’s used to build airplanes and cars and trucks and shampoo bottles and my friend Ryan who will be talking to you in a moment he works in a product that we acquired called ingenuity and that product was relatively old and had lots and lots of swing code and his features about how we moved from this older now obsolete swing stuff to Java effects so without any further ado so I’m happy to say that the stuff that used probably this morning in your hotel room was probably designed using a java swing application being the ingenuity software so it’s used to design practical practical lots of formulas out there I’m it’s a leading formula enterprise formulation software it’s used by chemists to formulate and create many products including toothpastes care personal care cosmetics fragrances etc as well as laundry detergents OTC drugs it is elite it’s our many of our customers that’s why when I say that you probably bought something this morning using a customer’s include P&G Merck Kodi etc and they’re all using a swing they are using a swing desktop client to actually design to design the formulas so basically is a CAD software for formulation so okay so during this presentation I’m gonna cover how to move from Swing to driver effects or how we’re handling move from from swing to job effects so one of the questions that comes up is you know why move from swing to JavaFX and one of the reasons why is it brings many rich technologies to the desktop so it brings the scene graph to the desktop which I talked about I think yesterday as well as video multi-touch support and also html5 which I touched on and the other in the other presentation and this is actually one of the driving reasons why or one of the reasons why we initially started using Java effects was to get access to that webview component so we could actually integrate content from web applications into our desktop applications as a result of the acquisition it addresses critical desktop concerns including internationalization applications skinny I’ll cover dive into that a little bit I don’t know how many of you have ever tried fiddling around with you a manager and swing it is it is a bear to work with it to customize your application we actually use the Nimbus look and fuel and actually a tweaked version of the Nimbus look and feel and there have been requests to do a custom look and feel for our application however given the the amount of effort that’s involved currently with swing that’s we won’t be doing that anytime soon and definitely not with job effects one of the other things that JavaFX brings to the table is screen customization tooling using a standard XML file so we’re very excited about the screen builder tool in terms of it makes it much easier to design screens years ago we were using a custom XML file format the design screens we’ve since we’ve been using actually J forms designer on the swing side since however Jake the screen builder brings it to a new level and we’re quite excited to actually begin using that and one of the reasons why is because it empowers customers and integrators to extend and customize their UI so you don’t actually have to write tons of code and I’ve actually banged out an example which I’ll show just demonstrating the power of the scene builder I keep calling it screen builder for some reason I know it’s called scene builder um I so one of the one of the challenges in moving from Swing to job FX is you don’t want to break what works if you have a large application that’s ten plus years old you just can’t take you know three or four years offline and go rewrite it to have the same feature set because by the time you finish rewriting it you know your competitors will be you know four years ahead of you so that’s the first thing is that don’t break what works change changing to Java effects a few effects QA as well as automated test Suites and I’ll touch a little bit upon that later in terms of you know what the ramifications are are for test Suites and switching to Java FX especially around tooling tooling Eclipse IDE usually lag lags or has integration issues with new technologies such as Java effects and development must be coupled to adding business values so in

terms of switching to Java effects it might you know the first the most important thing is it must add business value to the application we just can’t switch because it’s a cool new UI technology that will someday replace swing I can’t go to my manager and say you know I’d like to I would like to rewrite you know court you know the entire app to make it you know so that we can use Java effects cause I’ll be accused of resume driven development so it has to has to actually have business value and then finally some of the other challenges are leveraging the new Java effects capabilities in a swing application getting them to actually work and coupling them together which I’ll which I’ll touch upon throughout the presentation in terms of strategic reasons to move to H to drive effects one is it enables the composit html5 applications as I already touched upon so it enables you to actually you know pull in and use html5 content in your application and if you’re at my presentation the other day I showed how you can actually have JavaScript code call into Java code and Java code call back into the web page to perform operations on the web page so it actually it’s not just you know you know like in the old days where we had that Swing component with that rendered HTML no it’s actually WebKit from Safari and chrome and you can actually talk to it and actually in the presentation the other day I even went over how do you actually debug WebKit how do you use the WebKit debugging API to talk to it in terms technical reasons JavaFX has a larger suite of built-in components it’s got you know charting components date pickers all the things that you know in the past you had to go out to a separate third party and try to integrate into your application it’s also got a superior architecture that addresses numerous swing shortcomings so how many of you are actually swing developers out here ok so you’ve probably run into many you know you’ve had to dive into swing code at some point they’ve run into challenges trying to extend the UI class and discovered that it was packaged protected especially within the Nimbus classes there’s been many times I’ve had to dive into something like you know putting up a search results screen so that you know where you can scroll through you know hundreds of thousands of records and I want to put up a glass pane so that every time you you know we have to pull more records from the data from the backend database it blocks the UI and just you know puts up little progress indicator the amount of code to do that with a amount of code to do that in the swing is you know enormous you know whereas if you have a scene graph and you can just you know put to use a stack pane and put another panel in front of it in a septa button clicks it makes it much easier you know you don’t have to go out and try using the what’s what’s the JX layer to try to intercept events and trying to get that to work and make sure that you intercept key events Mouse events and all of the other things and then other issues like for instance you know Auto lookup themselves so you want to as the user type something in the cell they hit enter and you want to go out to the server to look up the value and then block committing the cell value until you get a list of options back from the server so that you can then present you know a basically a pick list screen allowing the user to do that so there’s things like you know trying to intercept the commit for a cell is actually kind of tricky and defer it not just you know stop it from happening you want to actually defer it for a minute while you go check with a server for something so things like that are very complicated with it drop affects also provides you know special effects things that in swing would have just been plain impossible there’s no way that you can animate a text field moving on to a screen you can’t do anything nice where you know you know you’re moving through a wizard and the screens slide off you know each wizard panel slides on and slides off you can’t do that easily with swing you know if you wanted to zoom in on something you can’t do that looking field complications JavaFX styling is much more versatile although it’s still you know they’re still they’re still working on that dealing with CSS is much easier than trying to deal with the UI manager and the look and feel that was never quite completed so in terms of challenges in moving to Java effect one is customizing and joining table cells that is you know technical swing challenges that we’ve run into implementing custom effects binding the UI to the data model so a large part of our app a large block of code is actually devoted to you know synchronizing the UI fields with the data model and back and forth so that if you change one field triggers a calculation and updates ten other fields there’s lots of code in our code basin we have it basically have constructed a framework to try to handle types of things like that that Java affects handles now with like the binding API so there’s a lot of things where you know I think you know as we moved to Java effects we’ll be removing lots of code from our application because we’ll be leveraging the features that Java FX provides such as binding and you know screen design tools etc some customizations require as I mentioned changes to the look and feel classes so as I mentioned previously are kind of at ahead of myself some Nimbus code much of the Nimbus code is in package protected at least it was prior to one of the more recent updates so you know making custom changes you know it seems like every time I have to you know fix some really naughty defect I’m running up against

something and down in the UI UI delegate where I can’t actually make changes to that code and I have to like to copy it out and you know make tweak it so that actually made things quite hard with swing and the other thing is you know you know you’re you kind of have a pseudo scene graph and swing right so you know components have parents so sometimes you’re walking up the parent tree to try to find something you know that’s just natural you have a scene graph in Java effects so you can find out who your parent is and you don’t have some you know bizarre behavior around like tab panes etc so as I mentioned html5 is a driving reason for adopting JavaFX initially it provides you can actually manipulate the dome as well as have the talk back and forth JavaFX also and these are in terms of business reasons JavaFX also provides supports and new technologies such as multi-touch I mean the swing API is our secondly single touch only there’s you’ll never get multi-touch in the swing with the current way that it’s architected and it also allowed you know enables you to do CSS skinning and as it’s on the session the other day CSS skinning is not exactly it’s not you can’t take your you know site CSS file and copy it over into your swing application your swing application will now look like your website the properties are actually different as I went over the other day so it’s just not a complete you know it’s not a copy and paste type operation you actually have to learn about how Java effects stai to have the different Java effects styles and how to work with them so that is indeed one of the challenges with dealing with the CSS so you can style with CSS but you can’t necessarily leverage stuff that you already have easily so there’s a little bit wrong when I pitched it initially I said well we could no just take that our website and copy you know copy our CSS file and then we can tweak it to make our application look better it’s not that easy in terms of Java effects Java Java Web Store applications so one of the other challenges like if you’re if you’re deploying code that you want to like customize that like a client site and you’re deploying via Java Web Start the applications are digitally signed so previously you either had to develop your own mechanism for updating screens so if you were deploying an application to a client site and the client site needs to customize some of the screens and the application is also digitally signed well you’ve got clean of a problem because you can’t update the code after it’s digitally signed and shipped to the client so we’d have to build something separately so now given that you can actually design your screens using the scene builder you can actually down your application can download the most recent versions of the screens and present them so it allows you a way to build screens without having to build the screens and code JavaFX also you know so you get the security benefits outlined above and it makes it much easier as I mentioned to customize and make UI changes so one of the challenges in moving from moving a swing application to Java fxo require significant architect architectural changes to the application first of all swing and JavaFX the component models are completely different so you can’t just take your component that you’ve written in swing and poured it over to chop effects it’s not a one-for-one you know you don’t have you know you don’t have the UI classes that you have over in swinging it’s a completely different inheritance hierarchy so basically you have to rewrite if you’ve done custom components in swing you’re going to have to rewrite them for JavaFX they operate on two different threads although they’re supposedly fixing that so that adds an extra level of complexity into the problem that you have two different threads so if you’re integrating Java effects into your swing application today like using the webview you know they’re operating on two separate threads and a few minutes that if you mess up connecting between mix up yeah mix up the threading between the two of them I can actually generate you know hard crashes where it’s actually a core dump in certain situations so the UI components now if your mismatching an application where you’re doing some of your UI in java effects and then some of your UI and swing you’re gonna have a mismatch in the look and feel because Java effects is using Caspian Swing depending upon whether you’re using a custom look and feel or in our case have customized a look and feel it’s not gonna look the same and getting them to match you know there’s there’s different behaviors in terms of you know how the how you interact with the components you know when you click on something how long does it take to come up so there’s slight differences in terms of that behavior so you just can’t like you know replace one dialogue with the JavaFX dialogue because you know your users are gonna go that well this is weird this doesn’t this looks out of place the events are also a little bit different and as I mentioned the data binding capabilities with the data model are different so Java effects you can actually bind stuff to the data modeling you wouldn’t write your code that way you wouldn’t the way you write swing code is not the way that you would write Java effects code and actually I’ve got a short demo if we have time that I will light or show off working with tables in terms of you know how does the data what are the differences in terms of just like you know if you’re you have at it you know trying to present the same data in a table in swing versus Java effects what would it what are the differences so customized Google so if you’re architecting your application or if you

are starting with an existing application you’re going to have to change the architecture of it a little bit especially if you are you know if you have custom swing components and you’ve extended any anything you know any J component jtextfield or something like that you’re going to need to do a little bit of architectural changes to it so one approach is to the first thing is you need to have your components separate from the application so your components should be able to run outside of your application you shouldn’t you shouldn’t have to run your application to see if your custom you know numeric control works or not you should be able to pull that out and run it outside of your application to see if it works we need some type of a concept of basically a separate or runtime and the runtime should ideally provide you know common infrastructure for binding so that you can switch between JavaFX and swing in terms of by how you get the data into the controls so a common interface unify the swing components in terms of their behaviors and how data is loaded and unloaded etc and also provide callbacks for event notification data validation and ideally you want this deploy there’s a separate jar file so if you have an existing swing application right now and you have your own custom components you should probably pull those components out into a separate jar file so that you isolate them from the codebase first so that you can you can isolate their behavior you know as a part of the migration migration to Java effects because you don’t have to fire up your application and drill into ten screens in order to test your numeric control so Java swing in terms of the benefits of Java effects Java swing is just a basic widget toolkit so there is no application framework there is no data binding there is no explicit localization support this is all up to you you have to do this there is also no explicit screen architecture in terms of how you organize your screens or not I mean how many people probably just extend jframe when you’re trying to you know put together a new screen you extend jframe and in the constructor you setup all of your you know you setup the contents of your panels etc JavaFX addresses these gaps and additionally provides controllers for the screens so if you’re actually using scene builder you know there’s a little drop-down that says you know what’s what’s it’s control or and I believe that when you’re creating a project and NetBeans it’ll actually create a controller for you so it will associate a screen and the controller as well as providing data binding support so I’ll circle back to that topic in a second but back to the component suite you will definitely want to develop a regression suite for your components so you’re going to want to have something that you can open up your swing component and also your JavaFX component and say are they behaving the same because they have to be able to isolate whether the problem isn’t shared logic between the two components you know is the problem the JavaFX component the swing component or the code that is shared between them so you know it would also serve as a testbed for defects so as you discover defects or differences in behavior it provides you with the place to actually test it and also helps you validate the technology so one of the first things in terms of switching to Java effects that I did was actually port our you know testing UI testing up for our components over to Java effects so in order to build up the skills because you don’t necessarily want to you know especially if you’re doing all swing development right now you just don’t want to start trying to port your application over to Java effects without having really written Java effects because you’ll probably make a ton of mistakes in the process of doing that so what you want to do is you want to start with some simple peripheral tasks that don’t break your core application or you know tasks that your users don’t see like utilities you use in development or in testing your application so architectural patterns in terms of hooking expediting the the bridge between the two technologies so the first thing I would suggest is to look at Apple’s iOS I actually just did an iOS presentation prior to this integrating Java EE and iOS but what you want to do is you want to look at they have the distinct concept of controllers so if you’re developing for the iPhone each screen has a controller now swing doesn’t enforce it does not require to do have any architecture whatsoever you can extend jframe you know and begin throwing stuff up there that’s the way a lot of Java developers do things if you’re an iOS developer you know that generally you don’t extend components you might you know you you add you register delegates for callbacks for adding functionality but you just don’t extend you know a UI UI table by default so have a screen controller to control the screens and then at the component level have a component basically a component delegate that adds the additional functionality for the components and so if you isolate if you pull the logic that is currently in your swing controls out and into a separate delegate then you can use that delegate on the FX on the JavaFX side so you can you know first you pull your logic out of the swing component because remember you can’t just take your your swing component and copied over to JavaFX you want to pull it out into a into basically a delegate that you can use for both swing and for JavaFX so that you isolate you know any custom behavior that you want and then I put a link at the bottom actually the slides will be up there so that if

you’re interested in this pattern more apples got a pretty good documentation on it business logic so business a logic as I mentioned in the jframe urge a dialog complicates the migration to Java effects so if all of your code is in you know Jake lat J frame subclass well you’re gonna have to refactor your code base in order to get there look at Apple as I mentioned at their view controllers for inspiration for how they go about handling this problem and they also have a nice thing that allows you to design things and storyboards which would be nice if we get that some day and scene builder to fully leverage the capabilities of the Java platform you could actually use your Java JavaScript support to implement the controllers so this is more of a suggestion as an idea you could actually implement the controllers in JavaScript because you have the JavaScript runtime in the Java language so you could actually write the controllers or delegates using javascript in java and execute it their controllers should be agnostic to the presentation technology so when you pull the logic out of your you know out of your j frame and you create a separate controller for the screen you should make sure that it does not have references to j labels is not calling get to text in order to pull the values out you want to make sure that your screens are agnostic so this is architecting for how you go from swing to java effects so you want to pull out you want to isolate the swing code from any business logic as you know as we all know technical debt acquire you know builds up over time where you fix one particular defect the day before shipping you do something that you probably shouldn’t have you know to circumvent something and you know now now it’s time to pay the piper so a comic screen controller functionality so the screen controller should probably handle loading the data or kicking it off to java effects for it to do is binding things this is more of an issue for the swing controls where you actually have to load the data into your screen right you have to call sets text on a text field you have to set your check buttons you don’t have any of the nice binding stuff they get with java effects so you’re going to want to isolate that separately and have a distinct stage for that you’re going to want to handle value change events and as well as checkpointing for you know like under reduce support and one other thing as you architect this control you’re probably going to want to provide feedback so you know whether the bindings actually work whether you actually have valid bindings or not so this is more of a suggestion for your component delegates is to make sure that they you know highlight something so that if a field is not actually bound it actually you know puts up something really noxious so that you know that anything you type in that field is not going to end up back in the data model because it’s always bad you don’t want to have to tell QA well well you have to go through and type in something into every field and then verify that it ended up and you know all the columns in the database the component delegate should handle things like loading and saving data from the component to the data model or in the case of Java effects using the binding so there’s really no op there JavaFX simplifies as I mentioned the data component data mount the data model binding us and then there’s two types of data binding that you could do you can either do POJO or maps so you could actually binder if you’re doing a UI where it you know you’re adding attributes to it you know you don’t know exactly what you’re going to get out of the database in terms of columns you could model it as a map and then bind to that and then in terms of Java effects says you know that you okay hop on from there how to move so moving the entire application over to Java effects at that at one you know in one fell swoop is very risky Java effects is still an evolving technology so you’ll probably run into things that you didn’t expect especially if you have customized components so the approach that the approach to migrations would be to implement swing property editor so it in terms of as I mentioned before mitigating the risk you want to start out with something simple that your users don’t see so one of the first things I started it out with was the application for testing or components and then I moved on to implementing the property editors using Java effects so for all of our components we have property editors and in the existing GUI tool that we use to design the screen so I ported the property editors over to running in Java effects and so that gave me experience with dealing with threading issues figuring out how the layout met the equivalent of layout managers and JavaFX work the grid pain you know kind of you know getting a lay of the land there so that I’m not I don’t you know see so I so that I have a better handle on how it works and so then incrementally improve using new JavaFX features such as adding in web the web view control and then incrementally port screens and features over and then at some point you know you you’ll you know get to the point where you start just redoing screens so the impediments right now to actually switching to Java affects their major Java their major table improvements in Java 8 so you can actually I believe join cells and do a bunch of things that you can’t do right now in the Java 7 release and also scene builder can’t be customized at this time I’m not aware or have not figured out a way to get my own custom property editors for components into scene builder so that’s a major

impediment if you have custom components and they have custom property editors that whole problem has not yet been worked out so that is indeed a major issue for switching so integration challenges so there’s there’s using the new technology and then also making sure that you are when you’re using Java effects that you aren’t coding like you code swing right so you have to unlearn all the bad habits and things that you do to quickly bang out swinging wise because there’s different ways of doing it with Java effects this is a completely new UI toolkit so you don’t want to be in your Java FX code you shouldn’t be calling you know set and get text on things you should actually be binding it to the data model you should be leveraging the power of CSS and not manually coding things in the code say ok you know put a red border around this you should be using CSS for stuff like that other key concerns with integrating of those matching the existing appearance like I mentioned if you’re using you know you you end up with a hybrid application that some screens look one way look like they are you know using the Caspian look and feel and then the other screens are using whatever Java look and feel that you’re using and then there’s as I mentioned thread synchronization issues so start with the lowest development tasks first port the job of property editors over and then definitely the most important point on the slide is solicit feedback from management sales marketing and QA early in the process of moving to Java effects so that they know how the application looking feel is going to change cuz I’ve been in you know many meetings where people argue about you know the color of the background and the disabled J List for instance you know should it be white should it be gray you know how should the gray look cuz how should it look you know compared to the what the windows uses for that color so if you start switching over to Java effects people will be surprised with it in terms of the differences between the two platforms and you could get pushback on that because people say well wait a minute wait a minute looks completely different you know I have to completely retest everything so this is an example of a property editor here poured it over to JavaFX so you know this is a swing property editor for a swing control that I’ve written the the property that are in using Java effects and of course you have to deal with the threading code which is fairly standard that should be that’ll be more readable on this the slides afterwards so some technical examples so I’m gonna look at some some typical problems that you run into the first one is going to be JavaFX boss swing and enum sizing issues that you run into with both technologies and as you’re combining them in the same screen common threading mistakes JavaFX versus swing appearance and then automated testing integration and then I also have another sample application that I can bring up and show off so the first one is this is integrating the webview with a swing with the swing component so it was actually the the screen shot that was supposed to be on this was this code the code that’s right here will actually when you add it into the when you add the webview into your swing swing application you would not actually get scroll bars on either side and the screenshot here is wrong because I actually updated the wrong slide the other day so that would be that’s an initial problem that the the component is getting this because you’re integrating you’re putting the webview into a swing window and both of them have to kind of coordinate you know the preferred sizes because remember they’re running on two separate threads so they’re the JavaFX stuff is going to do its layout on its thread and swing is going to do its layout on the EDT and so you have to synchronize the sizing between the two threads so that you know the scrollbar gets gets so the scroll bars appear and so the way of handling this is actually to set the preferred to preferred with because remember a a webview does not actually know what the dimensions are going to be until it actually loads the content right and then another important thing with moving to the JavaFX JavaFX actually has a much better file browser dialog so this is an example here you can see the swing one on the left and you can see the JavaFX one on the right and the JavaFX one actually mirrors what you’d get from a native Mac OS application so you get the little you know thing you get the icons from the platform you get the shortcuts over on the Left that the user has come to expect you know you get the the different views and everything like that so it’s more of a native experience so if you’ve ever you know one of the challenges with JavaFX is if you I’m sorry with swing is you decide to use the Nimbus look-and-feel well when you use the Nimbus book confuse you lose the platform the native platform file browsers right and so then you can you know go about trying to trick it to get it to appear yes so the question was was how easy is it

to take the job effects file browser and integrated into your swing application it’s actually fairly easy it’s just a matter of dealing with the with the threading issues around it putting it on displaying it on the thread basically there’s some code out there that you you issue the requests you do basically kind of like an invoke later type thing and you use a latch to stop it and then you appear and then you display it so it’s actually right now it’s fairly easy to actually do that so it’s one of the easiest things that could actually be that would that would probably be the first control that I would consider porting over or using if you’re in a swing application because the Java effects file browser is an immediate benefit and for the most part it looks it looks like the native platform one so the users won’t have any idea that you were actually running Java effects so it’s one easy way that you can improve your swing application and switch to and use Java effects without actually impacting the rest of your application so the next one I know this is possibly a little hard to read for those of you in the back but what’s wrong with this code so this is a gaucho and this is a threading one so if you actually run this code what’s going to happen is it’s going to blow up and you’re going to get a you know you can’t fully enable headless mode message which is rather confusing you know what what’s actually going on here what’s causing this message so this is just a situation of you are I have a swing application and I am trying to show I’m using I have a swing application right I have a swing window and I’m trying to end the UI that it’s showing is JavaFX and I’m trying to show a option pane when the JavaFX button is pressed and so what’s happening is that my show message dialog is executing on the JavaFX thread not the swing thread so if you’re merging the two technologies together and you do you know the panel in java effects it’s a job FX application sorry it’s a swing application you do a screen in Java effects but then you throw up a j.j options pane using swing you know you’ll get that error that you saw in the previous slide so the correct way is to do an involute invoke later here to put it on the thread so it appears on the correct threader invoking weight so that’s that error message right there yep Oh actually that was kicking off a J option pain from a drive effects application the next one is doing the same thing where I’m using actually reverse them so this one here is where I’m actually using swing the previous one was where I was using JavaFX and they using invoking a swing thing this run right here is where I’m using having a swing frame that’s using Java effects that is then as a result of like say and error condition trying to show a J option pain so you know say you start porting over logic to Java effects but you’ve left your existing error handling logic showing J option pains you’ll run into threading problems with that so that’s an easy gotcha that you’ll have to like grep your codebase trying to find all of your J option pains and trying to figure out you have to put checks in there to make sure that they actually get invoked on the correct thread and so forth that previous example believe it or not it’s not going to throw up a nice little error message for you it’s going to give you a core dump and it took me a ton of time to figure out what I had actually done wrong so this is you know the the code sample on the previous page or the previous slide that was really simplistic you could kind of look at that and eventually figure out what was going on but then the real application figuring out why your application just core dumped and figuring out that it was because you were doing something from the wrong thread took me a while to do this is probably a defect I’m guessing with with our error handling but it’s something that you could you know something that you’d run into today if you’re trying to use Java effects so if you get that dump you know right now it might not actually be a dump where there’s a problem with a JVM there’s just a problem there error handling but you’ve actually done something wrong in terms of integrating the two technologies and then on the next slide the next gacha gacha number three is automated testing via qtp so if you’re doing automated testing via qtp i’ve got bad news it does not support java effects they can’t even see the components so if you have if you’re a QA group has spent you know thousands of hours developing you know test scripts to automatically do regression testing of your application you’re kind of out of luck at this point because you know they won’t be able to see the components is completely different things so I don’t have to rewrite their scripts so you can actually see down there I actually this is that’s QT Pico down at the bottom you actually kind of have to add black getters and setters so that a qtp developer QT b QT p user you can get at the widgets on your screen so there’s really they’re going to have to write code in order to test the application right now so that’s just one testing package I don’t know if there’s any other if there’s been any other success in how the other packages work with that one but that one you know if you’ve invested a lot into it you know you’re gonna be quite upset with this and I was not able to find out and find out any information

in terms of when QT p plans to actually support Java effects and then scene builder significant gaps scene builder is right now currently developer tool so hopefully they will be adding two additional features to it for to make it easier to use by non developers so that non developers can customize screens because you kind of require knowledge of the codebase in order to do the screens and knowledge of the data model in order to do it so we’ve actually been talking to some of the people over at Java FX and trying to convince them to make changes to scene builder so that non developers can actually develop screens so one of the ideas that we had or we were pushing back we besides the fact of property editors was the concept of like pre bound widgets so that you could have like a library of pre bound widgets that are pre bound to your data model so that if a user wants to drag out a user name onto the screen it already knew how to talk to the user name field in your data model the ID is or you know the FX ID is already set on the component so that your application can find it properly editors and then also plugin support so that you can make changes to it because you presently don’t have presently don’t have those capabilities so this is kind of a demo slide demonstrates you know where you have a custom component library over and left with your pre bound widgets and then you can drag out a user name a first name and a last name and so we’ve been talking with them trying to convince them that to add in the capability so that you can customize the list of widgets on the left to do things like this so I’m going to quickly jump over and do a code sample right now to just kind of demonstrate the differences between the two of them and also highlight some other that’s good that that’s up and running so the first thing is I’m gonna run the application I’m gonna run the swing application first I should pop up in a second it’s quite a jump because in the previous session was doing high OS programming so now I’m back to Java so it’s okay so this is just a simple table displaying a list of boats and the swing code for this I mean this is a fairly trivial application right we’re just displaying a list of boats in a table and so let’s look at the code for this so the code for this first of all I’ve done it the note with that okay the first thing is they’re done at the bad way I’ve extended jframe for this screen right to quickly get it to bit quickly bang it out you know the easiest way to do this is to extend jframe and I have you know my table I’ve got my table model because I’m gonna have to insert records into it I’ve got my actions because I need to be able to tell them they’re actually inner classes so that I can control whether they’re enabled or not and all those types of things that you have to that you fight with with a swing a lot they end up with spaghetti code and then I go into the actual constructor where I set up the panel you know I create the list of books that I used initially but then I do the layout right so I do this really complicated or depending upon whether you like layout managers not layer layout managers or not in Java it’s really complicated to actually do the layout and you know if you have a big dialog with a couple hundred fields on it you know this is gonna be pages and pages of code doing the actual swing layout then I move further down and I actually do you know I set up the context menus on the table I configure them I add a mouse listener so that I can display you know the menus and also update their state you know is you know Israel a a record selected so that the menu item you know the copy menu item should be enabled because if the user clicks in the blank part of the table and they’ve resize the window you don’t want the copy menu to be enabled because there’s nothing selected to copy right and then over in I’ve implemented a table model you know we’re the table model you know has the list of boats and it you know goes in there you request you know given a row or you know how many columns does it have and then this block of code here which returns you know which values belong in which you know which columns etc so the swing code will call into this and ask for it right so this is all very you know run-of-the-mill swing programming you know to put a simple table and the screen had to write all of this code and then I also have because I want to do cut and paste I want to you know be able to cut and paste boat objects right you know between tables for instance so I’ve created a basically a custom transferable you know registered it did all the stuff of data flavor it’s rather arcane stuff that’s a pain in the neck right so let’s look over at the Java FX Co the first thing to notice is that there’s actually more code here but it is somewhat simpler and cleaner code is architected cleaner it’s not spaghetti because this swing code here as I add more and more features to it this is going to turn into spaghetti because you know under certain circumstances that darn menu is not going to enable when it when it should be and I’m going to have to test all of these cases and everything so the first thing is the entry point for this

application is you know Java effects application you know the standard you know start point where you set up your stage and the first thing I do is I load that UI right so I load it from the F XML so I’ve used the scene builder to design the screen and I load it that way so there’s none of this grid bag you know setting grid bag constraints and all of that to try to construct the UI I actually have customized I have a controller class so this is what provides a comment the logic for the screen right and I’ll get to that in a second and then you know I pop up the scene and display and so that’s all the code that’s required for actually displaying it and then if I go over to the I have a couple of other files here one is a race at CSS so I can actually customize the look and feel of the screen using CSS which I haven’t done anything with it yet I’ve got my properties my localization properties and the properties file and notice you did not see and if I switch back over to the controller I’m not working with resource bundles anywhere right so you don’t see any I haven’t loaded any resource bundles I’m not I’m sure I have it yep no problem is that better okay yeah I’m sorry about that I had it up to 18 I didn’t realize that this room was so far back so we’re only gonna be able to see like four lines of code at a time here so I’ll try to scroll somewhat slowly I just have to remember it okay so this is the race controller class so I was talking about controllers before with iOS so this is the same type of concept here you have AF XML screen which defines your UI and then you have a controller for it and you can see I’m using this annotation here for getting a hold of the swing components where I need to actually do things sorry JavaFX components we need to actually do stuff with them so this is how I bind the UI to the actual controller so that I can get a hold of the widgets on the screen to do things with them so I’ve got my menu items here which anything I’m actually doing anything with I have my table column down here and then I have my list of books with which is an observable list which is the JavaFX collections you know the controller basically just takes the list of boats in and sets up an observe FX list and then here is where I bind the the columns right to the to the actual data model so if you know if you add to this list up here you know whoever has a reference to the list that was passed in here if something is added to that list the UI is going to update right if you’re ready in swing code you add something to the list you have to tell the table to refresh itself right so there’s all the spaghetti code that okay you know I’ve you know I’ve written some code you know yeah insert a new record into the table well now I have to update the the look now I have to update the to tell the table to update itself into repol it’s repolarize data you don’t have to do that with java FEX because of its binding capabilities so that’s one difference right there oops so there’s this they’re setting up the binding and then in the previous code sample you saw that complicated code right for doing I you know extended transferable and they set up all that stuff this is to do copy and paste with the Java effects so I get a reference to the clipboard right I actually created a custom data format which was a basically a boat which I called a boat here and then I just stick the currently selected record onto the clipboard and voila I can paste I don’t have to implement a transferable and deal with all that custom logic so if you’re moving from swing to Java effects this is one of the things that you’re going to have to reevaluate for doing that okay and then let me hop over and show you the UI for this and seemed older wait for it to come up come on there we go okay so this is a look this is scene builder actually designing this screen and you know unlike the the swing code I define the tables here I define the tables in the scene builder so this is where I define them right and if you look over here this is where I select the key no sadly I can’t select keys I have to know the actual key and type it into seeing builder hopefully they’ll fix that in the future but the internationalization is done here I’m not doing the internationalization and code or I’m saying okay you know return you know go to the resource bundle grab you know grab this key from this value from the resource Lundell know I’m doing that over in scene builder and JavaFX is

handling it for me right and so you can do that with the custom the pop-up menu items and all of that is doing all of that for you so you don’t have to do write all of that code and so here scroll down you can see I bound it to boat name so that binds it to the the table column that I then have access to in my controller code the table itself the actual screen is bound to the race controller right there like that the context menu is also defined in the file right here and you can see I’ve defined that copy and paste right so I’ve not had to you know write any code to say okay if the user clicks this button 3 right that I display the context menu 1 and there’s a button click or button press that I do that on and this is the same thing on both platforms you don’t have to worry about that because it’s all being handled for you so as you can see moving from swing to JavaFX is a bit of a bit of a makes things a bit easier but it’s gonna require refactoring and code changes to it now in terms of the boat object there’s really no changes to the boat object this is just a POJO right so it just has the you know the boat name model you know actual finish etc so I didn’t have to make any changes to this I don’t have to make any changes to it it just was all the code that dealt with the UI and it’s actually much cleaner than that now let me run this right here I’m going to run the swing up application again they don’t think I opted Ronnie okay so there’s a swing application and now I’m going to run the JavaFX one should pop up within a second okay that’s the JavaFX one so as you can see by default I mean other than the fact that I forgot to set the column headers the the swing one the JavaFX one looks a lot better first of all it’s got the alternate shading I didn’t have to do anything to get that it just looks nicer alright it’s got the custom shading up here you can actually see it you know it looks it looks nice now let’s try that copy and paste logic between swing and JavaFX let’s see what happens when we try to do that so I’m going to right click here and I’m going to do a copy I’m gonna right click here and try it in oops well it’s not gonna let me paste now if I scroll down and that’s this reason because it doesn’t work when it comes over to Java effects this is what’s coming over its a serialized object and so there’s really you have to you know that that is one of the integration points that are going to run into if you have a swing application you’re trying to use Java effects and your custom shopping item you know copying objects around you’re gonna have to come up with some mechanism of handling or dealing with this problem because Java effects and swing there’s two different they use two different basic API is for doing copy and paste so if you start missing missing missing and Matt miss Smith it up using you know aw T’s toolkit and it’s cook board thing then you use Java effects when you’re going to see you know you’re gonna run into issues like this so I find the job FX one much easier to use but the swing one you can use used in more places in our application um okay okay so in summary JavaFX is definitely an improvement over swing it fixes many of the numerous shortcomings in swing that have been languishing there for a good 10 years it has a rich component suite so finally I mean I think I did a talk a couple years ago on swing where I pointed out that there’s been really noone no new components added to swing in ten ten or more years there’s really been nothing going on there there’s no chart components there’s no date picker you know all the things that if you down if you’re doing html5 development you just have by default you don’t have those with swing it enables integration with html5 and web technologies I’m so you can use both you can use web applicant err act with web applications within your application and you can also leverage designer skills in terms of customizing your UI if you’re regarding migrating terms of swing you’re going to need to develop a regression suite to help you migrate and to facilitate the process and then you’re going to have to architect for two different component technologies until you can completely move your application from one technology to the other technology and then a couple of things I left out on the slide deck something I forgot I keep mate and then meaning to add to the slide deck was that with components such as the webview you run into problems that if you’re like showing dialogues and then you close the dialogue it actually calls the dispose method on it so you might run into very weird errors you might have to like override the notify method on the java components to try to handle situations for that because the JavaFX components when the screen goes away we’ll actually get disposed of so if you try to read redisplay that screen that won’t actually work that’s one thing that’s one point or that I forgot to add into the slide deck but it’s an important one

for that so with that I’d like to thank you and if you have any questions I can take those at this point now I’ll get the code samples up online within the next couple of days so thank you you