Code for JProgressbar for monitoring  while writing into a files

Could anybody help me in sample code to implement a JProgressbar while writing into a file.

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.lang.reflect.*; // for InvocationTargetException
public class Test extends JApplet {
     private JProgressBar pb = new JProgressBar();
     public void init() {
          Container contentPane = getContentPane();
          final JButton startButton = new JButton("start");
          contentPane.setLayout(new FlowLayout());
          contentPane.add(startButton);
          contentPane.add(pb);
          startButton.addActionListener(new ActionListener() {
               public void actionPerformed(ActionEvent e) {
                    GetInfoThread t = new GetInfoThread(Test.this);
                    t.start();
                    // this is okay because actionPerformed
                    // is called on the event dispatch thread
                    startButton.setEnabled(false);
     public JProgressBar getProgressBar() {
          return pb;
class GetInfoThread extends Thread {
     Runnable getValue, setValue;
     int value, currentValue;
     public GetInfoThread(final Test applet) {
          getValue = new Runnable() {
               public void run() {
                    JProgressBar pb = applet.getProgressBar();
                    currentValue = pb.getValue();
          setValue = new Runnable() {
               public void run() {
                    JProgressBar pb = applet.getProgressBar();
                    pb.setValue(value);
     public void run() {
          while(true) {
               try {
                    Thread.currentThread().sleep(500);
                    // This is okay because the getValue's run()
                    // is invoked on the event dispatch thread
                    value = (int)(Math.random() * 100);
                    try {
                         SwingUtilities.invokeAndWait(getValue);
                    catch(InvocationTargetException ite) {
                         ite.printStackTrace();
                    catch(InterruptedException ie) {
                         ie.printStackTrace();
                    if(currentValue != value) {
                         SwingUtilities.invokeLater(setValue);
               catch(InterruptedException e) {
                    e.printStackTrace();
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.lang.reflect.*; // for InvocationTargetException
public class Test extends JApplet {
     private JProgressBar pb = new JProgressBar();
     public void init() {
          Container contentPane = getContentPane();
          final JButton startButton = new JButton("start");
          contentPane.setLayout(new FlowLayout());
          contentPane.add(startButton);
          contentPane.add(pb);
          startButton.addActionListener(new ActionListener() {
               public void actionPerformed(ActionEvent e) {
                    GetInfoThread t = new GetInfoThread(Test.this);
                    t.start();
                    // this is okay because actionPerformed
                    // is called on the event dispatch thread
                    startButton.setEnabled(false);
     public JProgressBar getProgressBar() {
          return pb;
class GetInfoThread extends Thread {
     Runnable getValue, setValue;
     int value, currentValue;
     public GetInfoThread(final Test applet) {
          getValue = new Runnable() {
               public void run() {
                    JProgressBar pb = applet.getProgressBar();
                    currentValue = pb.getValue();
          setValue = new Runnable() {
               public void run() {
                    JProgressBar pb = applet.getProgressBar();
                    pb.setValue(value);
     public void run() {
          while(true) {
               try {
                    Thread.currentThread().sleep(500);
                    // This is okay because the getValue's run()
                    // is invoked on the event dispatch thread
                    value = (int)(Math.random() * 100);
                    try {
                         SwingUtilities.invokeAndWait(getValue);
                    catch(InvocationTargetException ite) {
                         ite.printStackTrace();
                    catch(InterruptedException ie) {
                         ie.printStackTrace();
                    if(currentValue != value) {
                         SwingUtilities.invokeLater(setValue);
               catch(InterruptedException e) {
                    e.printStackTrace();

Similar Messages

  • OSB cluster --reading a writing into a file

    Dear All,
    I have a requirement in which my first OSB service s writing into a file(In a clustered environment).So in this case some of the files are being written in managed_server1 while some of the files are getting written in managed_server2.
    My second OSB service has to poll those files.Now as we know while polling,we have to define one target server(managed server).So this service will only be able to poll from one managed server.Is there any way it can poll from both the managed servers?

    Hello Deepthi,
    Can you please explian what is meant by shared storage as i am not aware of that.From shared storage, I meant common mounted/mapped file system.
    We have 2 managed servers on two different physical machines and we are using clustered environment.In this case you have two option -
    1. Use unique endpoint & mask combo for both the proxies and make sure that all the servers in the cluster have access to the staging directory of the polling manged server (by mounting/mapping the file system appropriately).
    2. Create a shared storage by mounting/mapping the file system for business services to put file and have a single proxy to poll that shared storage. Again all managed server need to have access to the staging directory of the polling manged server.
    You may like to refer metalink note ID 965135.1
    To understand how to achieve HA in this case, please refer -
    OSB10gR3:High-availbility of file protocol based proxy service
    Regards,
    Anuj

  • API5317: Error occured while writing to archive file

    We have been making daily archives for weeks and then one morning started getting this error:
    API5317: Error occured while writing to archive file f:\OWB\Archives\Daily\backups\Friday\projects\erm_phase1\project.mdl
    We have checked space on the disc, and running the archive from different PCs. Is possible that there is a limit on the archive file? The archive file is in the order of 21M. I am worried about the upgrade to the new version if we cannot make archives. Any suggestions?

    Marlene,
    Which OWB version are you using and what is the database version?
    Regards:
    Igor

  • Error while writing to a file

    Hi,
    I am getting an error while writing to a file.Here is the sample code in which I am getting error.The STDERR is getting printed to console but the same is not getting written to a file.
    package Sample;
    import java.util.*;
    import java.io.*;
    public class MediocreExecJavac
    public static void main(String args[])
    try
    Runtime rt = Runtime.getRuntime();
    Process proc = rt.exec("perl ic_start");
    InputStream stderr = proc.getErrorStream();
    InputStreamReader isr = new InputStreamReader(stderr);
    BufferedReader br = new BufferedReader(isr);
    FileWriter fw=new FileWriter("result.txt");
    String line = null;
    System.out.println("<ERROR>");
    while ( (line = br.readLine()) != null)
    System.out.println(line);
    fw.write(line);
    System.out.println("</ERROR>");
    int exitVal = proc.waitFor();
    System.out.println("Process exitValue: " + exitVal);
    fw.close();
    } catch (Throwable t)
    t.printStackTrace();
    }Below is the output -
    <ERROR>
    Can't open perl script "ic_start": No such file or directory
    java.lang.NullPointerException
    at java.io.Writer.write(Unknown Source)
    at Sample.MediocreExecJavac.main(MediocreExecJavac.java:21)
    Please tell where the program is going wrong.

    i think it is just the path of file that u r missing

  • Why do I get a NI-488 error massage when writing into a file and at the same time copiyng this file with a backup softwarre like Easy2Sync?

    I have a small LabVIEW program which writes random numbers very fast into a ASCII-file. I want that file to be copied to a new position every 10 min. Therefor I use a backup/synchronisation software which is doing a copy operation every 10 min. It works fine a certian amount of time and after a while I get either an LabVIEW error (LabVIEW: Fiel already open: NI-488 Comand requieres GPIB Controller to be System controller) or an backup-software error (couldn´t open file...whatever). I´m guessing, it has something to do with file-access but I don´t know why?!? If I run the LabVIEW program and I copy and paste the random-number-file with the windows explorer very fast (pressing ctrl+v rapidly) while LabVIEW is still writing into this file, no error appears. Can sombody help me?
    LabVIEW 2011

    Hi Serdj,
    you don't get a GPIB error, the error number has just 2 different explanations...
    Well, you have two programs accessing the same file. One program just wants to make a copy, the other (LabView) is trying to write to the file. When copying a file that is written to you get inconsistent results! That's why one of both programs is complaining an error...
    You can't have write and read access at the same time! (But you can have more than one read access at the same time...)
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome

  • ORA-48913: Writing into trace file failed

    Hi
    my OS: OUL5x64
    DB: 11.1.0.7
    receive this error in alert.log but could not figure out which parameter to increase.
    Can someone please help.
    Non critical error ORA-48913 caught while writing to trace file
    Error message: ORA-48913: Writing into trace file failed, file size limit [10485760] reached
    the suggestion:
    ORA-48913: Writing into trace file failed
    *Cause:An attempt was made to write into a trace file that exceeds the trace's file size limit
    *Action:increase the trace's file size limit.
    Thanks in advance.

    Hi ,
    I have one more doubt :
    ORACLE_SID=XXXX
    /XXXX/XX/ofaroot/XXXX/diag/rdbms/xxxx/XXXXX/trace
    Non critical error ORA-48913 caught while writing to file "trace /XXXX/XX/ofaroot/XXXX/diag/rdbms/xxxx/XXXXX/trace/XXXX_ora_8218.trc"
    Error message: ORA-48913: Writing into trace file failed, file size limit [10485760]everywhere its written to increase the parameter max_dump_file_size or to relocate the alert log, but as far as i understand ,
    is this because a trace file with the name XXXX_ora_8218.trc was getting generated with a greater size than the one defined in max_dump_file_size. Is this what happened ?
    Also , I am not able to find what directory does this parameter points to ? is it the trace directory or diag directory ?
    i checked select * from v$diag_info ,but i could not find any conclusion.
    Probably , on getting the above info , i will be able to decide where to move the alert.log to create space.

  • Urgent: Error while uploading into pdf file

    Hi ,
    I got a requirement that converting smartform into pdf file and sending into application server, And uploading the that pdf file into presentation server once a day am geting error when uploading into pdf format from application server .
    Error : There was an  error while tryinging to parse an image.
    Please help me out its urgent.
    Thanks in advance
    Regards
    krishna
    Edited by: krishna rao on Feb 13, 2008 12:05 PM

    U can use this code
    Reward if useful
    REPORT  ZMN_PDF_UPLOAD.
    data: begin of itab occurs 0,
    field(256),
    end of itab.
    data: dsn(100) value '\usr\sap\DEV\DVEBMGS00\work\testpdf',
    length like sy-tabix,
    lengthn like sy-tabix.
    call function 'GUI_UPLOAD'
    exporting
    filename = 'c:\temp\test.pdf'
    filetype = 'BIN'
    importing
    filelength = length
    tables
    data_tab = itab.
    open dataset dsn for output in binary mode.
    loop at itab.
    transfer itab-field to dsn.
    endloop.
    close dataset dsn.
    clear itab.
    refresh itab.
    *To crosscheck if it went well
    open dataset dsn for input in binary mode.
    do.
    read dataset dsn into itab-field.
    if sy-subrc = 0.
    append itab.
    else.
    exit.
    endif.
    enddo.
    call function 'GUI_DOWNLOAD'
    exporting
    filename = 'c:\temp\testn.pdf'
    filetype = 'BIN'
    bin_filesize = length
    importing
    filelength = lengthn
    tables
    data_tab = itab.
    *Or
    *Use the TCode
    *CG3Z or CG3Y
    *for downloading to Application Server.

  • Writing into Excel file using PL/SQL and formatting the excel file

    Hi,
    I am writing into a excel file using PL/SQL and I want to make the first line bold on the excel. Also let me know if there are any other formatting options when writing into excel.
    Regards,
    -Anand

    I am writing into a excel file using PL/SQL
    Re: CSV into Oracle and Oracle into CSV
    check that thread or search in this forum...

  • Writing into XML File in Flex

    Hi,
    I want to create a XML file (dynamically) and writes data
    into that xml file(data coming from web service).
    Thanks in advance.

    i want to write the data(coming from web service) into XML
    file and keep that XML file in Cache,then read that XML file
    contents and post into UI Control(Datagrid).
    <b>Sample Output Data from my Webservice:</b>
    <CoreProgramming>
    <BasicProgramming>
    <ProductId>10049</ProductId>
    <ProgrammingName>America'sTop60</ProgrammingName>
    <Price>29.99</Price>
    <IncludesLocals>false</IncludesLocals>
    <IncludesRSN>false</IncludesRSN>
    <Listing>
    <CategoryName>WOMEN'SPROG</CategoryName>
    <Station>
    <StationCallLetters>TLC</StationCallLetters>
    <Hdflag>false</Hdflag>
    </Station>
    <Station>
    </Listing>
    </BasicProgramming>
    <BasicProgramming>
    <ProductId>10041</ProductId>
    <ProgrammingName>America'sTop120</ProgrammingName>
    <Price>39.99</Price>
    <IncludesLocals>false</IncludesLocals>
    <IncludesRSN>true</IncludesRSN>
    <Listing>
    <CategoryName>WOMEN'SPROG</CategoryName>
    <Station>
    <StationCallLetters>TLC</StationCallLetters>
    <Hdflag>false</Hdflag>
    </Station>
    <Station>
    <StationCallLetters>DHLTH</StationCallLetters>
    <Hdflag>false</Hdflag>
    </Station>
    <Station>
    <StationCallLetters>DISC</StationCallLetters>
    <Hdflag>false</Hdflag>
    </Station>
    </Listing>
    </BasicProgramming>
    <BasicProgramming>
    <ProductId>10045</ProductId>
    <ProgrammingName>America'sTop180</ProgrammingName>
    <Price>49.99</Price>
    <IncludesLocals>false</IncludesLocals>
    <IncludesRSN>true</IncludesRSN>
    <Listing>
    <CategoryName>WOMEN'SPROG</CategoryName>
    <Station>
    <StationCallLetters>TLC</StationCallLetters>
    <Hdflag>false</Hdflag>
    </Station>
    <Station>
    <StationCallLetters>DIY</StationCallLetters>
    <Hdflag>false</Hdflag>
    </Station>
    <Station>
    <StationCallLetters>LIME</StationCallLetters>
    <Hdflag>false</Hdflag>
    </Station>
    </Listing>
    </BasicProgramming>
    </CoreProgramming>

  • Is there a fix for my imac monitor burning highlights into blue shapes on my screen?

    Whenever I leave an image or window open on my imac for longer than 5 minutes the white boxes or white in the images burn a blue shape onto my screen.  It is apparent in every program and finder, but overly so in photoshop.  Is there a fix for this or do I need to take my computer in?  I've tried changing my display settings to AdobeRGB 1998 and turning down the brightness but neither fixed it.

    Image persistence on LCDs is not permanent like screen burn on CRTs.
    Have a look at > Avoiding image persistence on Apple LCD displays
    Personally I use a Hot Corner to Sleep my displays when I get up or when I'm not looking something. I also have the Display Sleep timer set to 10 minutes, just in case I get up and forget to use the Hot Corner.

  • Problem with dataset while writing into

    I am writing my output internal table into ftp server.
    I used below stmt in ECC 6.0 .
        OPEN DATASET p_opath FOR OUTPUT IN TEXT MODE MESSAGE gv_msg ENCODING DEFAULT.
    But the gv_msg is filled up with 'Permission denied'.
    What does it mean ?  My coding is not correct or I don't have access to write into ftp server ?
    THANKS IN ADV.

    Hi,
    i guess you dont have the permission of creating file in the directory have mentioned in the path
    change the path of the file and check it again... may be HOME directory
    regards
    padma

  • Writing into pdf file

    Hi All,
    I need to add a line of text/string to about
    1000 or so number of pdf files. whats the best
    way of writing this string to the pdf file.
    Has anyone done this using java/javascript.
    If so could you please tell the best solution
    or provide some code samples.
    Thanks
    lared

    I know there is an API available from http://www.adobe.com for java (90% sure). I'd suggest starting there.

  • "Deep data objects not supported" when writing into a file

    Hello everybody,
    I am having some issues about a program that i made which puts the content of any table in a file that i created.
    The problem is when my table (transparent table) has a deep data type in it (example : a string field, so with undefined length).
    Here is my code :
      DATA : lt_gentable TYPE REF TO data.
      DATA : ls_gentable TYPE REF TO data.
      FIELD-SYMBOLS : <ft_lines> TYPE STANDARD TABLE.
      FIELD-SYMBOLS : <fs_line> TYPE ANY.
      CREATE DATA lt_gentable TYPE TABLE OF (p_tab).
      CREATE DATA ls_gentable TYPE (p_tab).
      "creation of links
      ASSIGN ls_gentable->* TO <fs_line>.
      ASSIGN lt_gentable->* TO <ft_lines>.
      DATA : l_fname     TYPE char80.
      CONCATENATE '\dir\dir2\' l_fname_log INTO l_fname.
      OPEN DATASET l_fname FOR OUTPUT IN BINARY MODE.
      OPEN CURSOR WITH HOLD l_c FOR SELECT * FROM (p_tab).
      DO.
        FETCH NEXT CURSOR l_c INTO TABLE <ft_lines> PACKAGE SIZE p_size.
        IF sy-subrc = 0.
          LOOP AT <ft_lines> INTO <fs_line>.
            TRANSFER <fs_line> TO l_fname.   <=====> GOES INTO DUMP BECAUSE MY TABLE (p_tab) has a string field
          ENDLOOP.
          CLEAR <ft_lines>.
        ELSE.
          CLOSE CURSOR l_c.
          EXIT.
        ENDIF.
      ENDDO.
      CLOSE DATASET l_fname.
    Here is the message i am getting :
    At the statement
       "TRANSFER f TO ..."
    no deep data objects are supported at the a
    for strings.
    Elementary deep data types are internal tabl
    data object) references and strings (STRING,
    General deep data objects are elementary dee
    that contain deep data objects.
    In this particular case, the operand "f" has
    internal identification "v".
      List of internal ABAP types:
      C    Text (Character)
      N    Numerical text
      D    Date (YYYYMMDD)
      T    Time (HHMMSS)
      X    Hexadecimal
      I    Integer
      P    Packed number
      F    Floating point number
      h    Internal table
      r    Object reference
      l    Data reference
      g    String of type C
      y    String of type X
      s    2-byte integer with plus/minus sign
      b    1-byte integer without plus/minus sig
      u    Structure (flat structure)
      v    Structure (deep structure)
    Can you help me to go through this issue ?
    Any kind of help would be appreciated.
    Christian

    Sandra is correct I agree with him,
    TRANSFER dobj TO dset [LENGTH len]
                          [NO END OF LINE].
    dobj must be character-type . Use String.
    Please read the F1 help for the TRANSFER Statement and also please check the example
    In your case assign the <fs> to Casting File asfollows
    DATA: file TYPE string VALUE `flights.dat`,
          wa TYPE spfli.
    FIELD-SYMBOLS TYPE x.
      ASSIGN wa TO CASTING.
      TRANSFER TO file.
    Hope this helps...

  • Error While Writing to Target FIle

    Hi
    I am executing an interface which reads data from a delimited file and writes into another delimited file.
    But while executing the interface i am getting the following error
    ODI-1227: Task I_FILE_TO_FILE (Integration) fails on the source ORACLE connection DWH_TARGET.
    Caused By: java.sql.SQLSyntaxErrorException: ORA-00923: FROM keyword not found where expected
    To let u know te background i am using Staging Area Different Than Target
    LKM is LKM File to SQL
    IKM: IKM SQL to file Append
    Kindly let me know where am i doing wrong??
    regards
    GS

    Source Code
    select      
         C1_ORD_NO     ORDER,
         C2_QTY1     QUANTITY1,
         C3_QTY2     QUANTITY2,
         C4_QTY3     QUANTITY3
    from     ODI_TARGET.C$_0FILE_ORDER
    where     
         (1=1)     
    Target Code
    insert into "D:/GSANKAR/FILE_ORDER.txt"
         ORDER,
         QUANTITY1,
         QUANTITY2,
         QUANTITY3
    values
         :ORDER,
         :QUANTITY1,
         :QUANTITY2,
         :QUANTITY3
    /*$$SNPS_START_KEYSNP$CRDWG_TABLESNP$CRTABLE_NAME=FILE_ORDERSNP$CRLOAD_FILE=D:/GSANKAR/FILE_ORDER.txtSNP$CRFILE_FORMAT=DSNP$CRFILE_SEP_FIELD=0x007cSNP$CRFILE_SEP_LINE=0x000D0x000ASNP$CRFILE_FIRST_ROW=1SNP$CRFILE_ENC_FIELD=SNP$CRFILE_DEC_SEP=SNP$CRSNP$CRDWG_COLSNP$CRCOL_NAME=ORDERSNP$CRTYPE_NAME=STRINGSNP$CRORDER=1SNP$CRLENGTH=50SNP$CRPRECISION=50SNP$CRSNP$CRDWG_COLSNP$CRCOL_NAME=QUANTITY1SNP$CRTYPE_NAME=STRINGSNP$CRORDER=2SNP$CRLENGTH=10SNP$CRPRECISION=10SNP$CRSNP$CRDWG_COLSNP$CRCOL_NAME=QUANTITY2SNP$CRTYPE_NAME=STRINGSNP$CRORDER=3SNP$CRLENGTH=10SNP$CRPRECISION=10SNP$CRSNP$CRDWG_COLSNP$CRCOL_NAME=QUANTITY3SNP$CRTYPE_NAME=STRINGSNP$CRORDER=4SNP$CRLENGTH=10SNP$CRPRECISION=10SNP$CR$$SNPS_END_KEY*/
    regards
    GS

  • 'FROM keyword not found where expected'error while Inserting into Text file

    Hi,
    I have created a simple interface for testing purpose. All it has to do is to Read the data from a Source Text file and put it into another text file (exactly the same headers as that of source) ...
    I am using Oracle as my staging area.
    But at 'Insert column Header' Stage, it gives me a warning 'FROM keyword not found where expected' and when it goes to the next step 'Insert Rows' it gives me the same error 'FROM keyword not found where expected' and aborts its execution.
    I checked the query for insertion and found nothing wrong in it (FROM Statement is just where it is expected, that is) but somehow its not working.
    Can somebody help me out as i have done it before on other Installations and dont know why it is occuring that too for the simplest thing in ODI ...
    Regards,
    Nitesh.

    Probably you missed the concat operator.
    select rpad(nvl(lu_parid,' '),1,19)|| v_comma ||
    rpad(nvl(lu_class,' '),1,3)
    from temp_te07                                                                                                                                                                                                                                                                                                           

Maybe you are looking for

  • Cisco Jabber Client for Linux

    Are there any plans to have a Cisco Jabber client on linux?

  • My phone keeps freezing and I have the 5s and now it won't turn on but I can talk to sir

    My phone keeps freezing and I have the 5s and now it won't turn on but I can talk to sir

  • How do I determine what codecs I need

    I was attempting to edit/combine several flv files into one file in order for it to perform on my windows media player 11 for windows7 operating system.  My Adobe premiere 10 said I needed the correct codec.  Needless to say, Adobe Premiere Elements

  • PSE 13 installatieprobleem

    Goedemorgen. Ik heb PSE 13 aangeschaft via een een downloadkaart van "safedigital.eu" in een winkel van Kamera-express. Na downloaden en uitpakken van de bestanden blokkeert het installatieprogramma met volgende melding :installatieprogramma kan niet

  • Playlists out of wack

    So many of my playlists are out of order on my phone. Its so annoying. I listent to a lot of mixed CD's. They are all organized in order and play fine on my computer but are all out of wack on my phone. Anyone know what the deal is? Match on the ipho