Ooh … Begitu! I see, I see …

Icon

Setelah kelayapan di internet, cari-cari info dari sana-sini dan bongkar pasang tips (terutama programming), akhirnya baru sadar … ternyata begitu caranya … [all about tricks and tips I have found during my work as programmer.]

close a singleton JInternalFrame from an outsider customized JPanel.

darn it … I had been really such a fool during these three days. I admit I am really a newbie again in Java programming after leaving it for four years since my way to fashion design back then. totally blank again and got lost in reading the Java documentation.

here was my problem:

I was creating a customized JInternalFrame singleton class (I named it dwInternalFrame class) which would be my global class for customized JInternalFrame to receive any customizable JPanel via a parameter pnContent (a JPanel) as its content pane. I was planning to only create many customized JPanel (e.g. pnNewMaster for adding new data, pnEditMaster for editing the table data, etc.) and then I would only call the constructor of dwInternalFrame and pass the customized JPanel (for example that pnNewMaster) into this dwInternalFrame constructor like:

dwInternalFrame ifNewMaster =
        dwInternalFrame("Adding new Warehouse", 
        pnNewMaster);

but later, there was a JButton btClose for closing the dwInternalFrame that contained this pnNewMaster. how to do that …? I had done a lot of modification to the constructor, create new methods for passing the dwInternalFrame variable name (in this case I called it ifNewMaster) into the pnNewMaster method like:

pnNewMaster.setTheParent(ifNewMaster) ;

which would be passed into pnNewMaster’s myContainer, so it would recognize ifNewMaster when I had to close it via clicking btClose.

still, I got the java.lang.NullPointerException when I tried to close the ifNewMaster. what’s up? I did the debugging and found out that the ifNewMaster I passed as the parameter was null for the pnNewMaster, when I recalled the hidden ifNewMaster.

that’s why this code would raise the null exception when I clicked the btClose:

myContainer.setVisible(false);

this one raised the same null exception too:

myContainer.dispose();

so much effort searching the Java Documentation and googling for the proper way to do the btClose clicking, only to find out I was such a fool to not recognize it this way:

getRootPane().getParent().setVisible(false);

a very simple one liner to solve my three days problem. I don’t even need any ifNewMaster as parameter passing to the pnNewMaster class nor method. darn it. the JRootPane was the root panel for the frame like component, how could I forget it?! and when I call getParent() for the RootPane of pnNewMaster (my customized JPanel), of course I would get the ifNewMaster (aka the dwInternalFrame). darn it. I should learn to read the Java documentation any better.

and when I called the dispose(); for the ifNewMaster or something like that (or any of my dwInternalFrame) . I found out that after I dispose the ifNewMaster, I couldn’t call it again for the second time. what’s happened???

finally I found out, I should have set the dwInternalFrame this way when I created it:

this.setDefaultCloseOperation(HIDE_ON_CLOSE);

and to not call the dispose(); from the pnNewMaster’s btCloseActionPerformed (as I did the clicking to the btClose), instead I should do the setVisible(false); like in

getRootPane().getParent().setVisible(false);

so the singleton would still be able to be called again. why I should have done this, I still need explanation, I just found it this way and I don’t know why if my JInternalFrame singleton was disposed, I couldn’t call it again with a new dwInternalFrame(…) such like that.

any suggestion for a better way doing this things, Guys? or any URL out there providing the tips? I don’t think I’ve done it properly yet, I still need some advice about singleton JInternalFrame thingy.

I have coding too much Delphi programming for the past year, I guess. completely blank in Java again. hmm … migrating from one programming language to another is not as easy as translating a real language. I should get a grip on my Java books again …

thank you for coming and dropping any comments / suggestions.
for those already in Friday noon and not working on Shabbat (Saturday)
may you have a nice weekend and rest.

Advertisements

Filed under: Java programming

a Texas man sued 1-800-Flowers for Revealing His Affair

“flowers to the ‘mistress’, receipt to the wife?”
whoops …

😀 I just got this article from a friend, and found it hilarious to post it inside my wordpress. for those who only speak Indonesian, you can also find another news about the same guy at:
http://www.detikinet.com/index.php/detik.read/tahun/2007/bulan/08/tgl/12/time/131559/idnews/816115/idkanal/398


okay, let’s go back to the article I got from a friend just now. I got this one from http://www.transworldnews.com/NewsStory.aspx?storyid=20577&ret=Current.aspx?pg=3

