Geek-Press Geeky Blog about software development

21Jul/120

Codebits 2012

Codebits VI

Codebits VI

 

And here it is! The 2012 Codebits edition is starting to rock and roll!

For those who don't know what Codebits is I will write a little review about it.

Codebits it's an event organized by SAPO.PT and believe me these guys put a lot of effort on this event, and thanks to their work not only the event is free but they provide food and beverages, a nice welcome pack, and a lot of talks and presentation and awesome partners stands.

This is the biggest and geekiest technological event in Portugal and it worth every single minute in there.

This year (for the ones that already know the event) it will be in the same venue but seems like the place will have some big news (they say that the division that was diving the main stage to the rest of the area will be a fancy curtain allowing the people outside the main stage to see what is happening!).

As every year the 24-hour programming contest will be on the run too...

Remember 800 geeks'n freaks can attend to the event via a pre-selection method so be sharp and stay tuned on www.codebits.eu!

19Jul/120

Resizing all the components on a java.awt.Frame in Java

When we are used to use a programming language, sometimes we get our tasks a little bit automated.

I come from a background in C# and I am now doing some tasks in Java and I found some concept differences very quickly!

Task: Change the size of all the components inside a dialog based on a java.awt.Frame

After some failures figuring out how to reach my goal here is the best result I got.

protected void changeContent(Container parent) 
{
    for (Component comp : parent.getComponents()) 
    {
        changeFont(comp);
        comp.setMaximumSize( new java.awt.Dimension(comp.getWidth()*2, comp.getHeight()*2) );
        comp.setPreferredSize( new java.awt.Dimension(comp.getWidth()*2, comp.getHeight()*2) );
        comp.setSize( comp.getWidth()*2, comp.getHeight()*2);
        if (comp instanceof Container) 
        {
            changeContent((Container)comp);
        }
    }
}
protected void changeFont(Component comp) 
{
    AffineTransform at = AffineTransform.getScaleInstance(2, 2);
    if (comp.getFont() != null)
    {
        Font font = comp.getFont().deriveFont(at);
        comp.setFont(font);
    }
}

 

In my case, this little methods solved my problems and made my form grow like a charm! I hope this is usefull for someone else...