Archive for the ‘Swing’ Category

Multiple floating toolbars with Swing

March 18, 2013 1 comment

These are my holidays, I should be sitting at the beach, not coding. Unfortunately I can’t; and since when I am bored I do things I like, coding is still one good way to kill some time. So I was restarting an old pet project of mine, some kind of editor and I pretty early ran into a problem: The Java gods have brought us floating toolbars that can be docked to the sides of a BorderLayout. Unfortunately the BorderLayout is the only layout they work with und unfortunately a BorderLayout can just hold one component in each of its border regions, so you can’t have more than one JToolbar on each side, which unfortunately renders the floating functionality pretty useless by default. They might have thought “YAGNI”, when the idea of multiple toolbars next to each other crossed their minds, I don’t know. Unfortunately “I am gonna need it”, but fortunately there is remedy. Read more…

Categories: Swing Tags: , ,

A properly sized JTable

February 16, 2013 2 comments

Task: Create a table with two columns. The columns should fit the size of the content. If the table’s width is smaller than the panel, make the last column fill the panel, if the table is wider than the panel, show horizontal scrollbars. Sounds so easy? How many of you have wasted a good amount of time making a table behave like this? The good thing is: it is easy. And here is how it works. Read more…

Categories: Swing Tags: , , , ,

Paint faster!

August 29, 2010 1 comment

It’s been a while since I came across this stuff and I already wrote about it on a company blog in the German language, but I thought this could be interesting enough for more people out there, so I’m sitting here translating what I wrote almost 2 years ago, keen on validating it with today’s Java Runtime. So what’s this fuzz about? Simply put: I noticed that you might have wasted a lot of time in swing, if you relied on the Graphics-object you get passed by Swing and the difference was dramatic!
Read more…

Categories: Swing Tags: , , ,