Texas Man, LeRoy Greer, Sues 1-800-Flowers for Revealing His Affair

Atlanta, Ga. 8/13/2007 4:41 PM GMT (FINDITT)

LeRoy Greer just wanted to send flowers to his girlfriend. Sounds simple enough but after Greer arranged for a bouquet to be sent courtesy of 1-800-flowers the simple task became a major headache for the car salesman.

As it turned out Greer was married and his wife wasn’t the one receiving the flowers, just the thank you card from 1-800-flowers for purchasing the flora.

While Greer was already in the process of divorcing his wife the 1-800-flowers incident didn’t help his standing any and now his wife is all the more eager to end their union. Oh and now that she is aware of the extramarital affair she wants more money as well.

Greer, upset that the company delivered a thank you note for the purchase, is now suing the floral company. Greer had specifically noted on his order that he did not want any cards or information sent to the house he shared with his wife. He now blames the company of falling short of delivering the flowers in a discreet manner, which just so happened to cause his wife to flip out.

Now Greer, a Texas resident, has asked for $1 million from the florist who made the mistake but as of yet there has been no pay off.

here is also an excerpt from http://news.aol.com/story/ar/_a/man-sues-florist-for-revealing-affair/20070810160709990001:

After learning of the affair, Greer’s wife asked for a $300,000 divorce settlement in addition to child support, said Kennitra Foote, Greer’s attorney.

hmmm … worth it? what he sowed is what he reaps now. serves him right. this is a good lesson for the morons out there that “you can’t hide the fish because the smell stinks”. 😀

here is a blog also mentioning about this case. a very cool blog entry to read. just check it out! a very good thought. http://averagebro.blogspot.com/2007/08/leroy-greer-needs-to-learn-how-to-creep.html

a search on the google with “leroy greer sued florist” will give you a lot of result. *grinning*
and I found it interesting that he said that he had to pursue this matter because of what everyone was saying about him on the internet. (http://blogs.chron.com/legaltrade/2007/08/suing_flower_sender_on_today_s.html)

but in my opinion if he had not pursued this matter, no one would be talking about him on the internet. 😀

next time, STOP cheating on your wife.

Filed under: hilarious

get current date time in Firebird?

a friend asked me:

hi, do you know how to get current date time directly from firebird sql? I need to make sure that every client that append or insert any data would use or access the same date time resource, I would like to use sql date time directly, because some of the clients would be from any other time zone. thank you in advance for your help.

hmmm ….

it should be around this way, I guess?

select 
    current_date, 
    current_time, 
    current_timestamp 
from rdb$database

oh … before I forget, you need to check the timestamp information in the firebirdsql.org at this url to make sure about the version of your database: http://www.firebirdsql.org/index.php?op=guide&id=ib6_newfeatures

and this one is a good summary about Date Literals in Firebird:
Firebird Date Literals (Excerpt from Chapter 10 of The Firebird Book © Helen Borrie 2004)

hope this helps. 🙂

Filed under: Firebird

Thunderbird proxy setting??

this is to answer a question from baliazura who has posted this question few days ago in my Date Time simple tips for Firebird store procedure page. this is what he asked:

I use computer and my place work use proxy so I have problem to load thunderbird or my network protect with firewall. any one can help me?

well, I got some information from here: http://kb.mozillazine.org/RSS_proxy_(Thunderbird)

I have never tried using proxy setting so … perhaps you want to give it a try.

It says that Thunderbird does not honor Firefox’s http proxy settings, nor does it provide a GUI to set http proxy settings. But there is an extension exists which provides access to the advanced configuration options where the Proxy Server can be configured. The extension is AboutConfig perhaps you want to check it out.

Once installed, open the AboutConfig extension at “Tools -> about:config” and then follow these steps:

  • Enter “proxy” in the Filter box.
  • Double click “network.proxy.http” and enter the name or address of your proxy server.
  • Double click “network.proxy.http.port” and enter the port your proxy server uses for http.
  • Double click “network.proxy.type” and change the value to 1.

For Automatic proxy configuration URL:

  • Enter “proxy” in the Filter box.
  • Double click “network.proxy.autoconfig_url” and enter the URL. The port number must be in the URL.
  • Double click “network.proxy.type” and change the value to 2.

I give the credit to mozillaZine which has provided this information at their site. you might want to check more information there. hope this helps.

Filed under: thunderbird