Easy to Learn Java: Programming Articles, Examples and Tips

Start with Java in a few days with Java Lessons or Lectures


Code Examples

Java Tools

More Java Tools!

Java Forum

All Java Tips


Submit News
Search the site here...
Search the JavaFAQ.nu
1000 Java Tips ebook

1000 Java Tips - Click here for the high resolution copy!1000 Java Tips - Click here for the high resolution copy!

Java Screensaver, take it here

Free "1000 Java Tips" eBook is here! It is huge collection of big and small Java programming articles and tips. Please take your copy here.

Take your copy of free "Java Technology Screensaver"!.

Java Newsletters Archive: 164

JavaFAQ Home » Java Newsletters Go to all tips in Java Newsletters

Bookmark and Share

=== [ The Java FAQ Daily Tips, weekly publication ] ===

Issue No: 164 8 May 2003
12693 subscribers

Foreword: Excuse me for possible mistakes. English is not native language for me.

In this issue:
  • 1. I want to use progress bar for downloading files from Internet. But how do I know in advance the file size and then show the progress of downloading?
  • 2. Are classes implementing Externalizable considered Serializable classes?
  • 3. Latest posts on our message board
  • 4. Link to Java FAQ

  • Hello dear friends!

    Tip 1

    Question: I want to use progress bar for downloading files from Internet. But how do I know in advance the file size and then show the progress of downloading?

    Answer: First, try to get file size by:

    int filesize = yourURL.openConnection().getContentLength();
    if it returns -1 then you really do not know the file size.

    Second step in this case will be to use progress bar in indeterminate mode - Mozilla like. This is available since Java 1.4. In this mode, the progress bar displays animation to indicate that work is occurring. As soon as the program determines the length of the task, you should switch the progress bar back into its default, determinate mode.

    Tip 2

    Question: Are classes implementing Externalizable considered Serializable classes?

    Answer: Yes, since public interface Externalizable extends Serializable (according to API)

    Latest posts on our message board

    Setting out java gui code

    Hi. I'm kinda relatively new to creating gui's and i kinda get some of the concepts in swing. However, I'm slowly finding that I'm coding everything in one class which is pretty bad since i'm writing a relatively thick gui client.
    Are there any patterns or anything of the sort for laying out swing code?
    more read here

    Help W/ Binary File Downloading from http server!

    I am attempting to write a program which will download multiple zip files from specified websites. I am having problems though, when the http server requires a domain, name and password. The password also has unusual characters in it, such as #, and /. The program currently creates a listing of all the files to be downloaded and puts them into an array, but I would really like it to go one step further, and actually have it download them, which I haven't gotten to work yet. I would greatly appreciate any info on how to download binary files through http connections requiring windows style logons.
    more read here

    blinking minimised window

    I wanted to implement blinking minimised window when any new message comes to me like the ones in the messenger.
    I am working in linux
    more read here

    sockets ,force close and garbage collection

    I have developed a server application that can accept one connection at a time. One of the server options is that the client can request to chat with the server.If this is the case, the the server opens a chat window which uses another class 'chatserver' in order to wait for and accept connection. However, i found out that if the user on the server closes the ChatGui of the server (maybe because they finished chatting) and they reopen it after about 4 minutes a bind exception will be thrown. After testing i found out that the Gui is disposed but the serversocket still waits and accepts connections while another gui opens and tries to bind the same port. i have a cleanup method that closes I/O streams and closes the serversocket and socket objects as well.
    Does anyone have anyidea how to force the server socket release the specific port?
    Thank you in advance.
    more read here

    when i compile i get a grey screen?!?!?

    When I compile my program and run it I get a grey screen? It compiles okay with no errors. Any know where i could be going wrong?
    more read here


    I have a password box that will be linked to a database. Once the users enter their password they will have another panel where they can register their hobbies. It is not for the net but simply on JBuilder for the moment. I had no problem setting up the GUI for both the password and the other panel (the database link will be for later!) but as I'm a very novice programmer I don't know how to link the two so that on a user's screen there is a smooth transition between the password and the hobby panel. The password class looks like this:
    more read here

    JPopupMenu removing borders / insets


    I have a popup menu but, though I remove the borders, there is still space at the top and bottom of the JPopupMenu. There is also a white line at the left side and a grey line (or component?) on the right of the JPopupMenu. How can I remove this space / lines from a JPopupMenu? Is this something that can be done through methods of the Swing components or is it necessary to use L&F API to remove these insets and borders?
    more read here

    Please ask your questions and help each other at our Java Forum:

    The Java FAQ Daily Tips is a newsletter that is only sent to those who have specifically subscribed to it (double opt-in).

    To subscribe/unsubscribe to "The Java FAQ Daily Tips" weekly edition newsletter visit our page here:

    If you have troubles please contact us: subscription@javafaq.nu

    Link to Java FAQ

    If you have added a link to http://javafaq.nu on your WEB-site, please let us know and you will get listed on our
    "pages linking to us" pages! If your page is a programming is programming relates you will of course get listed in the WEB-directory as well. Also, if you link to us, you have a chance to be listed in this newsletter as well.

    More information and graphics artworks can be found here


    For information on advertising on the Java FAQ's Daily Tips Newsletter, send an email to: adv@javafaq.nu
    You will get the answer immediately from auto responder!

    Send your comments, questions, praise and complaints to us: comments@javafaq.nu

    Copyright (c) 2000 - 2003 John Andersson, All rights reserved.

     Printer Friendly Page  Printer Friendly Page
     Send to a Friend  Send to a Friend

    .. Bookmark and Share

    Search here again if you need more info!
    Custom Search

    Home Code Examples Java Forum All Java Tips Books Submit News, Code... Search... Offshore Software Tech Doodling

    RSS feed Java FAQ RSS feed Java FAQ News     

        RSS feed Java Forums RSS feed Java Forums

    All logos and trademarks in this site are property of their respective owner. The comments are property of their posters, all the rest 1999-2006 by Java FAQs Daily Tips.

    Interactive software released under GNU GPL, Code Credits, Privacy Policy