How to use  Progress Monitors?

how to use Progress Monitors?
in the name of god
hi friends
i have a problem. I am writing a program that read data from a file record by record and store to a database. my problem is here that i want add a progress monitor that when the program is doing its work it appear. I use ProgressMonitorInputStream class but it can not work well. It appear and read file record by record and store in table of database but its progress don’t move and do nothing. I know that I have a tiny problem in use this class. Please guide me.
i put my codes below.
best regards
*////this is an event that invoke my classes*
private void readbtnActionPerformed(java.awt.event.ActionEvent evt) {                                       
        JFileChooser fileChooser = new JFileChooser();
        fileChooser.setCurrentDirectory(fileName);
        //filtering file extension
        FileNameExtensionFilter filter = new FileNameExtensionFilter("Text file", "txt");
        fileChooser.setFileFilter(filter);
        //fileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
        int result = fileChooser.showOpenDialog(this);
        if (result == JFileChooser.APPROVE_OPTION) {   //if choose ok button
            fileName = fileChooser.getSelectedFile();
            ReadTextFile readFile = new ReadTextFile(fileName);
            readFile.openFile();
            readFile.readRecord();
            *//readFile.closeFile();       //if  this line enable this message appeare "Scanner closed" .why?*      
            readFile.closeFile();
        } else //if choose cancel button
            result = 0;     //do nothing
*/////this is readFile class and invoke data access class and insert data in my database*
public class ReadTextFile {
    private Scanner input;
    private File fileName;
    private int i = 1;
    DataAccess dal = new DataAccess();                     //new a defined my class
    AcountRecord record = new AcountRecord();
    public ReadTextFile(File n) {       //Constructor
        fileName = new File(String.valueOf(n));
        this.openFile();
    private void setRecord(String val) {
        try {
            record.setId(Integer.parseInt(val.substring(1, 5)));
            record.setTime(Integer.parseInt(val.substring(8, 12)));
            record.setDate(Integer.parseInt(val.substring(15, 21)));
            record.setMode(val.substring(24, 26));
        } catch (Exception e) {
            JOptionPane.showMessageDialog(null, "ÇäÊÎÇÈ ÔãÇ äÇÏÑÓÊ ÇÓÊ.","Set Record Method",JOptionPane.ERROR_MESSAGE);
    public void openFile() {
        try {
            input = new Scanner(fileName);
        } catch (FileNotFoundException e) {
            JOptionPane.showMessageDialog(null, "ÇäÊÎÇÈ ÔãÇ äÇÏÑÓÊ ÇÓÊ.","Open File Method",JOptionPane.ERROR_MESSAGE);
    public void readRecord() {
        new Thread() {
            private Component _Main;
            @Override
            public void run() {
                try {
                    input = new Scanner(fileName);
                    InputStream in = new FileInputStream(fileName);
                    ProgressMonitorInputStream pm =
                            new ProgressMonitorInputStream(_Main, "reading the file", in);
                    ProgressMonitor pmo = pm.getProgressMonitor( );
                    pmo.setMaximum( (int) fileName.length());
                    while (/*input.hasNext() &&*/ pm.read() != -1) {
                        setRecord(input.next());
                        dal.Connect();
                        String sql = "INSERT INTO fileinfo(pkey,id,date,time,mode)VALUES(%s,%s,%s,%s,'%s')";
                        sql = String.format(sql, i++, record.getId(), record.getDate(), record.getTime(), record.getMode());
                        dal.doCommand(sql);
                } catch (Exception e) {
                    JOptionPane.showMessageDialog(null, e.getMessage() ," Read Record method.",JOptionPane.ERROR_MESSAGE);
                dal.Disconnect();      
        }.start();
    public void closeFile() {
        input.close();
}Edited by: firethumbs on Mar 26, 2009 12:43 PM

IN THE NAME OF GOD
hi firends
i forget say one thing. if remove while loop content this program will work good. i suppose that the while condition and read file records not similar. because while condition check bytes but in while body read records. is that true?
how can solve this problem?
best regurds

Similar Messages

  • How 2 use Progress Monitor.. when u dont know hw long process takes place!

    hello frnds,
    I am trying to use ProgressMonitor.. to show user that required process is taking place.. so wait for a while!!
    what before i was doing is to miimize the frame for that time and popping it again.. :-).. was really silly of me..
    setExtendedState(JFrame.ICONIFIED);
    NewProject();                      // This function takes time..
    setExtendedState(JFrame.NORMAL);I was wondering that cant I use progressmonitor for that time.. but I dont know how long that function runs.. so may be now I have to use separate thread for it..
    well even word THREAD haunts me.. so much.. .. never tried in my code.. If you people helps me how to put thread.. in my code..
    so that I can show dialog ProgressMonitor for that time.. I would be grateful.. even i dont know whther thread is really necessary for what am trying to do.. !!
    Thanking in advance!!
    gervini

    see if this makes any sense
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    class Testing extends JFrame
      ProgressMonitor pmon = null;
      public Testing()
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        setSize(200,100);
        setLocation(200,100);
        JPanel panel = new JPanel();
        JButton btn = new JButton("Run");
        btn.addActionListener(new ActionListener(){
          public void actionPerformed(ActionEvent ae){
            pmon = new ProgressMonitor(null, "","",0, 100);
            new Thread(new LongTask(pmon)).start();}});
        panel.add(btn);
        getContentPane().add(panel);
    public static void main(String[] args){new Testing().setVisible(true);}
    class LongTask implements Runnable
      int percentDone = 0;
      ProgressMonitor pm;
      public LongTask(ProgressMonitor p){pm = p;}
      public void run()
        someMethod();
      public void someMethod()
        for(int x = 0; x < 100000000; x++)
          if(x % 1000000 == 0)
            percentDone++;
            pm.setProgress(percentDone);
            pm.setNote("Task is " + percentDone + "% complete");
            //try{Thread.sleep(200);}catch(InterruptedException ie){}//may need this on a fast pc
          if (pm.isCanceled()) return;
    }

  • How to use dual monitor display in windows 7 using MSTSC command.......??????

    how to use dual monitor display in windows 7 using MSTSC command ....?????

    Hi Anurag,
    The main issue is how to use the dual monitor in the Remote Desktop Session in Windows 7 ,right ?
    please refer to the following links:
    Using Multiple Monitors in Remote Desktop Session
    http://blogs.msdn.com/b/rds/archive/2009/07/01/using-multiple-monitors-in-remote-desktop-session.aspx
    Best regards

  • How to use external monitor with laptop closed

    My external monitor goes to sleep when i close the Macbook Air lid.  How do i stop that from happening?

    Mac notebooks: How to use your computer in closed clamshell ...

  • How to use progress bar for Main and Subsequences in teststand

    HI,
    I have one main sequence in that I am calling different subsequences (Containing many steps and for loop).
    I am trying to use progress bar for this sequence, but my requirement is progressbar is able to show the progress of all the steps containing in Main and subsequences.
    I have developed sequence in that I am able to show the progress for only Main sequence steps not for subsequences steps.
    Is it possible? If yes please let me know the suggestions.
    Thank You

    Hi Santosh
    Here you are
    Greetings
    Juergen
    never Double Click on Submit
    Message Edited by j_dodek on 08-05-2008 08:05 AM
    =s=i=g=n=a=t=u=r=e= Click on the Star and see what happens :-) =s=i=g=n=a=t=u=r=e=
    Attachments:
    Progress_ts351.seq ‏52 KB

  • How To Use Activity Monitor

    Is there a tutorial or something on using Activity Monitor?
    For instance, I'd like to find out what processes are going on to prevent my G4 from shutting down at the scheduled time. (The shutdown deal has been ongoing since first going to OS X.)

    Hi, David.
    1. What specific version of Mac OS X are you using? Your profile information simply states "10.4". See:• If 10.4.5 or earlier, see "Mac OS X's Shut Down schedule will only work when one user is logged in."
    • If 10.4.6 or later, see Mac OS X 10.4.6 or later: Scheduled shut down occurs at Login window even if users are logged in."
    2. Note that your Mac must be awake at the appointed time for scheduled shutdown to work. See "Mac OS X 10.3 and later: Computer must be awake for scheduled shutdown to occur."
    3. You may want to trash the preferences related to scheduling Startup / Shutdown / Sleep:1. Quit (Command-Q) System Preferences if it is open.
    2. There are two preferences files for power management / energy saver settings under Mac OS X 10.4:• If you want to reset the Scheduled Startup and Sleep/Shutdown preferences, trash the file:
    com.apple.AutoWake.plist
    located in the Macintosh HD > Library > Preferences > SystemConfiguration folder. You may be prompted for your Admin password when you trash this file.
    • The Energy Saver preferences related to Computer, Display, and Hard Drive Sleep are saved in the file
    com.apple.PowerManagement.plist
    which is also located in the Macintosh HD > Library > Preferences > SystemConfiguration folder. As before, you may be prompted for your Admin password when you trash this file.3. Empty the Trash.
    4. Launch System Preferences and reset the preferences accordingly.Note that some of the information above is from the "Sleep" and "Shutdown" chapters of my book, Troubleshooting Mac® OS X, Tiger Edition.
    Good luck!
    Dr. Smoke
    Author: Troubleshooting Mac® OS X
    Note: The information provided in the link(s) above is freely available. However, because I own The X Lab™, a commercial Web site to which some of these links point, the Apple Discussions Terms of Use require I include the following disclosure statement with this post:
    I may receive some form of compensation, financial or otherwise, from my recommendation or link.

  • How to use  two monitors with my Mac mini

    Hello,
    I have a Mac mini and using a 20" Samsung Monitor with it which works well. I also have my 40" LCD Samsung telly, set up next to it. Whenever i watch a DVD using my Mac i have to swap over the cables. Is there a way of getting the right cables etc and making it so i would be able to watch a dvd on the 40" and still use the 20" surfing the net etc. I had a similar set up with my old windows laptop, but cant seem to work out how do it with the mac. Both monitors have modern sockets, the 40in has HDMI/DVI IN and AGV, the 20" has AGV and HDCP/DVI IN. Many thanks.

    To the best of my knowledge there is no way to use dual displays on the Mini. You may be able to find some adapter that will allow you to physically connect two displays, but they will be mirrored, not spanned.
    To do what you describe would take spanning, which the Mini is not capable of doing. Unless something has changed recently,..

  • How to use Progressive video in aggregated file

    I'm using Captivate 5 and have several .swf modules to publish along with their supporting video files (progressive download). 
    How can I package these into an executable or aggregated output so the videos play?  I can't load the videos into the aggregated file, therefore the videos don't play.
    It would be great if there was a way to imbed these videos into Captivate, but I don't think that's possible and the company hasn't purchased Flash to use that as an option.
    I also can't seem to get a large aggregated or executable file to run.  It just has the loader, and doesn't show anything else.
    I can chunk it into thrids, but I'm just wondering if there's another way to publish this for use as one file, instead of 13 different modules.
    Any ideas or suggestions?  Thank You!!!

    What major and minor version of Captivate 5 are you on? 
    The Aggregator is designed to be a single standalone file output for several Captivate published projects.  It can output as either a single SWF or a single EXE or even a single PDF.
    Yes there are issues with trying to encapsulate video files into this package.  You might be able to try hosting the videos as F4V format on a streaming host service and then viewing them on one of the slides in your project from inside the EXE.  That way the video doesn't have to be packaged with the course in the EXE.

  • How to use Dual monitors with G5 Mac;  AND    How can the image in "Develop" be made to look like wh

    Two questions: How can I use my dual monitors on my G5 Mac?
    How can the image in "Develop" be made to look like what it will print, just as it is
    done in Photoshop with view>proof setup.

    Still wondering what tool is available in LR 1.1 to "view proof"
    As in Photoshop CS 3, and previous versions of PS, in view I can
    choose the custom .icc profile of the printer, to view what the final
    print will nearly perfectly appear like.
    What tool is available in LR 1.1 to do the same?
    Equipment: Mac OS 10.4.10; dual monitors; Epson Pro 9600 and SPR
    2400, both dedicated to matte black ink. Color working space is
    ProPhoto RGB. I stay in 16 bit.

  • How to use Dual monitors with G5 Mac;  And...    How can the image in "Develop" be made to look like

    Two questions: How can I use my dual monitors on my G5 Mac?
    How can the image in "Develop" be made to look like what it will print, just as it is
    done in Photoshop with view>proof setup.

    Patience! :)
    (This was asked and answered in previous thread.)

  • How to use progress bar

    Hi
    I am using jdev11.1.1.5.0
    I have created an adf application in which i have a select many shuttle to display data from database.
    On the radio button change event i am setting another where clause on associated vo and re-executing vo.
    Now the problem is that the processing takes few seconds to fetch data from database according to where condition. For the time being I want to display a progress bar to user.
    How it is possible....?
    Thanks...

    Read http://myjdeveloperhints.blogspot.de/2010/12/add-glass-pane-to-long-running-db-job.html...
    Here it's an example http://myjdeveloperhints.blogspot.de/2010/12/add-glass-pane-to-long-running-db-job.html
    Timo

  • How to use second monitor as extended monitor

    Want to use a second monitor at MacbookAir 11. I get the mirror to work and I know resolution is unfortunately not the same, but I wanted to use the two as one extended monitor. I cannot move or extend any window to cover both. Any advises how to get to that?

    You should be able to drag the application off the right side of your monitor and it appear on the TV.  You can size and position as desired.
    Check System Preferences > Displays > Arrangement tab  for the placement of the external monitor.  It normally defaults to the right side but could be above/below or left of your primary.
    Regards,
    Captfred

  • How to use Memory Monitor on Sun ONE Studio 4 ??

    Hello,
    I am creating a midlet using the Nokia 7210 emulator. When trying to load a Canvas, an "Unable to run application" alert appears and the midlet quits.
    Presuming this is due to a memory problem, I've inserted a System.gc() call before I create the new canvas, but the midlet still exits.
    So to help me get to the bottom of it, I thought I had best try s1s4's Memory Monitor utlity - but I can't get it to work. I have ticked the 'Enable Memory Monitor' box on the Monitor tab of Preferences for the Installed Emulator (J2ME Wireless Toolkit 1.0.4_01), but nothing happens after the midlet runs and quits.
    Does anyone have any suggestions?
    Many thanks in advance,
    James

    I don't know. I've never tried.
    Look at the manual (7210midpSimGuide.pdf in the docs directory). Maybe there is something in there. In the command line options there are a bunch of tracing options that you can specify, like tracing allocations, garbage collections, stackmaps, etc.
    shmoove

  • How to use one monitor with two Power Macs

    I searched this forum and was unable to find an answer. Although I believe it's probably here.
    Nevertheless, I have a Power Mac G5 and a rarely used Power Mac G3. I'd like to share the G5's VGA Accusync 120 CRT monitor with the G3. I know there is a way to switch the monitor between computers without pulling plugs in and out of the machines.
    Does anyone have any specific switch I could buy to solve this issue. I don't care so much for picture quality for the G3. But I don't want to compromise picture quality for the G5.

    You're looking for what's called a KVM (Keyboard, Video, Mouse) switch.
    This one should do what you're looking for. I've not used it, but it does VGA switching like you want and is inexpensive.

  • How to use progress indicator which block the user for editing ?

    Hi All,
    I have a requirement where i need to show a round progress bar while processing to the database.For example :- I have a bounded taskflow and inside it I have a two jspx page called as "First.jspx" and "Second.jspx".And i have two textboxes and one "Save" button on first.jspx page.
    Now when user puts the values in the textboxes and hits the "Save" button , my ticker or progress indicator should say "Please wait while processing" and as soon as the transaction is complete , i need to show another page which is "Second.jspx" page. "Save" button action has method inside a managed bean which has some functionality and then it executes the VO(View Object) and commits the data.
    How should i implement the indicator?
    I have read this article :- http://www.oracle.com/technetwork/developer-tools/adf/learnmore/42-progressbarcolor-169184.pdf but it doesn't fit to my requirement.I need indicator which holds the user to edit anything on the page.Like what we get when we do any transaction in banks while navigating to payment gateway.
    Please suggest!!!
    Thanks and Regards,
    Shah

    Hi Shah,
    The answer was around the same are that you were looking into. http://www.oracle.com/technetwork/developer-tools/adf/learnmore/27-long-running-queries-169166.pdf but the sample was the 27.
    - Juan Camilo

Maybe you are looking for

  • Ascii Plug in/ or Image conversion to text plug in

    Hi, Does anyone know of a Ascii plug-in for Illustrator? or a plugin that converts images to text images? any help greatly appreciated... Al

  • Function module for Vendor

    Hi Pls help me out, Any function module , which takes Input as a Vendor ID and returns Vendor Name(Formatted Name). Regards Arya

  • Need support for resolving a known bug in AIR

    Hi All, I want a favour from all of you so that one of the known issue can be resolved from adobe.This issue is reported by me six month back and as it is treated as a lower priority item so this is not being resolved.But it is a high prority item fr

  • Customer TIN and CST In PLD

    Dear Members,    In PLD I want to include the customer TIN and CST No. In PLD i could not view the CRD7 Or DLN12 tables.Anyone could tell the varaible Name for the same.Please tell me the work around for this. Jai Edited by: JaiShankarRaman on Dec 12

  • Scedule VI FI reporting to be done in BI

    Hi, Does anybody has experience of working in schedule VI reports? These are FI reports, I need to derive them in BI. Regards, Shailesh