We just launched a new website, guigeeks.com, where we will be writing about Swing, JavaFX and other UI related stuff as well. Our other sites, swingrocks.com and feedjii, are still available but don’t expect to much activity there. GuiGeeks.com seems like a much better name, now we can write about anything that we like just as long as it’s UI related and geeky.
Author Archive for Pär Sikö
We just added Feedjii to Kenai so if you’re interested in the code, want to take part in the development or just want to try out the application go to
http://kenai.com/projects/feedjii
and browse around but before you do you should know that we don’t consider the codebase to be complete or perfect. We know of several bugs and some really bad design choices but after all this is just a hobby project and if you don’t like what you see fix it youself
It seems like all energy was drained from us after the JavaOne event and that’s the reason why it’s been eerily silent. After a long and appreciated summer vacation it’s now time to do some fun java coding again. The positive feedback we got from the conference really mades us want to come back and talk more about Swing and good looking UIs. I can’t give any details or show any screenshots yet (because there are none) but we are working on a lot of new stuff both with Swing and JavaFX. We’ll write more about that later.
A thing that’s been bugging me is the lack of KineticScrolling examples. Guess there’s no one to blaim but myself and that’s we I’m currently writing a ”Top 50 Project Kenai” application. The reason I think this is a good idea is not only because I want to demonstrate the KineticScrolling component but also because it seems to me that Project Kenai is litteraly flooded with crappy projects that the world would be much better without. I really think that Kenai is a good idea but I want to be able to browse other projects without all the “This is a just a test project” comming in my way all the time. So “Top 50 Project Kenai” is nothing but an application that shows the top 50 projects on Kenai excluding, among other things, all projects that contains one of the words “test” and “hello”.
One last thing, we’ve been talking about adding Feedjii to Kenai and event though it’s not “perfect” I still think it’s a good idea. Maybe someone else would like to help us out?
This is the first release of the KineticScrolling component (version 0.1), we hope you find it useful. If you find bugs or if you need help to make it work please feel free to mail us.
To get started you need feedjii.jar, which you’ll find under downloads, and the timingframework which you’ll find here.
feedjii-source.jar contains the source code, the java doc is not completely up to date yet.
This is an example of how easy it is to use:
JPanel panel = new JPanel(); // populate the panel with child elements JKineticScrolling scrolling = new JKineticScrolling(panel, JKineticScrolling.Direction.VERTICAL); scrolling.setAnimationTime(1300); scrolling.setSpeed(0.5f); frame.add(scrolling);
Enjoy!
We got a lot of questions and positiv feedback on our presentation and we are very thankful for that. There were also two persons who pointed out, what they believed was, mistakes/errors in our presentation. This post is about those errors.
First of all one person told us that when we draw our component in the paintComponent() method we must consider the space that the border will use. If the border uses five pixels on the edges then we cannot paint anything on those 5 pixels. Yes that’s understood and maybe we should have said it but our goal is to make the code, in the presentation, easy to understand and that’s why we didn’t include it.
Secondly someone told us that when we change the location of the component in the Kinetic Scrolling code we shouldn’t do it directly but instead do it later, probably by using SwingUtilities.invokeLater(). The reason was that every time we changed the location of the component events will be fired and the source of those events will be our KineticScrolling component. I don’t understand what’s wrong with that? I believe that the KineticScrolling component should be what caused the event and nothing else, At least as long as we are running on the EDT. I’m going to investigate this further and let you know what the right way is.
Yes I know that our presentations are named “Swing Rocks” but I just have to save that I think that JavaFX really Rocks. At least the new 1.2 version. The controls are really good looking, performance seems to have increased a lot and I know there are other really nice featues in this version. Can wait to start working with JavaFX.
Today we held our presentation at JavaOne and I think it went alright. No tomatoes were thrown at us and all our demos worked as expected. We had a couple of questions that we, thankfully, could answer and some good discussions afterwards. Now it’s time to relax, attend a few sessions, have a few beers (not at the same time as the sessions) and perhaps start to think about our next application.
By the way someone commented on the thread safety (of lack of?) when we change the location of the Kinetic Scrolling component. Don’t know if it’s a big deal but we will have a look at it before we open source the code. Thank you for telling us.
It’s been a lot of work but finally we beleive that we have something that looks like a beta release of feedjii (just in time for JavaOne)
Start Feedjii here
Feel free to test run it, we are more than happy to hear what you think of it.
When JavaOne is over we plan to open source the entire application as well as individual components.
As I wrote in a previous post Timing Framework have been acting kind of strange lately. The problem is that when animating, say a movement (a simple moving line is enough), for two seconds the application takes much longer time and the result isn’t even close to good looking. A 2 second animation ends up taking 6 seconds and still doesn’t look good. Yes Houston we have a problem!!!
So I’ve been working on this problem for a couple of month and I’ve tried a lot of different things and tried to blame everything from Timing Framework and Java to Windows and the hardware and just when I was about to give up and accept the fact I stumbled apon the solution. And this time it’s really working.
So what’s the problem? It turns out that the problem is related to both Java and the native platform. Timing Framework uses a swing timer and the swing timer uses wait(time) and notify() internally. Unfortenately wait and notify lacks the kind of resolution that we need and to be more precise, on Windows, the resolution is approximately 16 ms. This means that the maximum frame rate that we can get is 1000(ms)/16(ms) = 62 FPS. This is not enough for our application since we use an animation time of 2 seconds and in that time the component that we scroll moves 500-1500 pixels. That means, worst case, that each animation loop will make the component move 1500/(62*2) = 12 pixels. And i’m pretty sure that not even a drunk and half blind person won’t notice the choppy behaviour.
And the solution is….. simple. Write your own TimingSource.
A TimingSource is a class in TimingFramework that handles the timing and all you have to do is write 4 simple methods and add the new TimingSource to your Animation class and your done. I guess I don’t have to remind you NOT to use wait() and notify() in your solution? What should you use? Well I guess there are several ways to do it but we have done it as simple as possible and used Thread.sleep(time) which actually works as expected with an accurate precision. If you’re using Linux or some other operating system then you don’t have this issue and I have no idé why you’ve read this far.
Below is our implementation of TimingSource. Note that this is a first version and no brain power has been consumed creating it. This will of cource change in the future.
public class NanoSource extends TimingSource {
private long resolution;
private boolean stop = false;
@Override
public void start() {
new Thread() {
@Override
public void run() {
while (!stop) {
try {
sleep(resolution);
} catch (Exception e) {
e.printStackTrace();
}
timingEvent();
}
}
}.start();
}
@Override
public void stop() {
stop = true;
}
@Override
public void setResolution(int res) {
resolution = res;
}
@Override
public void setStartDelay(int arg0) {
// add delay
}
}
And then all you have to do to make your Animator use your new TimingSource is:
Animator animator = new Animator(2000, timingTarget); animator.setTimer(new NanoSource()); animator.start();
and your done.
That’s it for this time
Ps. Yes I know that we’ve promised to opensource/publish our feed reader and yes we are going to do exactly that but we need just a little bit more time. Ds.
Recent comments