27.04.2013 Views

330 Java Tips.pdf - FTP Server

330 Java Tips.pdf - FTP Server

330 Java Tips.pdf - FTP Server

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Graphics, AWT, Swing II part<br />

--<br />

John A.Cruz<br />

Q: How can I force <strong>Java</strong> not to draw the background?<br />

I have the following problem: I display a .gif image on a panel with the g.drawIcon()<br />

method. If I now display the image of a car on a track then the background of the<br />

image (black) gets displayed, too.<br />

How can I force java not to draw the background?<br />

I tried the setXORMode(Color col) method which filters the given color out but this<br />

ruins my image.<br />

Answer: Just make your GIF image have a transparent background. <strong>Java</strong> already<br />

handles drawing GIFs with transparency. The black color in your car image is not the<br />

transparency color of your image.<br />

-dalal<br />

Q: I was wondering how to create a Directory Dialog, just like the FileDialog<br />

class, but for selecting directories instead of files.<br />

I'm sure this has been done, and I apologize if it is in a FAQ. Just point me in a<br />

direction, and I will go. Swing or AWT is fine.<br />

Answer: In Swing, you can use JFileChooser and set it up to choose a directory. See<br />

the API docs for details.<br />

--<br />

Chris Smith<br />

Q: Can any one please tell me whether I can create a Window/JFrame in <strong>Java</strong><br />

that is not rectangular in shape?<br />

If the answer is yes, then where can I get the information to do that?<br />

Answer: Unfortunately answer is "No"...<br />

Pick your topics, and we'll send you great deals, free<br />

information, and special offers by email from Focalex.<br />

IT Professional General Computer Design and Graphics Linux Freeware/Shareware<br />

Games Intranet Computer Hardware Web Design Computer Software<br />

UNIX Web Software Windows Software Personal Finance Programming Software<br />

<strong>Server</strong>s C/C++ Powerbuilder Perl XML<br />

<strong>Java</strong> SQL Design/Graphics Utilities Handhelds<br />

Get FREE STUFF, special offers and information on the <strong>Java</strong>, C/C++,<br />

SQL, XML and another languages programming topics YOU want to hear<br />

about delivered to your inbox!<br />

Unix, Windows Software/HardWare, Handhelds - just pick YOUR<br />

interests and start getting the stuff you want today. The best<br />

free info and deals on computers, software and much more by email.<br />

SUBSCRIBE for FREE HERE<br />

file:///F|/350_t/350_tips/graphics-II.htm (5 of 6) [2002-02-27 21:18:10]

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!