Coding on a Picture in Java

Hi guys,
i have a project to do and it has to be done in Java, unfortunately i'm not too good with java.
I need to create a Matrix in java and at the same time try and superimpose a picture on it.
The picture will be that of a street intersection that i have created in paint.
i was able to create an application and have it split into a matrix but i didnt want to set the
background color of each cell in order for it to look like a map, is there any other way of
importing a picture onto the application?
So basically i need the application to look like a street map while it is split in a matrix so that
i can have specific code related to each cell.
Thanks in advance.

sounds like a scenario where custom painting is best.
http://java.sun.com/docs/books/tutorial/uiswing/painting/

Similar Messages

  • 2007 Macbook Pro suddenly coding over files, pictures, deleting itunes and iphoto albums, after it had been dropped in late november 2010. Apple specialists say they cannot find anything wrong. HELP!

    I have a Macbook Pro, the last generation, not the most recent one. It fell about 2 feet in late November 2010 and had the screen and logicboard replaced right after. A day or two after that, I started to notice that my word documents, pictures files, pdf files, itunes library and iphoto library were coded over and deleted out of nowhere. When I click on it, it says it is not a compatible format or cannot be read, etc. However, this doesn't happen all the time and not with every file. I could open a new word document and begin it today, and tomorrow it will not be retreavable, but I have a document on my desktop that has been there since January and can still be opened, so this happens without warning.
    I have taken it in to the Genius Bar at my local Apple store several times with this problem, and they say they cannot see anything wrong with my computer. On my most recent visit, the lady told me to buy an external hardrive, transfer everything onto it, then do a complete clean out of my computer and reboot it I guess. If it doesn't continue, then that might have been the problem, but if it does continue, then it is obviously not that. I am really confused and I don't know if I should trust that this is the problem or just go ahead and buy a new computer all together. I don't have applecare anymore.
    Help me!!! I am desperate.

    Does your MBP still have its original hard drive? If so, it may have started to go south. The average useful life of a notebook drive is 3-5 years, and if yours is the original, it would be about 4 years old. The drop could also have affected it.
    It might be worth booting from your install disc and repairing your boot disk. It sounds like you could have some directory issues. Repair until there is nothing left to repair. If Disk Utility cannot repair the drive, you will need a stronger utility like Disk Warrior or possibly a new drive.
    It also sounds like you may have some software corruption, which can happen if you have hard drive problems. Have you tried reinstalling the OS? You would want to make a backup first on an external drive and then use the archive and install feature and then update the OS.
    You might want to download and run SMART Utility:
    http://www.volitans-software.com/smart_utility.php
    You can download the demo and run it several times for free. SMART Utility seems to be somewhat more critical than Disk Utility, and may be able to detect impending drive failure sooner.
    If the drive checks out OK, then you can follow the advice you got from the genius and make a clone of your boot drive using Super Duper or carbon Copy Cloner on the external drive. You could boot from the clone you made and see how your Mac does when booted from a different drive. If all is good, you can reformat the internal drive and clone back to it.
    If all you need is a replacement hard drive, then your Mac is likely worth fixing. I too have a 2007 MBP, and I replaced my hard drive right after Applecare expired, as the drive started to fail a week after Applecare ran out. I put in a Western Digital 500 GB 7200 RPM Scorpio Black, and have been running on it ever since. I have also upped my RAM to 6 GB and my OS to Lion. Not all the features of Lion work on a 2007 MBP--the trackpad does not support Gestures, and AirDrop is not supported. Even so, I expect this Mac to last me a few more years.
    iFixit has instructions for replacing the hard drive, and OWC has both good RAM and kits for hard drive replacements. My gut feeling is that your hard drive is behind the weird symptoms you are experiencing.
    If you are ready for a new computer, by all means get one--there are some great choices. However, you should be able to fix your old Mac for not very much money and get some more use out of it.
    Good luck!

  • Tips on avoiding hard coded paths and make a java app platform independent

    HI all,
    I would like to gather some tips on how to avoid hard coded file paths, which are plenty in the application I work on and which I inherited from previous programmers.
    Also, when deploying to the production server, my app goes from a Windows platform to a Linux machine.
    I am curious to know what tricks and tools other programmers find useful in similar contexts.
    I am sure many of us would benefit from the discussion.
    Thank you !

    Actually, Java does this for you; you can use unix-style paths and they will still work, even on Windoze. To wit:
    public static void main(String[] args) {
            File f = new File("/");
            System.out.println(f.getAbsolutePath());
    }Yields: C:\
    public static void main(String[] args) {
            File f = new File("/Program Files");
            System.out.println(f.getAbsolutePath());
    }Yields: C:\Program Files

  • Help!! Editing Pictures in Java???

    I'm working on a program that can change the color of a image picture (.gif, .jpg/jpeg, etch),, is there a way how can i do this using java,, thx

    Most certainly. If you care to explain what "change the color of a picture" is supposed to mean in detail, people might be even able to tell you how.

  • Tool to make easy code for making pictures in java

    e.g.
    g.drawLine(10,10,50,100)
    Is there a simple tool where I can draw a line on a screen and that that tool gives me then the right coordinates to put it in the java code?
    Of course this simple line is just an example.
    I want to use this to create advanced pictures in a Java applet.
    I hope you guys understand what I mean. I'm from Belgium and my English is not very very good.
    thx for reading this!

    I'm searching just for a more simple tool with interface of Paint for example where I can make pictures. That tool gives than the right code in java.
    Just like when you in eg Dreamweaver make a webpage and then gereates the html code.
    I'm almost sure this must exist but I can't find a tool like that... :-(

  • How to import a picture in java

    hello can annyone help me with my problem, i have tried various ways to import a picture but i cant seem to find the correct way. Can annyone help me with this problem that would be great. You all have my thanks

    Add this class and change the image to your own...
    import java.awt.*;
    public class Viewer extends Canvas {
         private Image image;
         public Viewer()
              image = Toolkit.getDefaultToolkit().getImage("someDirectory/someImage.gif");
              MediaTracker mediaTracker = new MediaTracker(this);
              mediaTracker.addImage(image, 0);
              try
                   mediaTracker.waitForID(0);
              catch (InterruptedException ie)
                   System.err.println(ie);
                   System.exit(1);
         public void paint(Graphics g)
              g.drawImage(image, 0, 0, this);
    }Then in your main program you can call it liek this...
    Viewer pic = new Viewer(); Then just add pic to your frame where you want it to appear

  • Centered Components (table, picture or java applet)

    I'm a beginner using Dreamweaver cs3. I've centered a
    background image vertically and horizontally within the page, but
    can't seem to get anything else to align with it.
    Question: Is there a way to align a table, image, or java
    applet vertically as well as horizontally?
    Or maybe you've got a better solution for me. Take a look at
    this link:
    http://www.charbelaflowers.com/index11.html
    I'm trying to center the guitar (which uses durius waterpic
    applet) exactly in the middle of the wooden background so that even
    when the window is resized, it still remains in the middle.
    Any help is appreciated!

    > but can't seem to get anything else to align with it.
    Trying to align page content with background images is a
    losing proposition.
    > Question: Is there a way to align a table, image, or
    java applet
    > vertically
    > as well as horizontally?
    In general, most likely not, but it would depend entirely on
    your page
    layout and its infrastructure.
    >which uses durius waterpic applet
    I wouldn't touch those with a 10-foot pole. Many people do
    not have the
    Java engine installed, and would therefore just see an ugly
    gray box, or in
    my case, a white box with a puzzle icon in it and a link to
    download the
    applet engine. Plus your page takes a big hit on the weight
    of the applet,
    not to mention the 232K background image (at least 4 times
    heavier than what
    should be your total page weight). It's not worth the effort
    in my opinion.
    Murray --- ICQ 71997575
    Adobe Community Expert
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    http://www.projectseven.com/go
    - DW FAQs, Tutorials & Resources
    http://www.dwfaq.com - DW FAQs,
    Tutorials & Resources
    ==================
    "tgnylu" <[email protected]> wrote in
    message
    news:fj0qhd$pfd$[email protected]..
    > I'm a beginner using Dreamweaver cs3. I've centered a
    background image
    > vertically and horizontally within the page, but can't
    seem to get
    > anything
    > else to align with it.
    >
    >
    > Or maybe you've got a better solution for me. Take a
    look at this link:
    >
    http://www.charbelaflowers.com/index11.html
    >
    > I'm trying to center the guitar (which uses durius
    waterpic applet)
    > exactly in
    > the middle of the wooden background so that even when
    the window is
    > resized, it
    > still remains in the middle.
    >
    > Any help is appreciated!
    >

  • "WRITE CODE FOR ME"

    SALAM COMPUTER SIR,
    I AM STUDENT OF COMPUTER SOFTWARE ENGINEERING .PLEASE HELP ME ABOUT I SEND YOU PICTURE OF MY PROJECT.PLEASE YOU MADE CODING FOR THE PICTURE IN JAVA LANGUAGE.PLEASE YOU GIVE ME SOURCE CODE OF THIS PROJECT PICTURE IN JAVA LANGUAGE.MY ENGLISH LANGUAGE IS VERY WEAK.PLEASE YOU SEND ME SOURCES CODE OF THIS BANK PROJECT.THIS IS 1ST PICTUTE OF BANK PROJECT.YOUR WEBSITE IS VERY GOOD.MY E_MAIL ADDRESS IS [email protected] IF YOU SEND ME E_MAIL.
    THANKS SIR
    http://www.codeguru.com/forum/showthread.php?t=367047
    THIS IS MY 1ST PICTURE OF MY JAVA BANK PROJECT.

    try to study this:
    Creating a GUI with JFC/Swing
    http://java.sun.com/docs/books/tutorial/uiswing/

  • How To Upload Picture And adding sound

    Hi all...
    Anyone if you know how to upload picture in java application and adding sound plz try to help me thx..
    I need the coding for this 2 for my java application urgently//!!! I am currently using JFrame as my GUI.

    Eh
    Upload a picture, to what? Your PDA, an FTP server, what?
    and adding sound to the picture? or just to the application? Do you want a simple "Beep", or more?
    I need the coding for this 2 for my java application urgently
    Thats nice, I can take it then you have read the [url http://java.sun.com/docs/books/tutorial/index.html]tutorials, search google and the forums, and then posted here? It would be much faster.
    I am currently using JFrame as my GUI
    Good for you.

  • Error while Uploading the docs into KM using webdynpro for java

    In My view I have create a context node(ctx_va_FileData) with value attribute (ctx_va_FileResource) of type ,Resource.
    Select the Simple Type, navigate to Dictionaries u2192 Local Dictionary u2192com.sap.ide.webdynpro.uielementdefinitions and select Resource.
    In View part of Layout :Create one u201CFileUpload u201C UI with Create one LinkToAction IU element and assign u201CaUploadFileinto_KMu201D action to this action
    Coding Part in Web Dynpro java
    Step 1:
    Go to the wdDoInit() method and paste the following code
    public void wdDoInit()
    //@@begin wdDoInit()
    try {
    IPrivateUploadFile_KMView.ICtx_vn_FileDataElement element = wdContext.createCtx_vn_FileDataElement();
    if (element != null)
    wdContext.nodeCtx_vn_FileData().bind(element);
    }catch (Exception e) {
    wdComponentAPI.getMessageManager().reportSuccess("Error: " + e.getCause().toString());
    //@@end
    Go to the onActionaUploadFileinto_KM and paste the following code
    public void onActionaUploadFileinto_KM(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
    //@@begin onActionaUploadFileinto_KM(ServerEvent)
    msgMgr = wdComponentAPI.getMessageManager();
    IPrivateUploadFile_KMView.ICtx_vn_FileDataElement element =
    wdcontext.currentCtx_vn_FileDataElement();
    IWDResource resource = element.getCtx_va_FileResource();
    if(resource!=null){
    try {
    //To get the Current User
    IWDClientUser wdClientUser = WDClientUser.getCurrentUser();
    com.sap.security.api.IUser sapUser = wdClientUser.getSAPUser();
    com.sapportals.portal.security.usermanagement.IUser ep5User =
    WPUMFactory.getUserFactory().getEP5User(sapUser);
    ResourceContext resourseContext = new ResourceContext(ep5User);
    //Portal KM Path
    RID pathRID = RID.getRID("/documents/SDN"); //Root Directory
    IResourceFactory resourseFactory =
    com.sapportals.wcm.repository.ResourceFactory.getInstance();
    ICollection collection = (ICollection)resourseFactory.getResource(pathRID,
    resourseContext);
    //Read the File
    InputStream stream = resource.read(true);
    String resourceName = resource.getResourceName();
    String resourceExtn = resource.getResourceType().getFileExtension();
    //KM Content
    Content cont = new Content(stream,"application/octet-stream",-1,"UTF-16");
    //create a file in above mentioned path in KM
    com.sapportals.wcm.repository.IResource new_resource =
    (com.sapportals.wcm.repository.IResource)collection.
    createResource(resourceName, null, cont);
    //Get the File length
    long contentLen = new_resource.getContent().getContentLength();
    //If no data in file
    if(contentLen <= 0){
    msgMgr.reportException("No data in file" , true);
    }else {
    msgMgr.reportMessage(IMessageUploadFile_KMComp.SF__UPLOAD,
    new Object[] {resourceName},true);
    } catch (NotSupportedException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    } catch (AccessDeniedException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    } catch (WDUMException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    } catch (ResourceException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    } catch (ContentException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    } catch (UserManagementException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    } catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }else
    msgMgr.reportException("No file Selected ,Browse the file!",true);
    element.setCtx_va_FileResource(null);
    }//End of Action
    But in the  onActionaUploadFileinto_KM  part  IUser is deprecated and i m stuck at that point.
    Plz provide me the solution and is there ant alternative solution for this and MY Portal is EP6 Nwds version is 7.0.9

    Hi Sukalyan,
    Have you checked the below links?
    These will give you step by step implementation procedure.
    http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/a099a3bd-17ef-2b10-e6ac-9c1ea42af0e9?quicklink=index&overridelayout=true
    http://wiki.sdn.sap.com/wiki/display/WDJava/KmuploadusingWebdynproapplication
    Regards,
    Sandip

  • To launch a java application in Windows environment

    hello,
    I need to distribute one stand alone application, that I made using NetBeans, for sale it.
    I know that this is not a so simple problem, because delivering the program to one client you cannot simlpy say him to launch the jar file....
    I saw that, in the Windows environment, program like eclipse or netBeans run thruogth an .exe file, that I think is a program that its purpose is to define the java environment for the application in the particular host operative environment .
    Perhaps they are corporations like InstallShield (now Macrovision) that sale programs to solve this type of problems..., and I already used this type of programs to install some my
    applications that I coded in languages different than java.
    But before to look for one of them, I should like have more informations how this problem fits in java language, knowing that java is different to other languages because use JRE and have proper tools, how JWS and JNPL, that concern with this problem.
    ...Looking in the forum I had not much help..., but I saw that someone uses to write launchers program in different language, like C, as well I had not so much detailled instructions about how to do it.
    In order to solve my problem I should like have, from some one that already made it, some general information about how he realized the commercial installation of java applications in the most used Operatve Systems (particullary Windows), and possibly to have links to web sites for good explanations, including advantages to buy apposite commercials installation programs too.
    thank you very much
    tonyMrsangelo

    You can distribute it as an executable JAR so users will run it by double clicking. The would be required to have JRE installed.
    You can distribute it online via WebStart. Users need JRE but it's easier to manage updates and distribution of new versions.
    You can distribute it with AjaxSwing, a product that deploys Swing applications as AJAX websites so you don't need JRE at all.
    You can create EXE files using many of the products available. Google for it and you'll get lots of hits.

  • Javax.naming.NameNotFoundException: Name java:comp is not bound in this Con

    Hi
    I have developed a search servlet and deployed it in tomcat 4.0.3 and connected to mysql database through jdbc by specifying jndi.
    I have coded JNDI lokkup name as "java:comp/env/jdbc/KgoogleDB"
    I have added a context in server.xml file of tomcat for DBCP connection pooling .I have tested this in windows and it is running well in it.
    But when i hosted this in linux i got error like this
    INIT OF SEARCH SERVLET
    Error in file reading Connection refused
    File Not Found
    javax.naming.NameNotFoundException: Name java:comp is not bound in this Context
    at org.apache.naming.NamingContext.lookup(NamingContext.java:811)
    at org.apache.naming.NamingContext.lookup(NamingContext.java:194)
    at javax.naming.InitialContext.lookup(InitialContext.java:354)
    at DbConnect.getConnection(DbConnect.java:35)
    at QueryDetails.Query(QueryDetails.java:32)
    at Search.doPost(Search.java:66)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at org.apache.catalina.servlets.InvokerServlet.serveRequest(InvokerServlet.java:446)
    at org.apache.catalina.servlets.InvokerServlet.doPost(InvokerServlet.java:216)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
    at filters.ExampleFilter.doFilter(ExampleFilter.java:149)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:213)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
    at filters.ExampleFilter.doFilter(ExampleFilter.java:149)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:213)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243)
    at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:190)
    at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:475)
    at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
    at org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve.java:246)
    at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
    at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2343)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
    at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
    at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
    at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170)
    at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
    at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
    at org.apache.catalina.connector.warp.WarpRequestHandler.handle(WarpRequestHandler.java:217)
    at org.apache.catalina.connector.warp.WarpConnection.run(WarpConnection.java:194)
    at java.lang.Thread.run(Thread.java:536)
    Connection ID null
    Entered FINALLY
    =================================
    What would be the cause of this error?.Please help me.
    My server.xml context is
    - <Host className="org.apache.catalina.connector.warp.WarpHost" name="www.keralagoogle.com" debug="0" appBase="/domains/www.yy.com/tomcat/webapps" unpackWARs="true">
    - <Context path="/yyjava" docBase="/domains/www.yy.com/tomcat/webapps/yyjava" debug="0" reloadable="true" crossContext="true">
    <Logger className="org.apache.catalina.logger.FileLogger" prefix="localhost_KgoogleDB." suffix=".txt" timestamp="true" />
    <Resource name="jdbc/KgoogleDB" auth="Container" type="javax.sql.DataSource" />
    - <ResourceParams name="jdbc/KgoogleDB">
    - <parameter>
    <name>factory</name>
    <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
    </parameter>
    - <!--
    Maximum number of dB connections in pool. Make sure you
              configure your mysqld max_connections large enough to handle
              all of your db connections. Set to 0 for no limit.
    -->
    - <parameter>
    <name>maxActive</name>
    <value>500</value>
    </parameter>
    - <!--
    Maximum number of idle dB connections to retain in pool.
              Set to 0 for no limit.
    -->
    - <parameter>
    <name>maxIdle</name>
    <value>300</value>
    </parameter>
    - <!--
    Maximum time to wait for a dB connection to become available
              in ms, in this example 10 seconds. An Exception is thrown if
              this timeout is exceeded. Set to -1 to wait indefinitely.
    -->
    - <parameter>
    <name>maxWait</name>
    <value>12000</value>
    </parameter>
    - <!-- MySQL dB username and password for dB connections
    -->
    - <parameter>
    <name>username</name>
    <value>pratap</value>
    </parameter>
    - <parameter>
    <name>password</name>
    <value>ky67yumXg</value>
    </parameter>
    - <!-- Class name for mm.mysql JDBC driver
    -->
    - <parameter>
    <name>driverClassName</name>
    <value>com.mysql.jdbc.Driver</value>
    </parameter>
    - <!--
    The JDBC connection url for connecting to your MySQL dB.
              The autoReconnect=true argument to the url makes sure that the
              mm.mysql JDBC Driver will automatically reconnect if mysqld closed the
              connection. mysqld by default closes idle connections after 8 hours.
    -->
    - <parameter>
    <name>url</name>
    <value>jdbc:mysql://localhost:3306/kgoogle?</value>
    </parameter>
    </ResourceParams>
    </Context>
    ==============================
    Please help me find if i have to change the syntax for linux in the above code.
    Thanks in Advance
    Prathap

    hi
    Thanks for your advise.
    But when i chenged my web.xml and jndi name in my servlet file i got error like this
    javax.naming.NameNotFoundException: Name jdbc is not bound in this Context
    at org.apache.naming.NamingContext.lookup(NamingContext.java:811)
    at org.apache.naming.NamingContext.lookup(NamingContext.java:194)
    at org.apache.naming.SelectorContext.lookup(SelectorContext.java:183)
    at javax.naming.InitialContext.lookup(InitialContext.java:354)
    at DbConnect.getConnection(DbConnect.java:35)
    at QueryDetails.Query(QueryDetails.java:32)
    at Search.doPost(Search.java:66)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at org.apache.catalina.servlets.InvokerServlet.serveRequest(InvokerServl
    et.java:446)
    at org.apache.catalina.servlets.InvokerServlet.doPost(InvokerServlet.jav
    a:216)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
    icationFilterChain.java:247)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
    ilterChain.java:193)
    at filters.ExampleFilter.doFilter(ExampleFilter.java:149)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
    icationFilterChain.java:213)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
    ilterChain.java:193)
    at filters.ExampleFilter.doFilter(ExampleFilter.java:149)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
    icationFilterChain.java:213)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
    ilterChain.java:193)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
    alve.java:243)
    at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline
    .java:566)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
    a:472)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
    alve.java:190)
    at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline
    .java:566)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(Authentica
    torBase.java:475)
    at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline
    .java:564)
    at org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve
    .java:246)
    at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline
    .java:564)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
    a:472)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
    at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:
    2343)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
    ava:180)
    at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline
    .java:566)
    at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatche
    rValve.java:170)
    at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline
    .java:564)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
    ava:170)
    at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline
    .java:564)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:
    468)
    at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline
    .java:564)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
    a:472)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
    ve.java:174)
    at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline
    .java:566)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
    a:472)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
    at org.apache.catalina.connector.http.HttpProcessor.process(HttpProcesso
    r.java:1012)
    at org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.ja
    va:1107)
    at java.lang.Thread.run(Thread.java:536)
    Connection ID null
    Entered FINALLY
    Please help me
    Thanks in Advance
    Prathap

  • Java TV Day at JavaOne

    Hi, all,
    I wanted to let you know about a special one+ day track at JavaOne this year focusing on TV:
    Java� Technology in TV: Blu-ray Disc and Cable Day
    at the JavaOne&#8480; Conference in San Francisco
    Thursday, May 10
    Morning General Session: Friday, May 11
    Register Today for $350.
    Please use Priority Code TVD991
    See http://java.sun.com/javaone/sf/javatvday.jsp for details and registration.
    2007 is a landmark year for the adoption of Java� technology for digital television.
    Millions of Java platform-based cable, satellite and IPTV set-top boxes, televisions, and Blu-ray Disc players have shipped within the last year. Cable operators, broadcasters, and movie studios worldwide have begun their shift to standards-based technologies to deliver compelling new content and services onto digital televisions worldwide.
    As a result, a thriving market has emerged for developers who can author content to specifications based on the Java ME Personal Basis Profile, including Multimedia Home Platform (MHP), OpenCable Application Platform (OCAP), Blu-ray Disc Java (BD-J), and Globally Executable MHP (GEM).
    NEW FOR 2007: DIGITAL TV SOFTWARE AND MARKETS
    To support this marketplace, we're pleased to announce a special track of sessions at the 2007 JavaOne&#8480; conference targeting developers interested in gaining an understanding of digital television software technologies and markets. This track will be held on Thursday, May 10, during the JavaOne conference at The Moscone Center in San Francisco. Also included is access to the morning general session with James Gosling on Friday, May 11.
    MOVERS AND SHAKERS: DIRECTION OF THE INDUSTRY
    Produced in conjunction with CableLabs and major motion picture studios, Java Technology in TV: Blu-ray Disc and Cable Day will feature:
    - A kickoff presentation detailing the current status and future prospects for the OCAP and Blu-ray Disc technologies
    - Technical sessions detailing OCAP technical features, APIs, and how to develop OCAP and Globally Executable MHP (GEM) applications
    - The roadmap for future interactive services on cable TV, the challenges of producing Blu-ray Disc Java (BD-J) software titles for Hollywood, and the role of Java technology in IPTV
    - Birds-of-a-feather sessions, including development of Blu-ray Disc Java technology content and a TV technology Q&A session
    - Blu-ray Disc developers contest sponsored by 20th Century Fox Home Video
    THIS TRACK INCLUDES:
    May 10, Technical Sessions:
    - JavaOne Conference TV Track Kickoff Session
    - OCAP: Summary of Technical Features and APIs
    - Java Technology for Interactive TV: Developing and Deploying Effective OCAP Applications
    - OCAP Roadmap and Future Interactive Services on Cable TV
    - Producing Blu-ray Java Software Titles for Hollywood
    - The Role of Java Technology in IPTV
    May 10, Birds-of-a-Feather Sessions:
    - Talk to the Stars: A Discussion of Blu-ray Java Technology
    - TV Technology Q&A
    May 11, Morning general session with James Gosling
    REGISTER TODAY
    In addition to the Java Technology in TV: Blu-ray Disc and Cable Day sessions on May 10, attendees will receive full JavaOne conference materials, and gain admission Thursday to the general session, the JavaOne Pavilion floor, the JavaOne �After Dark� Bash, and to the Friday morning general session with James Gosling.
    Registration for the Java Technology in TV: Blu-ray Disc and Cable Day track is $350.
    Please use Priority Code TVD991
    See http://java.sun.com/javaone/sf/javatvday.jsp for details and registration.
    If you are currently a Java technology developer who would like to learn more about the exciting content development opportunities in the digital television market, or if you are a current television developer looking to gain knowledge and skills applicable to OCAP, BD-J, and related Java technologies, Blu-ray Disc and Cable Day is a must-attend event!
    Copyright � 2007 Sun Microsystems, Inc. All rights reserved. Sun, Sun Microsystems, the Sun logo, Java, the Java Coffee Cup logo, JavaOne, the JavaOne logo, Java Developer Conference, Java Community Process, JCP, 100% Pure Java, Java EE, Java ME, Java SE, Jini, Solaris, "Write Once, Run Anywhere", and all Java-based marks and logos are trademarks or registered trademarks of Sun Microsystems, Inc. in the United States and other countries.
    2007 JavaOne Conference, 999 Skyway Road, Suite 300, San Carlos, CA 94070

    Have a look here at a decent example of Web Cam capture code in JMF....
    if I do say so myself :-)
    http://forum.java.sun.com/thread.jspa?threadID=570463
    Look in initialise(), at line
    formatControl = (FormatControl)player.getControl("javax.media.control.FormatControl" );That's how you get custom controls from a player.
    There's also a call for in Player
    java.awt.Component getControlPanelComponent() which might return an Awt component to control the TV Tuner.
    So you may have to take take component, and add it to the JFrame.
    If that component doesn't do it, then try iterating through
    Control[] Player.getControls()
    to see if there's any tv tuner control there.
    Ps. that code only displays web cam video feed and grabs single photos from it. It won't record video clips. But... it's a good start.
    regards,
    Owen

  • How do I thead a netbeans/ java aplication?

    How would i multithread this?
    i creadted a gui in netbeans to run my antivirus for mac, its coded in version 6 of java, (windows and linux), how would i thread it to output finds and after it scans every 100 files scanned?
    The full files are avalable at www.saveourmacs.com
    * JavaAntivirusView.java
    package saveourmacs;
    import java.net.*;
    import java.io.*;
    import java.util.*;
    import java.text.DecimalFormat;
    import org.jdesktop.application.Action;
    import org.jdesktop.application.ResourceMap;
    import org.jdesktop.application.SingleFrameApplication;
    import org.jdesktop.application.FrameView;
    import org.jdesktop.application.TaskMonitor;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.Timer;
    import javax.swing.Icon;
    import javax.swing.JDialog;
    import javax.swing.JFrame;
    * The application's main frame.
    public class JavaAntivirusView extends FrameView {
        public Signatures sig;
        public boolean virusFound;
        public int count = 1;
        public long before, after, total = 0;
        public DecimalFormat cur;
        public JavaAntivirusView(SingleFrameApplication app) {
            super(app);
            initComponents();
            sig = new Signatures("C:\\Documents and Settings\\Ryan\\Desktop\\MAIN\\main.db", this.textoutput);
            // status bar initialization - message timeout, idle icon and busy animation, etc
            ResourceMap resourceMap = getResourceMap();
            int messageTimeout = resourceMap.getInteger("StatusBar.messageTimeout");
            messageTimer = new Timer(messageTimeout, new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    statusMessageLabel.setText("");
            messageTimer.setRepeats(false);
            int busyAnimationRate = resourceMap.getInteger("StatusBar.busyAnimationRate");
            for (int i = 0; i < busyIcons.length; i++) {
                busyIcons[i] = resourceMap.getIcon("StatusBar.busyIcons[" + i + "]");
            busyIconTimer = new Timer(busyAnimationRate, new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    busyIconIndex = (busyIconIndex + 1) % busyIcons.length;
                    statusAnimationLabel.setIcon(busyIcons[busyIconIndex]);
            idleIcon = resourceMap.getIcon("StatusBar.idleIcon");
            statusAnimationLabel.setIcon(idleIcon);
            progressBar.setVisible(false);
            // connecting action tasks to status bar via TaskMonitor
            TaskMonitor taskMonitor = new TaskMonitor(getApplication().getContext());
            taskMonitor.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
                public void propertyChange(java.beans.PropertyChangeEvent evt) {
                    String propertyName = evt.getPropertyName();
                    if ("started".equals(propertyName)) {
                        if (!busyIconTimer.isRunning()) {
                            statusAnimationLabel.setIcon(busyIcons[0]);
                            busyIconIndex = 0;
                            busyIconTimer.start();
                        progressBar.setVisible(true);
                        progressBar.setIndeterminate(true);
                    } else if ("done".equals(propertyName)) {
                        busyIconTimer.stop();
                        statusAnimationLabel.setIcon(idleIcon);
                        progressBar.setVisible(false);
                        progressBar.setValue(0);
                    } else if ("message".equals(propertyName)) {
                        String text = (String)(evt.getNewValue());
                        statusMessageLabel.setText((text == null) ? "" : text);
                        messageTimer.restart();
                    } else if ("progress".equals(propertyName)) {
                        int value = (Integer)(evt.getNewValue());
                        progressBar.setVisible(true);
                        progressBar.setIndeterminate(false);
                        progressBar.setValue(value);
        @Action
        public void showAboutBox() {
            if (aboutBox == null) {
                JFrame mainFrame = JavaAntivirusApp.getApplication().getMainFrame();
                aboutBox = new JavaAntivirusAboutBox(mainFrame);
                aboutBox.setLocationRelativeTo(mainFrame);
            JavaAntivirusApp.getApplication().show(aboutBox);
        /** This method is called from within the constructor to
         * initialize the form.
         * WARNING: Do NOT modify this code. The content of this method is
         * always regenerated by the Form Editor.
        @SuppressWarnings("unchecked")
        // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
        private void initComponents() {
            mainPanel = new javax.swing.JPanel();
            jScrollPane1 = new javax.swing.JScrollPane();
            textoutput = new javax.swing.JTextArea();
            SelectDirectory = new javax.swing.JButton();
            UpdateDefinitions = new javax.swing.JButton();
            Scan = new javax.swing.JButton();
            Exit = new javax.swing.JButton();
            dirselect = new javax.swing.JTextField();
            jLabel1 = new javax.swing.JLabel();
            jLabel2 = new javax.swing.JLabel();
            menuBar = new javax.swing.JMenuBar();
            javax.swing.JMenu fileMenu = new javax.swing.JMenu();
            javax.swing.JMenuItem exitMenuItem = new javax.swing.JMenuItem();
            javax.swing.JMenu helpMenu = new javax.swing.JMenu();
            javax.swing.JMenuItem aboutMenuItem = new javax.swing.JMenuItem();
            statusPanel = new javax.swing.JPanel();
            javax.swing.JSeparator statusPanelSeparator = new javax.swing.JSeparator();
            statusMessageLabel = new javax.swing.JLabel();
            statusAnimationLabel = new javax.swing.JLabel();
            progressBar = new javax.swing.JProgressBar();
            mainPanel.setName("mainPanel"); // NOI18N
            jScrollPane1.setName("jScrollPane1"); // NOI18N
            textoutput.setColumns(20);
            textoutput.setRows(5);
            textoutput.setName("textoutput"); // NOI18N
            textoutput.addComponentListener(new java.awt.event.ComponentAdapter() {
                public void componentShown(java.awt.event.ComponentEvent evt) {
                    textoutputComponentShown(evt);
            jScrollPane1.setViewportView(textoutput);
            org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(saveourmacs.JavaAntivirusApp.class).getContext().getResourceMap(JavaAntivirusView.class);
            SelectDirectory.setText(resourceMap.getString("SelectDirectory.text")); // NOI18N
            SelectDirectory.setName("SelectDirectory"); // NOI18N
            SelectDirectory.addMouseListener(new java.awt.event.MouseAdapter() {
                public void mousePressed(java.awt.event.MouseEvent evt) {
                    SelectDirectoryMousePressed(evt);
            UpdateDefinitions.setText(resourceMap.getString("UpdateDefinitions.text")); // NOI18N
            UpdateDefinitions.setName("UpdateDefinitions"); // NOI18N
            UpdateDefinitions.addMouseListener(new java.awt.event.MouseAdapter() {
                public void mousePressed(java.awt.event.MouseEvent evt) {
                    UpdateDefinitionsMousePressed(evt);
            Scan.setText(resourceMap.getString("Scan.text")); // NOI18N
            Scan.setName("Scan"); // NOI18N
            Scan.addMouseListener(new java.awt.event.MouseAdapter() {
                public void mousePressed(java.awt.event.MouseEvent evt) {
                    ScanMousePressed(evt);
            Exit.setText(resourceMap.getString("Exit.text")); // NOI18N
            Exit.setName("Exit"); // NOI18N
            Exit.addMouseListener(new java.awt.event.MouseAdapter() {
                public void mousePressed(java.awt.event.MouseEvent evt) {
                    ExitMousePressed(evt);
            dirselect.setText(resourceMap.getString("dirselect.text")); // NOI18N
            dirselect.setName("dirselect"); // NOI18N
            jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N
            jLabel1.setName("jLabel1"); // NOI18N
            jLabel2.setText(resourceMap.getString("jLabel2.text")); // NOI18N
            jLabel2.setName("jLabel2"); // NOI18N
            javax.swing.GroupLayout mainPanelLayout = new javax.swing.GroupLayout(mainPanel);
            mainPanel.setLayout(mainPanelLayout);
            mainPanelLayout.setHorizontalGroup(
                mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(mainPanelLayout.createSequentialGroup()
                    .addContainerGap()
                    .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 381, Short.MAX_VALUE)
                        .addGroup(mainPanelLayout.createSequentialGroup()
                            .addComponent(SelectDirectory)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(UpdateDefinitions)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(Scan)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(Exit))
                        .addGroup(mainPanelLayout.createSequentialGroup()
                            .addComponent(jLabel1)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(dirselect, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                            .addComponent(jLabel2)))
                    .addContainerGap())
            mainPanelLayout.setVerticalGroup(
                mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, mainPanelLayout.createSequentialGroup()
                    .addContainerGap()
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 113, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel1)
                        .addComponent(dirselect, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel2))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(SelectDirectory)
                        .addComponent(UpdateDefinitions)
                        .addComponent(Scan)
                        .addComponent(Exit))
                    .addContainerGap())
            menuBar.setName("menuBar"); // NOI18N
            fileMenu.setText(resourceMap.getString("fileMenu.text")); // NOI18N
            fileMenu.setName("fileMenu"); // NOI18N
            javax.swing.ActionMap actionMap = org.jdesktop.application.Application.getInstance(saveourmacs.JavaAntivirusApp.class).getContext().getActionMap(JavaAntivirusView.class, this);
            exitMenuItem.setAction(actionMap.get("quit")); // NOI18N
            exitMenuItem.setName("exitMenuItem"); // NOI18N
            fileMenu.add(exitMenuItem);
            menuBar.add(fileMenu);
            helpMenu.setText(resourceMap.getString("helpMenu.text")); // NOI18N
            helpMenu.setName("helpMenu"); // NOI18N
            aboutMenuItem.setAction(actionMap.get("showAboutBox")); // NOI18N
            aboutMenuItem.setName("aboutMenuItem"); // NOI18N
            helpMenu.add(aboutMenuItem);
            menuBar.add(helpMenu);
            statusPanel.setName("statusPanel"); // NOI18N
            statusPanelSeparator.setName("statusPanelSeparator"); // NOI18N
            statusMessageLabel.setName("statusMessageLabel"); // NOI18N
            statusAnimationLabel.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
            statusAnimationLabel.setName("statusAnimationLabel"); // NOI18N
            progressBar.setName("progressBar"); // NOI18N
            javax.swing.GroupLayout statusPanelLayout = new javax.swing.GroupLayout(statusPanel);
            statusPanel.setLayout(statusPanelLayout);
            statusPanelLayout.setHorizontalGroup(
                statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addComponent(statusPanelSeparator, javax.swing.GroupLayout.DEFAULT_SIZE, 401, Short.MAX_VALUE)
                .addGroup(statusPanelLayout.createSequentialGroup()
                    .addContainerGap()
                    .addComponent(statusMessageLabel)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 231, Short.MAX_VALUE)
                    .addComponent(progressBar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(statusAnimationLabel)
                    .addContainerGap())
            statusPanelLayout.setVerticalGroup(
                statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(statusPanelLayout.createSequentialGroup()
                    .addComponent(statusPanelSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, 2, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(statusMessageLabel)
                        .addComponent(statusAnimationLabel)
                        .addComponent(progressBar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGap(3, 3, 3))
            setComponent(mainPanel);
            setMenuBar(menuBar);
            setStatusBar(statusPanel);
        }// </editor-fold>//GEN-END:initComponents
    private void ExitMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_ExitMousePressed
    // TODO add your handling code here:
    System.exit(0);//GEN-LAST:event_ExitMousePressed
    private void SelectDirectoryMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_SelectDirectoryMousePressed
    // TODO add your handling code here:
      /*  textoutput.setText(" Initializing...");
        String filename = File.separator+"tmp";
        JFileChooser fc = new JFileChooser(new File(filename));
        // Show open dialog; this method does not return until the dialog is closed
        fc.showOpenDialog(frame);
        File selFile = fc.getSelectedFile();
        // Show save dialog; this method does not return until the dialog is closed
        fc.showSaveDialog(frame);
        selFile = fc.getSelectedFile();
        /*if (aboutBox == null) {
                JFrame mainFrame = JavaAntivirusApp.getApplication().getMainFrame();
                aboutBox = new JavaAntivirusAboutBox(mainFrame);
                aboutBox.setLocationRelativeTo(mainFrame);
            JavaAntivirusApp.getApplication().show(aboutBox); */
        if (aboutBox == null) {
                JFrame mainFrame = JavaAntivirusApp.getApplication().getMainFrame();
                aboutBox = new JavaAntivirusAboutBox(mainFrame);
                aboutBox.setLocationRelativeTo(mainFrame);
            JavaAntivirusApp.getApplication().show(aboutBox);
    }//GEN-LAST:event_SelectDirectoryMousePressed
    private void UpdateDefinitionsMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_UpdateDefinitionsMousePressed
    // TODO add your handling code here:
    /*FTPClient ftpClient = new FTPClient();
    ftpClient.connect("ftp.foo.com", "user01", "pass1234");
    ftpClient.download("C:\\Temp\\", "README.txt");
    // Eventually other operations here ...
    ftpClient.disconnect();*/
    }//GEN-LAST:event_UpdateDefinitionsMousePressed
    private void ScanMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_ScanMousePressed
    // TODO add your handling code here:
        String directorychoose "";
        directorychoose = dirselect.getText();
        if(directroychoose.equals(""))
          directorychoose = "."; 
        cur =  new DecimalFormat(".00");
        File startingDirectory = new File(directorychoose);
        //File startingDirectory = new File(".");
        textoutput.append("Scanning Files.");
        scanDirectory(startingDirectory);
    }//GEN-LAST:event_ScanMousePressed
    private void textoutputComponentShown(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_textoutputComponentShown
      // TODO add your handling code here:
    }//GEN-LAST:event_textoutputComponentShown
    * This program demonstrates how to traverse a directory.
    * @version 1.0
    * @author  Jeffrey M. Hunter  ([email protected])
    * @author  http://www.idevelopment.info
        public void scanDirectory(File dir) {
              if (count % 100 == 0)
                   if ( (total / 1000) < 60 )
                        textoutput.append(count + " files scanned in " + cur.format((double)(total) / 1000) + " seconds.");
                   else
                        textoutput.append(count + " files scanned in " + cur.format((double)(total) / 60000) + " minutes." );               
            if (dir.isDirectory()) {
                String[] children = dir.list();
                for (int i=0; i<children.length; i++) {
                        scanFile(dir.getAbsolutePath() + "\\" +children);
    scanDirectory(new File(dir, children[i]));
         public void scanFile(String fileName)
              before = System.currentTimeMillis();
              File f = new File(fileName);
              virusFound = false;
              count++;
              if ((int)f.length() > Integer.MAX_VALUE) {
                   textoutput.append("Not enough memory to read file.");
                   System.exit(-1);
              //System.out.print ("Scanning " + f + " - ");
              byte[] bytes = new byte[(int)f.length()]; // assume < 2gb
              RandomAccessFile raf = null;
              try
                   raf = new RandomAccessFile(f,"r");
                   raf.readFully(bytes);
                   raf.close();
              catch (Exception e)
                   textoutput.setText(e.toString());
                   //System.exit(-1);
              String fileBytes = new String(bytes);
              for (int i = 0; i < sig.numSigs(); i++)
                   if (fileBytes.indexOf(sig.getSignature(i).getPattern()) > 0 )
                        textoutput.append(sig.getSignature(i).getName() + " Virus Found!");
              after = System.currentTimeMillis();
              total = total + (after - before);
              if (!virusFound)
                   System.out.println("Clean");
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton Exit;
    private javax.swing.JButton Scan;
    private javax.swing.JButton SelectDirectory;
    private javax.swing.JButton UpdateDefinitions;
    private javax.swing.JTextField dirselect;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JPanel mainPanel;
    private javax.swing.JMenuBar menuBar;
    private javax.swing.JProgressBar progressBar;
    private javax.swing.JLabel statusAnimationLabel;
    private javax.swing.JLabel statusMessageLabel;
    private javax.swing.JPanel statusPanel;
    private javax.swing.JTextArea textoutput;
    // End of variables declaration//GEN-END:variables
    private final Timer messageTimer;
    private final Timer busyIconTimer;
    private final Icon idleIcon;
    private final Icon[] busyIcons = new Icon[15];
    private int busyIconIndex = 0;
    private JDialog aboutBox;
    public static void download(String address) {
              int lastSlashIndex = address.lastIndexOf('/');
              if (lastSlashIndex >= 0 &&
              lastSlashIndex < address.length() - 1) {
                   //download(address, address.substring(lastSlashIndex + 1));
              } else {
                   System.err.println("Could not figure out local file name for " +
                        address);
    public static void download(String address, String localFileName) {
              OutputStream out = null;
              URLConnection conn = null;
              InputStream in = null;
              try {
                   URL url = new URL(address);
                   out = new BufferedOutputStream(
                        new FileOutputStream(localFileName));
                   conn = url.openConnection();
                   in = conn.getInputStream();
                   byte[] buffer = new byte[1024];
                   int numRead;
                   long numWritten = 0;
                   while ((numRead = in.read(buffer)) != -1) {
                        out.write(buffer, 0, numRead);
                        numWritten += numRead;
                   System.out.println(localFileName + "\t" + numWritten);
              } catch (Exception exception) {
                   exception.printStackTrace();
              } finally {
                   try {
                        if (in != null) {
                             in.close();
                        if (out != null) {
                             out.close();
                   } catch (IOException ioe) {
    public static void main(String[] args) {
              for (int i = 0; i < args.length; i++) {
                   download(args[i]);
    Edited by: kingryanj on Jun 19, 2008 10:49 AM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    nclow wrote:
    Dumping a huge application in the lap of a stranger and asking them to tell you how to multithread it is a pretty tall order, don't you think? You might try familiarizing yourself with threading concepts here , identifying the parts of your program that you want to split into new threads, and then come back if you have some specific questions.not to mention it sounds like threading is not what the OP even wants
    a simple counter would suffice and every time the counter reaches 100 you could print or whatever and then reset the counter

  • How do I thead a java aplication?

    How would i multithread this?
    i creadted a gui in netbeans to run my antivirus for mac, its coded in version 6 of java, (windows and linux), how would i thread it to output finds and after it scans every 100 files scanned?
    The full files are avalable at www.saveourmacs.com
    * JavaAntivirusView.java
    package saveourmacs;
    import java.net.*;
    import java.io.*;
    import java.util.*;
    import java.text.DecimalFormat;
    import org.jdesktop.application.Action;
    import org.jdesktop.application.ResourceMap;
    import org.jdesktop.application.SingleFrameApplication;
    import org.jdesktop.application.FrameView;
    import org.jdesktop.application.TaskMonitor;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.Timer;
    import javax.swing.Icon;
    import javax.swing.JDialog;
    import javax.swing.JFrame;
    * The application's main frame.
    public class JavaAntivirusView extends FrameView {
        public Signatures sig;
        public boolean virusFound;
        public int count = 1;
        public long before, after, total = 0;
        public DecimalFormat cur;
        public JavaAntivirusView(SingleFrameApplication app) {
            super(app);
            initComponents();
            sig = new Signatures("C:\\Documents and Settings\\Ryan\\Desktop\\MAIN\\main.db", this.textoutput);
            // status bar initialization - message timeout, idle icon and busy animation, etc
            ResourceMap resourceMap = getResourceMap();
            int messageTimeout = resourceMap.getInteger("StatusBar.messageTimeout");
            messageTimer = new Timer(messageTimeout, new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    statusMessageLabel.setText("");
            messageTimer.setRepeats(false);
            int busyAnimationRate = resourceMap.getInteger("StatusBar.busyAnimationRate");
            for (int i = 0; i < busyIcons.length; i++) {
                busyIcons[i] = resourceMap.getIcon("StatusBar.busyIcons[" + i + "]");
            busyIconTimer = new Timer(busyAnimationRate, new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    busyIconIndex = (busyIconIndex + 1) % busyIcons.length;
                    statusAnimationLabel.setIcon(busyIcons[busyIconIndex]);
            idleIcon = resourceMap.getIcon("StatusBar.idleIcon");
            statusAnimationLabel.setIcon(idleIcon);
            progressBar.setVisible(false);
            // connecting action tasks to status bar via TaskMonitor
            TaskMonitor taskMonitor = new TaskMonitor(getApplication().getContext());
            taskMonitor.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
                public void propertyChange(java.beans.PropertyChangeEvent evt) {
                    String propertyName = evt.getPropertyName();
                    if ("started".equals(propertyName)) {
                        if (!busyIconTimer.isRunning()) {
                            statusAnimationLabel.setIcon(busyIcons[0]);
                            busyIconIndex = 0;
                            busyIconTimer.start();
                        progressBar.setVisible(true);
                        progressBar.setIndeterminate(true);
                    } else if ("done".equals(propertyName)) {
                        busyIconTimer.stop();
                        statusAnimationLabel.setIcon(idleIcon);
                        progressBar.setVisible(false);
                        progressBar.setValue(0);
                    } else if ("message".equals(propertyName)) {
                        String text = (String)(evt.getNewValue());
                        statusMessageLabel.setText((text == null) ? "" : text);
                        messageTimer.restart();
                    } else if ("progress".equals(propertyName)) {
                        int value = (Integer)(evt.getNewValue());
                        progressBar.setVisible(true);
                        progressBar.setIndeterminate(false);
                        progressBar.setValue(value);
        @Action
        public void showAboutBox() {
            if (aboutBox == null) {
                JFrame mainFrame = JavaAntivirusApp.getApplication().getMainFrame();
                aboutBox = new JavaAntivirusAboutBox(mainFrame);
                aboutBox.setLocationRelativeTo(mainFrame);
            JavaAntivirusApp.getApplication().show(aboutBox);
        /** This method is called from within the constructor to
         * initialize the form.
         * WARNING: Do NOT modify this code. The content of this method is
         * always regenerated by the Form Editor.
        @SuppressWarnings("unchecked")
        // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
        private void initComponents() {
            mainPanel = new javax.swing.JPanel();
            jScrollPane1 = new javax.swing.JScrollPane();
            textoutput = new javax.swing.JTextArea();
            SelectDirectory = new javax.swing.JButton();
            UpdateDefinitions = new javax.swing.JButton();
            Scan = new javax.swing.JButton();
            Exit = new javax.swing.JButton();
            dirselect = new javax.swing.JTextField();
            jLabel1 = new javax.swing.JLabel();
            jLabel2 = new javax.swing.JLabel();
            menuBar = new javax.swing.JMenuBar();
            javax.swing.JMenu fileMenu = new javax.swing.JMenu();
            javax.swing.JMenuItem exitMenuItem = new javax.swing.JMenuItem();
            javax.swing.JMenu helpMenu = new javax.swing.JMenu();
            javax.swing.JMenuItem aboutMenuItem = new javax.swing.JMenuItem();
            statusPanel = new javax.swing.JPanel();
            javax.swing.JSeparator statusPanelSeparator = new javax.swing.JSeparator();
            statusMessageLabel = new javax.swing.JLabel();
            statusAnimationLabel = new javax.swing.JLabel();
            progressBar = new javax.swing.JProgressBar();
            mainPanel.setName("mainPanel"); // NOI18N
            jScrollPane1.setName("jScrollPane1"); // NOI18N
            textoutput.setColumns(20);
            textoutput.setRows(5);
            textoutput.setName("textoutput"); // NOI18N
            textoutput.addComponentListener(new java.awt.event.ComponentAdapter() {
                public void componentShown(java.awt.event.ComponentEvent evt) {
                    textoutputComponentShown(evt);
            jScrollPane1.setViewportView(textoutput);
            org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(saveourmacs.JavaAntivirusApp.class).getContext().getResourceMap(JavaAntivirusView.class);
            SelectDirectory.setText(resourceMap.getString("SelectDirectory.text")); // NOI18N
            SelectDirectory.setName("SelectDirectory"); // NOI18N
            SelectDirectory.addMouseListener(new java.awt.event.MouseAdapter() {
                public void mousePressed(java.awt.event.MouseEvent evt) {
                    SelectDirectoryMousePressed(evt);
            UpdateDefinitions.setText(resourceMap.getString("UpdateDefinitions.text")); // NOI18N
            UpdateDefinitions.setName("UpdateDefinitions"); // NOI18N
            UpdateDefinitions.addMouseListener(new java.awt.event.MouseAdapter() {
                public void mousePressed(java.awt.event.MouseEvent evt) {
                    UpdateDefinitionsMousePressed(evt);
            Scan.setText(resourceMap.getString("Scan.text")); // NOI18N
            Scan.setName("Scan"); // NOI18N
            Scan.addMouseListener(new java.awt.event.MouseAdapter() {
                public void mousePressed(java.awt.event.MouseEvent evt) {
                    ScanMousePressed(evt);
            Exit.setText(resourceMap.getString("Exit.text")); // NOI18N
            Exit.setName("Exit"); // NOI18N
            Exit.addMouseListener(new java.awt.event.MouseAdapter() {
                public void mousePressed(java.awt.event.MouseEvent evt) {
                    ExitMousePressed(evt);
            dirselect.setText(resourceMap.getString("dirselect.text")); // NOI18N
            dirselect.setName("dirselect"); // NOI18N
            jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N
            jLabel1.setName("jLabel1"); // NOI18N
            jLabel2.setText(resourceMap.getString("jLabel2.text")); // NOI18N
            jLabel2.setName("jLabel2"); // NOI18N
            javax.swing.GroupLayout mainPanelLayout = new javax.swing.GroupLayout(mainPanel);
            mainPanel.setLayout(mainPanelLayout);
            mainPanelLayout.setHorizontalGroup(
                mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(mainPanelLayout.createSequentialGroup()
                    .addContainerGap()
                    .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 381, Short.MAX_VALUE)
                        .addGroup(mainPanelLayout.createSequentialGroup()
                            .addComponent(SelectDirectory)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(UpdateDefinitions)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(Scan)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(Exit))
                        .addGroup(mainPanelLayout.createSequentialGroup()
                            .addComponent(jLabel1)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(dirselect, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                            .addComponent(jLabel2)))
                    .addContainerGap())
            mainPanelLayout.setVerticalGroup(
                mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, mainPanelLayout.createSequentialGroup()
                    .addContainerGap()
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 113, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel1)
                        .addComponent(dirselect, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel2))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(SelectDirectory)
                        .addComponent(UpdateDefinitions)
                        .addComponent(Scan)
                        .addComponent(Exit))
                    .addContainerGap())
            menuBar.setName("menuBar"); // NOI18N
            fileMenu.setText(resourceMap.getString("fileMenu.text")); // NOI18N
            fileMenu.setName("fileMenu"); // NOI18N
            javax.swing.ActionMap actionMap = org.jdesktop.application.Application.getInstance(saveourmacs.JavaAntivirusApp.class).getContext().getActionMap(JavaAntivirusView.class, this);
            exitMenuItem.setAction(actionMap.get("quit")); // NOI18N
            exitMenuItem.setName("exitMenuItem"); // NOI18N
            fileMenu.add(exitMenuItem);
            menuBar.add(fileMenu);
            helpMenu.setText(resourceMap.getString("helpMenu.text")); // NOI18N
            helpMenu.setName("helpMenu"); // NOI18N
            aboutMenuItem.setAction(actionMap.get("showAboutBox")); // NOI18N
            aboutMenuItem.setName("aboutMenuItem"); // NOI18N
            helpMenu.add(aboutMenuItem);
            menuBar.add(helpMenu);
            statusPanel.setName("statusPanel"); // NOI18N
            statusPanelSeparator.setName("statusPanelSeparator"); // NOI18N
            statusMessageLabel.setName("statusMessageLabel"); // NOI18N
            statusAnimationLabel.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
            statusAnimationLabel.setName("statusAnimationLabel"); // NOI18N
            progressBar.setName("progressBar"); // NOI18N
            javax.swing.GroupLayout statusPanelLayout = new javax.swing.GroupLayout(statusPanel);
            statusPanel.setLayout(statusPanelLayout);
            statusPanelLayout.setHorizontalGroup(
                statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addComponent(statusPanelSeparator, javax.swing.GroupLayout.DEFAULT_SIZE, 401, Short.MAX_VALUE)
                .addGroup(statusPanelLayout.createSequentialGroup()
                    .addContainerGap()
                    .addComponent(statusMessageLabel)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 231, Short.MAX_VALUE)
                    .addComponent(progressBar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(statusAnimationLabel)
                    .addContainerGap())
            statusPanelLayout.setVerticalGroup(
                statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(statusPanelLayout.createSequentialGroup()
                    .addComponent(statusPanelSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, 2, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(statusMessageLabel)
                        .addComponent(statusAnimationLabel)
                        .addComponent(progressBar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGap(3, 3, 3))
            setComponent(mainPanel);
            setMenuBar(menuBar);
            setStatusBar(statusPanel);
        }// </editor-fold>//GEN-END:initComponents
    private void ExitMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_ExitMousePressed
    // TODO add your handling code here:
    System.exit(0);//GEN-LAST:event_ExitMousePressed
    private void SelectDirectoryMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_SelectDirectoryMousePressed
    // TODO add your handling code here:
      /*  textoutput.setText(" Initializing...");
        String filename = File.separator+"tmp";
        JFileChooser fc = new JFileChooser(new File(filename));
        // Show open dialog; this method does not return until the dialog is closed
        fc.showOpenDialog(frame);
        File selFile = fc.getSelectedFile();
        // Show save dialog; this method does not return until the dialog is closed
        fc.showSaveDialog(frame);
        selFile = fc.getSelectedFile();
        /*if (aboutBox == null) {
                JFrame mainFrame = JavaAntivirusApp.getApplication().getMainFrame();
                aboutBox = new JavaAntivirusAboutBox(mainFrame);
                aboutBox.setLocationRelativeTo(mainFrame);
            JavaAntivirusApp.getApplication().show(aboutBox); */
        if (aboutBox == null) {
                JFrame mainFrame = JavaAntivirusApp.getApplication().getMainFrame();
                aboutBox = new JavaAntivirusAboutBox(mainFrame);
                aboutBox.setLocationRelativeTo(mainFrame);
            JavaAntivirusApp.getApplication().show(aboutBox);
    }//GEN-LAST:event_SelectDirectoryMousePressed
    private void UpdateDefinitionsMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_UpdateDefinitionsMousePressed
    // TODO add your handling code here:
    /*FTPClient ftpClient = new FTPClient();
    ftpClient.connect("ftp.foo.com", "user01", "pass1234");
    ftpClient.download("C:\\Temp\\", "README.txt");
    // Eventually other operations here ...
    ftpClient.disconnect();*/
    }//GEN-LAST:event_UpdateDefinitionsMousePressed
    private void ScanMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_ScanMousePressed
    // TODO add your handling code here:
        String directorychoose "";
        directorychoose = dirselect.getText();
        if(directroychoose.equals(""))
          directorychoose = "."; 
        cur =  new DecimalFormat(".00");
        File startingDirectory = new File(directorychoose);
        //File startingDirectory = new File(".");
        textoutput.append("Scanning Files.");
        scanDirectory(startingDirectory);
    }//GEN-LAST:event_ScanMousePressed
    private void textoutputComponentShown(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_textoutputComponentShown
      // TODO add your handling code here:
    }//GEN-LAST:event_textoutputComponentShown
    * This program demonstrates how to traverse a directory.
    * @version 1.0
    * @author  Jeffrey M. Hunter  ([email protected])
    * @author  http://www.idevelopment.info
        public void scanDirectory(File dir) {
              if (count % 100 == 0)
                   if ( (total / 1000) < 60 )
                        textoutput.append(count + " files scanned in " + cur.format((double)(total) / 1000) + " seconds.");
                   else
                        textoutput.append(count + " files scanned in " + cur.format((double)(total) / 60000) + " minutes." );               
            if (dir.isDirectory()) {
                String[] children = dir.list();
                for (int i=0; i<children.length; i++) {
                        scanFile(dir.getAbsolutePath() + "\\" +children);
    scanDirectory(new File(dir, children[i]));
         public void scanFile(String fileName)
              before = System.currentTimeMillis();
              File f = new File(fileName);
              virusFound = false;
              count++;
              if ((int)f.length() > Integer.MAX_VALUE) {
                   textoutput.append("Not enough memory to read file.");
                   System.exit(-1);
              //System.out.print ("Scanning " + f + " - ");
              byte[] bytes = new byte[(int)f.length()]; // assume < 2gb
              RandomAccessFile raf = null;
              try
                   raf = new RandomAccessFile(f,"r");
                   raf.readFully(bytes);
                   raf.close();
              catch (Exception e)
                   textoutput.setText(e.toString());
                   //System.exit(-1);
              String fileBytes = new String(bytes);
              for (int i = 0; i < sig.numSigs(); i++)
                   if (fileBytes.indexOf(sig.getSignature(i).getPattern()) > 0 )
                        textoutput.append(sig.getSignature(i).getName() + " Virus Found!");
              after = System.currentTimeMillis();
              total = total + (after - before);
              if (!virusFound)
                   System.out.println("Clean");
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton Exit;
    private javax.swing.JButton Scan;
    private javax.swing.JButton SelectDirectory;
    private javax.swing.JButton UpdateDefinitions;
    private javax.swing.JTextField dirselect;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JPanel mainPanel;
    private javax.swing.JMenuBar menuBar;
    private javax.swing.JProgressBar progressBar;
    private javax.swing.JLabel statusAnimationLabel;
    private javax.swing.JLabel statusMessageLabel;
    private javax.swing.JPanel statusPanel;
    private javax.swing.JTextArea textoutput;
    // End of variables declaration//GEN-END:variables
    private final Timer messageTimer;
    private final Timer busyIconTimer;
    private final Icon idleIcon;
    private final Icon[] busyIcons = new Icon[15];
    private int busyIconIndex = 0;
    private JDialog aboutBox;
    public static void download(String address) {
              int lastSlashIndex = address.lastIndexOf('/');
              if (lastSlashIndex >= 0 &&
              lastSlashIndex < address.length() - 1) {
                   //download(address, address.substring(lastSlashIndex + 1));
              } else {
                   System.err.println("Could not figure out local file name for " +
                        address);
    public static void download(String address, String localFileName) {
              OutputStream out = null;
              URLConnection conn = null;
              InputStream in = null;
              try {
                   URL url = new URL(address);
                   out = new BufferedOutputStream(
                        new FileOutputStream(localFileName));
                   conn = url.openConnection();
                   in = conn.getInputStream();
                   byte[] buffer = new byte[1024];
                   int numRead;
                   long numWritten = 0;
                   while ((numRead = in.read(buffer)) != -1) {
                        out.write(buffer, 0, numRead);
                        numWritten += numRead;
                   System.out.println(localFileName + "\t" + numWritten);
              } catch (Exception exception) {
                   exception.printStackTrace();
              } finally {
                   try {
                        if (in != null) {
                             in.close();
                        if (out != null) {
                             out.close();
                   } catch (IOException ioe) {
    public static void main(String[] args) {
              for (int i = 0; i < args.length; i++) {
                   download(args[i]);
    Edited by: kingryanj on Jun 19, 2008 10:49 AM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    {color:red}{size:16px}CROSS POSTED{size}{color}
    [http://forum.java.sun.com/thread.jspa?threadID=5306819]
    Cross posting is rude.
    db

Maybe you are looking for

  • No subtitles when using Apple Tv

    Hi, I have a lot of mp4/srt movies on my macbook pro! I used an app called subler to convert the movies to m4v and imported then into iTunes. Now Quick Time and iTunes can play the movies with their subs. In both programs the subtitle menus where ena

  • Browser button disppeared...

    Hi, after updating to 7.2, when I open a movie within the browser, the movie play fine but the button below disappeared and basically shown as a black stripe, it still exist I believe because I can still click and scroll on that blindly but the graph

  • GOOP Modified data?

    I have a GOOP class CC containing sub-classes A, B and C. Some common data is owned by the CC class and in additon the sub-classes have their own private data. Now, if I want to modify the data in sub-class A, I call some method for the CC class whic

  • TS3899 I've tried all of the suggestions but my mail still sits in the outbox. Incoming working fine.

    My live.com mail won't send. Have deleted acct and recreated, powered off, closed outlook on my laptop to no avail? Any suggestions?

  • KEY DOWN in event

    When use KEY DOWN in event ,this event triggered for every key (keyboard) press , the question i need event triggered for just 1 key pressed ; for example press F2 the event triggered and no triggered for the other key of keyboard ; thank you Forza J