Did you know the opposite of lightweight? Maybe almost 99% of you said that the opposite was heavyweight. It’s easy. Just take the adjective phrase, which is light, and change it to its opposite, which is heavy. It applied on language. But, did it apply to all language?

Maybe now, 50% of you said that it applied to all language. How about I said that if a thing wasn’t lightweight, so it must be a heavyweight? If you said that I was correct, maybe you forgot about one thing. In mathematics, there was a subject called mathematical logic.

Rings a bell? Remember about the if-then theorem? If you do it” then “something happens”. It means that “you do it” was just one of the causes to make “something happens”. But, if something happens, it doesn’t mean that always “you do it”. If you want a clause that said that “something happens” just because “you do it”, use if-and-only-if instead.

Well, why I bother telling a story about if-then and if-only-if? Yeah, I want to tell you about my experience when I was coding Java. Some of you maybe know about swing components in Java. They are divided into two categories, the heavyweight and the lightweight components. I was playing with JInternalFrame instance back then. I wanted to make a popup window when I clicked a button in this JInternalFrame instance. But I also wanted that if the window popped, the JInternalFrame was not enabled, means user couldn’t do anything in JInternalFrame.

Before we continued, I wanted to share that according to JDK API docs:

Disabling a lightweight component does not prevent it from receiving MouseEvents.

So then I checked if the JInternalFrame was a lightweight or not. To do this, I used a method called isLightweight. It returned false. So I think that it was a heavyweight component. Then I disabled this internal frame when the window popped up. But you know what, it didn’t work. The internal frame still could receive MouseEvents. When I checked again in JDK API docs about JInternalFrame, it said that it was a lightweight component. So what happened here?

Well, actually it’s totally my fault. I used isLightweight method when the internal frame still not visible. When I checked about this method, the JDK said:

This method will always return false if this component is not displayable because it is impossible to determine the weight of an undisplayable component.

So, the method returned false because the component wasn’t visible and not because it was a heavyweight component. Here, I got the if-then message. It reminded me about an advertisement in television not so long ago. It said: “smart people drink this tonic*. I guess you could use if-then to conclude its meaning. Well, have a nice day..

* I censored the trademark. I guess you already know about the advertisement already.

5 thoughts on “Lighweight

  1. hehehe,,

    well indeed bro.

    java is like a sea of knowledge and the only way to "dive" in it is by tryin to use 'em. :angel:

    so, how's your project?? finish yet?

  2. Hmm… Something smell fishy~

    whatever. .

    Coz i think arip won't interfere with my ambition to conquer the world. .

    So it's okay!

What's in your mind?