Přeskočit na hlavní obsah

Příspěvky

My JavaFX experience

Since version 2.0 of JavaFX, I was very keen about this technology and was looking forward to use it in some project. Hello world is fine, but you need some real application, used by real people.  First opportunity came with AgroSense project, where we developed Gantt chart component for planning (similar to Google Calendar or Outlook). As far as I know, this component was never used and now there are plenty of alternative solutions, but it gave me some insight to the library (is it library, or platform?) and its features. Few months ago another opportunity came in my company, where we decided to rewrite legacy self-service cafeteria terminal. The application is quite simple - user signs with his/hers contactless smart card and adds grocery to the shopping cart using barcode scanner or touch screen. This application is only for internal use in our company, so we decided to experiment a little and use JavaFX to the frontend of the application. We use quite ordinary ...
Nejnovější příspěvky

Have you met Thread?

I’m pretty sure, you know java.lang.Thread class and it’s API. Today I want to spend some time with sleep method.   void sleep (long millis) is pretty straight – just remember not to set negative value and be ready for InterruptedException , that’s it. But what if you need better precision? Great, there is another sleep method, this time with two arguments – millis and nanos. The Javadoc is clear: Causes the currently executing thread to sleep (temporarily cease execution) for the specified number of milliseconds, subject to the precision and accuracy of system timers and schedulers. See? You can set some amount of nanoseconds to the Thread to sleep, but the precision is dictated by system timers and schedulers.  Okay computers are fast these days, so the precision wouldn’t be so bad. You start to use it, but the results are far from what you expected. Double check your code, everything looks good. Okay it is time to see the source code. WTF. WTF? WTF! ...

CPU killer in Java with JavaFX GUI client

Motivation Few weeks ago I was searching for a source of a bug in one of our applications. The QA team suspected that slow computer could be a reason for this. You know that - developers have Core i7 CPU with 8 GB RAM (at least some of us :-) ) and never realize, that users can have slow machine, which reacts differently . And for that tiny moment you would need slow computer, just to see how it works and whether you can break it. But how to achieve this? The QA team does that by creating a virtual machine and setting it very low resources, so it acts very slow. Another option is to use some kind of CPU killer – those are great pieces of software, doing exactly what it sounds – killing your CPU. There are tons of complete solutions out there, but I didn’t want to deal with the licensing and our IT stuff yelling at me, what is that software that I installed by myself again. So I decided to break the rule “ Don’t reinvent the wheel ” again. Requirements At first, here is a list ...

Hello Lambdas

 We have been waiting so long for lambda expressions in Java and now we are one step from the release of Java 8, provided it won’t be postponed again :-) Before writing this article, I thought the release is planned for the fall 2013 and now I found, it was postponed again to early 2014.  And the original plan was late 2012! With Lambda project as the main reason of the postponing, it must be really perfect when it is finished :-)  But postponing the release of Java 8 is not what I am going to write. What I want to write about, is the Lambda project, but not as you would expect.  So much has been written about Lambda in Java, that everybody must know it and I believe nearly everybody is looking forward to use it. You can try it right now with Early Access Release available  here.    I don’t doubt you will try it just for fun. I did and really enjoyed it. But what about production code? Will you use it? With so much attention to Lambda...

Getting confused with JavaFX Canvas

As I am working on a new MapViewer  component for AgroSense  (it is fork, but very modified, of abandoned project swingx-ws) I am facing some strange behavior of JavaFX components, which I have never met in Swing. It is a combination of StackPane , Canvas and painting images in the Canvas .   And what was the problem? Having Canvas in StackPane and some components, for example BorderPane with Buttons and Slider , on top of it, components in upper layer of StackPane tend to disappear, especially when moving mouse over other components. The component with focus or with mouse over it looks good, but other disapear. As I was searching for the root cause of trouble, I tested some combinations of painting in Canvas ( GraphicsContext.fillRect() , GraphicsContext.drawImage() etc.) and only drawing of image was troubled. And when the Pane with components wasn’t over the painted image, the problem was gone. Searching for the problem But how to find out what is g...

Checking internet connection and connection to a particular server in Java

In AgroSense we need to know, if the computer is connected to the internet or not. And we don’t want to bother the user by throwing UnknownHostException or IOException also. So we need two things: Check the connection Notify everybody interested, that the connectivity changed When the first point is successfully implemented, the second one is easy – it is just a listener, so we will look only at the connectivity check problem. Solution For checking internet connectivity you need some host address. You will probably use the address, which you actually call, in our case it is www.openstreetmap.org. In first step, we check, if there is some internet connection, this is done in a method isOnlineFastCheck: private boolean isOnlineFastCheck() {         boolean check = false;         try {             InetAddress.getByName(hostName);             check = true;     ...

How to remember zillion passwords to zillion sites

I use about 6 different passwords to access my let’s say 25 accounts over the internet, including email, internet banking, linkedIn, oDesk, cloud9, openshift, bitbucket, twitter, facebook, icq, project1709, Amazon …  There are just too many. Some of them I don’t want to type every day and I don’t see a problem in being signed permanently, so I check the Keep me logged in option when I can. Some of them are so important and leave no way to forget the password, like work account or internet banking login. But some are used so rarely, I sometimes don’t remember event login name, not speaking about the password. How to solve this? OpenId Great solution (although one of those, where I don’t remember my password :-) ). The idea is great, but still there exists too many sites, that don’t support this type of logging. Maybe in a few years it could become a standard. There is always hope. Google / Facebook This is very similar to the OpenId project. I am not so...