Appropriate use of JProgressBar

/* Is this the correct way of using a JProgressBar, this is my first time using this class.
Please give your comments and correct me.
By the way, can you tell me when to use this method, addChangeListener(ChangeListener l). Is it possible for me to use when
the value increases.*/
public void check()
     cPane.remove(but);
     progressBar=new javax.swing.JProgressBar(javax.swing.JProgressBar.HORIZONTAL, 0, 100);
     cPane.add(progressBar, java.awt.BorderLayout.CENTER);
     setVisible(true);     
     Thread t=new Thread(new MonitorProgressBar());
     t.start();
     class MonitorProgressBar implements Runnable
          public MonitorProgressBar()
          public void run()
          int value=95;
               while(value <= progressBar.getMaximum())
               progressBar.setValue(value);
               progressBar.setString("Loading.... "+(progressBar.getPercentComplete()*100)+"%");
               progressBar.setStringPainted(true);
                    try
                    Thread.sleep(1000);
                    value++;
                    catch(Exception e)
                    { System.err.println(e.toString()); }
          System.out.println("Hello");
          //dispose();
     }

Hi,
/* Is this the correct way of using a JProgressBar,
this is my first time using this class.
Please give your comments and correct me.
By the way, can you tell me when to use this method,
addChangeListener(ChangeListener l). Is it possibleTry it. It should work.
for me to use when
the value increases.*/
public void check()
     cPane.remove(but);
progressBar=new
javax.swing.JProgressBar(javax.swing.JProgressBar.HORI
ONTAL, 0, 100);
cPane.add(progressBar,
java.awt.BorderLayout.CENTER);
     setVisible(true);     
     Thread t=new Thread(new MonitorProgressBar());
     t.start();
     }If you use Threads with a Progreesbar they should have a priority less than 4, cause the repainting thread has 4.
even the sleep doesn't garantues that the painting-progres
will do his work.
t.setPriority(Thread.Min_Priority) If you don't need a thread, have a look at SwingUtilities.invokeLater.
if setVisible(true);     is invoked by a modal dialog
the Thread will be created after closing the dialog.
     class MonitorProgressBar implements Runnable
          public MonitorProgressBar()
          public void run()
          int value=95;
               while(value <= progressBar.getMaximum())
               progressBar.setValue(value);
progressBar.setString("Loading....
.. "+(progressBar.getPercentComplete()*100)+"%");
               progressBar.setStringPainted(true);
                    try
                    Thread.sleep(1000);
                    value++;
                    catch(Exception e)
                    { System.err.println(e.toString()); }
          System.out.println("Hello");
          //dispose();
     }Hope this helps.
Greetings Michael

Similar Messages

  • Appropriate use of "return" in a method

    Migrating to Java quite some time back now I still haven't found the appropriate use of the 'return'-statement in a method.
    In procedual languages there has always been an unwritten rule saying that a function should not have more than one 'return'-statement and that the 'return'-statement should always be the last line to be executed in the function.
    Having seen a lot of source code by other Java programmers I was puzzled to see that a lot of programmers uses multiple return statments and furthermore use them to terminate loops, etc.
    Example, binary search find method
    while ( current.key != key ){
        if ( key < current.key){
            current = current.leftChild;
        else{
            current = current.rightChild;
        if (current == null){
            return null;
    return current;As you can see in the example, 'return' is used in the middle of the loop to both return a value and to stop the rest of the processing in the method.
    Is there any recommended practise on using 'return'? Personally I don't like the idea of having more than one return statement in my code as the code can end up being irrational.
    What do guys think in the forum?
    Kind regards,
    Allan

    Sylvia is probably right about the origin of that practice, memory leaks were a huge problem (and are to a lesser extent in Java). You really shouldn't avoid doing multiple returns to avoid memory leaks in C++ even. Usually when you allocate memory that you're expecting to simply disapear at the end of a function, you're going to allocate it as a stack variable, rather than using new, and it will be removed when it falls out of scope. There are some functions, like strcpy, and strdup, to name a few, that will allocate memory, and it's possible you could return out without removing that data. I find if this is likely to happen, the user probably wasn't thinking about releasing the data to begin with, and could just as easily return at the end of the function without releasing the memory, as he/she would at any point inside the function. I'd hope that you'd be using this newly created memory for some purpose before returning, so I would assume it's use would be complete before you left that function, and definitely it would be ready to be deleted.
    -Jason Thomas.

  • Threading design for jTable that uses AbstractTableModel & jProgressBar

    The application consists of a number of jTables that are filled using individual classes that extend AbstactTableModel. I want to use a jProgressBar (setIndeterminate(true)) to show progress is happening when a Search button is pressed. A code snippet is shown below. The method doSearch() calls the classes that populate the jTables. The code works fine but is wrong as components are being updated by a thread other than the EDT. Does this need a complete re-factoring? What design pattern should I be looking to use? Without using this extra thread I cannot get the jProgressBar to show progress.
    if (IbagDatabase.theInstance().isConnected()) {
                  jProgressBarSearch.setVisible(true);
                  jProgressBarSearch.setStringPainted(true); //get space for the string
                  jProgressBarSearch.setIndeterminate(true);
                  jProgressBarSearch.setString("Searching ..."); //display % string             
                  Runnable i = new Runnable()           {
                      public void run() {
                          doSearch();
                          jProgressBarSearch.setIndeterminate(false);
                          jProgressBarSearch.setString("");
                          jProgressBarSearch.setVisible(false);
                  Thread t = new Thread( i );
                  t.start();             
                  //doSearch();
            }

    Using a separate Thread for the long running task is the correct design.
    The only change you need is that when you want to update a GUI component you need to wrap the update code in a SwingUtilities.invokeLater(...). Read the Swing tutorial on [url http://java.sun.com/docs/books/tutorial/uiswing/misc/threads.html]How to Use Threads for more information.

  • Appropriate Use of Sessions

    I've been doing some reading on sessions and their uses (textbook and a little bit of searching on this newsgroup). I'm trying to get a feel for when it's appropriate to use sessions to maintain data and when it's not. According to the chapter I've read, it seems to imply that the old mechanisms include cookies, hidden variables, etc. Obviously there are still uses for these mechanisms, the question is when to use what.
    SO, I'm guessing this is very much a religious issue but would like to hear feedback on it. For instance, if I were to be using a Model-View-Controller implemention for a servlet web application where I am keeping track of my current operation with a variable and my current web page with a variable, would it be more appropriate to track this with a hidden variable or with a session variable?
    Thanks for your feedback...

    How you store the client portion of session state is really dictated by two aspects of standard browser behavior:
    If you store the session in a cookie, then multiple browser windows can share that session. As a test, hit control-N in Internet Explorer. You will see that both pages will share the same session cookie. However, if you launch a separate browser process (by double-clicking its icon), they will not share the same session cookie.
    If you store the session in a hidden tag on a page, then you have the ability to detect whether a new browser window has opened (assuming it has issued another GET or POST to your server). If you store two hidden fields (or cookies for that matter) instead of one, with the second field being a random string generated on the server for each and every request, then the server can compare whether it received the same random string in successive requests. This is the normal method to prevent users from double-clicking on a submit button (say, to process a credit card transaction).
    Most of the time, I simply use whatever implementation the J2EE container has decided on. If for some reason I need to detect double-clicks, I add the random string additional session variable (both client and server). If I need to detect whether a new window has been opened, and this does not always work, I explicitly force the client session to be stored via hidden page tags.
    - Saish
    "My karma ran over your dogma." - Anon

  • To Philip Lille - appropriate use of forums

    Your previous post is being systematically deleted because it is a rant.
    this is a user-to-user help forum.  If you have a question that some of us might be able to help with, then that is appropriate.  RANTS are not appropriate in this forum.
    But feel free to give it to Apple as feedback in the appropriate forum.

    Sylvia is probably right about the origin of that practice, memory leaks were a huge problem (and are to a lesser extent in Java). You really shouldn't avoid doing multiple returns to avoid memory leaks in C++ even. Usually when you allocate memory that you're expecting to simply disapear at the end of a function, you're going to allocate it as a stack variable, rather than using new, and it will be removed when it falls out of scope. There are some functions, like strcpy, and strdup, to name a few, that will allocate memory, and it's possible you could return out without removing that data. I find if this is likely to happen, the user probably wasn't thinking about releasing the data to begin with, and could just as easily return at the end of the function without releasing the memory, as he/she would at any point inside the function. I'd hope that you'd be using this newly created memory for some purpose before returning, so I would assume it's use would be complete before you left that function, and definitely it would be ready to be deleted.
    -Jason Thomas.

  • Appropriate use of temporary table - or can pivot approach be used?

    I am relatively new to pl/sql. My problem is that I need to return one row of data (joining several tables, including a 1-many), but with a varying number of columns (from single values returned from the 1-many table), and record types cannot be dynamically defined or modified (such as with adding columns).
    I am not sure if pivoting the many table would work, because the range of values returned (albeit not expected to realistically exceed a dozen) do not fall within a small set.
    Would dynamically generating SQL to create a temporary table with the requisite number of columns be the best approach? Then I could select all the data into the table, iterate through the results from the 1-many and populate into the columns, and then select * from the temp table for the return resultset.
    Specifics: There is a document table which has a 1-many table containing the CC's for that document. Only one row will ever be returned from the master doc table, and 0-n rows from the CC table. There could be no CC's for the doc, or there could be any number. I need to be able to return all the columns from the document table PLUS the CC's as if they were all one row in a table.
    So example of a return row might be a doc with n # of cc's
    DOC_ID | DOC_TYPE | DOC_OWNER | <etc> | CC_1 | CC_2 | ... | CC_n
    or a doc with all its fields and no cc's
    DOC_ID | DOC_TYPE | DOC_OWNER | <etc>
    So I am thinking the pl/sql would have to
    1. declare the SQL statement to create a temporary table
    2. declare the SQL statement to insert data into the temporary table
    3. declare the SQL statement to query data from the temporary table
    4. fetch the count of CC's based on doc id from the CC table
    5. use that count to loop and
    1. append columns onto the sql that creates the temporary table
    2. append columns onto the sql that will query the temporary table
    6. query the CC's table and read the values into an array
    7. use the count again to loop and dynamically create the insert statement for the temporary table, using the values from step 6
    8. execute the insert statement
    9. query the temporary table using the sql generated in step 5.2 and return that rowset
    HUGE thanks to anyone who can provide input on this. I know it's not a new problem, I am just unsure of the best approach to the solution.

    It's not that I require a single SQL statement to do this; in fact I expected to have to execute at least 2 in the procedure to accomplish the goal. The problem I am running into is that I need to return a dynamic number of columns, based on the number of entries in the 1-many table.
    I'm guessing if I can look up the number of rows in the 1-many table that I need to pivot before I actually do the pivot, I will be able to use this technique?
    The reasoning for all this can be summed up in one word: legacy. The row is being sent back to a legacy component which only takes that one single row of data. Currently, we are only limited to 3 CC entries and are expanding the system to allow >3, hence the 1-many table. However, the legacy component isn't able to handle anything more complex than that one row. Our clients will be able to change their definitions easily to expand from CC1, CC2, CC3 to however many they want to use. However, changing to multiple rows wouldn't be an option because it would incur too much complexity.

  • How do I use a JProgressBar to monitor the loading of a file ?

    How do I let the progress bar tell how much it has finished the reading so far ?? Thanks !!!

    You can use a ProgressMonitorInputStream, which can be used much like any other input stream, e.g.:
    in = new ProgressMonitorInputStream(contentPane, "Loading " + filename, new FileInputStream(filename));Look here for lots more info: http://java.sun.com/docs/books/tutorial/uiswing/components/progress.html
    Hope this is helpful
    Chris.

  • Appropriate use of inheritance

    We have many Database Access Classes (D1, D2, D3...) for each table in our application. All of these classes need to access some common functions such as getConnection and getResultSet.
    I suggested keeping these functions in a separate Utility Class. The concern in the team is if we do so we will instantiate several objects of the Utility class as all D1, D2, D3 etc. will access these.
    Another team member suggested that we should have a baseclass DBase for all the Database Access classes i.e. have D1, D2,D3 extend DBase and that will allow us to access the common functions and we will creating several instances as in the case of the Utility class.
    I find it odd that we should use inheritance in this manner where there is really no "is-a" relationship whatsoever betwen the base class and the derived classes!
    Is my concern valid and Can someone come up with any other alternatives?
    Thanks

    We have many Database Access Classes (D1, D2, D3...) for each table in our application. All of these classes need to access some common functions such as getConnection and getResultSet.
    I suggested keeping these functions in a separate Utility Class. The concern in the team is if we do so we will instantiate several objects of the Utility class as all D1, D2, D3 etc. will access these.
    Another team member suggested that we should have a baseclass DBase for all the Database Access classes i.e. have D1, D2,D3 extend DBase and that will allow us to access the common functions and we will avoid creating several instances as in the case of the Utility class.
    I find it odd that we should use inheritance in this manner where there is really no "is-a" relationship whatsoever betwen the base class and the derived classes!
    Is my concern valid and Can someone come up with any other alternatives?

  • Appropriate use of Negative Margin

    I have a straight forward layout.
    <div id="main">
    <div id="header"> </div>
    <div id="leftbox> </div>
    <div id="rightbox"> </div>
    </div>
    The two inner < div>s are floated so they sit side by
    side and most of the content is in rightbox.
    Here's my question. If on a couple of pages the header
    content is less is it acceptable to put a negative top margin to
    pull the rightbox div up into the empty header space? If I tinker
    with the header height I can see that it will have implications for
    other components (e.g. change position of nav panel on that page).
    Should I work at fixing those implications or is the negative top
    margin acceptable practice?
    Thanks
    Martin
    Whooooaa! I just tested that and in IE 6 the header obscures
    the content of rightbox as if it was sitting under it but FF shows
    it!

    I wouldn't. Negative margins always bite me in the long run.
    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
    ==================
    "martcol" <[email protected]> wrote in
    message
    news:ggri0h$lk7$[email protected]..
    >I have a straight forward layout.
    >
    > <div id="main">
    > <div id="header"> </div>
    > <div id="leftbox> </div>
    > <div id="rightbox"> </div>
    > </div>
    >
    > The two inner < div>s are floated so they sit side
    by side and most of the
    > content is in rightbox.
    >
    > Here's my question. If on a couple of pages the header
    content is less is
    > it
    > acceptable to put a negative top margin to pull the
    rightbox div up into
    > the
    > empty header space? If I tinker with the header height I
    can see that it
    > will
    > have implications for other components (e.g. change
    position of nav panel
    > on
    > that page). Should I work at fixing those implications
    or is the negative
    > top
    > margin acceptable practice?
    >
    > Thanks
    >
    > Martin
    >
    >

  • Using JProgressBar when sending an email

    Good day to all! How can I use the JProgressBar to monitor progress when
    sending an email? I am using the Email package by Jakarta Commons.
    Somehow, I need my application to display progress since the send( )
    function takes a considerable amount of time to complete.
    Regards...

    >
    I Want to learn how to send email . Could you please
    tell me how to send email. and also give me some
    sample Code . so that i can Understand
    Sure. :) I just used a simple-To-Use API of Jakarta Commons Email, which is
    built on Java Mail. Their main site may start you off through simple examples.
    Go to this page: http://jakarta.apache.org/commons/email/userguide.html

  • How do I use iPhoto vs. Pictures folder for organization and viewing?

    I have a high level question as to how to use, in general not specific functions, iPhoto on my new iMac.  I imported all of my PC files from an external drive into the appropriate Folders (Pictures, Documents, Music, Movies) successfully.    So my large collection of photos resides in many sub folders under Pictures (like ‘2012 Mom Visit’ or “Christmas 2008’).
    My question is should I be using iPhoto as my primary app for viewing and organizing my full inventory of pictures, along with obviously editing/creating? Or do I use the default Pictures folder, and dig through with Finder or some search mechanisms if I only want to look at a photo and save iPhoto for editing and creating tasks?  If iPhoto should be my primary photo browsing and organizing tool, and I hope so because I would like a tool to just organize/view/search all my photos rather than thumbing through the folder structure, how to I “import” or tell iPhoto where all my photos are (there are a lot under a lot of subfolders)?  Will iPhoto then keep duplicate copies of these or do all my photo files remain in the Folder structure?
    Bottom line: is iPhoto supposed to be my go-to place for all my photo browsing, viewing, searching as well as editing and creating?  Should every photo I add to this iMac somehow be linked or imported through iPhoto?
    I also have pictures in the cloud and on an iPad (since my PC died I dumped camera photos directly to the ipad) but I’ll deal with these after I understand the appropriate use for iPhoto.
    Thanks for any input.

    The important thing to remember is there is no "supposed to" or "best way". There's what works for you and you photos. This may be iPhoto or some other app.
    Couple of thoughts: iPhoto is not an editor. It's a Manager - like Contacts for your Addresses or iTunes for your Music, it offers powerful and easy to use tools that will help you manage and share your photos in the various ways you might need it. It will also enhance and crop and edit photos as well, but if you're not using it as a manager then forget about it for editing as it will be just too complex. There are loads of editors out there.
    If you use iPhoto then it's your "go-to" for anything to do with your Photos. Viewing, Organising, sharing, Uploading, Printing, whatever. All of these things can be done either with or via iPhoto. Put another way, you never access your files via the Finder.
    For more on this see this User tip:
    https://discussions.apple.com/docs/DOC-4491
    There are two ways to set up your iPhoto Library. Managed and Referenced
    A Managed Library, is the default setting, and iPhoto copies files into the iPhoto Library when Importing. The files are then stored in the Library package
    A Referenced Library is when iPhoto is NOT copying the files into the iPhoto Library when importing because you made a change at iPhoto -> Preferences -> Advanced. (You unchecked the option to copy files into the Library on import) The files are then stored where ever you put them and not in the Library package. In this scenario you are responsible for the File Management. 
    As you are new to iPhoto I strongly urge you to run a Managed Library. There are many pitfalls with a Referenced one - see here for instance
    https://discussions.apple.com/thread/3062728?tstart=0
    and for someone new to iPhoto and The Mac you can lose data very easily with a Referenced Library.
    However you store the files, importing is the same: easiest way: drag a folder of images to the iPhoto Window and iPhoto will import it and create an Event from it.
    If you have a managed library then it will copy the files into its own Library. You filing structure is then pointless. You can trash it - but don't do it immediately. iPhoto is a great app, but it's not necessarily for everyone. When you've lived with it for a few weeks and are sure it's for you, that's when you can trash your own filing structure.
    The problem with what you have now - files-in-folders-and-subfolders - is that it is limited. Searching is trcky as you don't have a whole lot of things to search on. I append the following to show you some of the options available in iPhoto.
    I use Events simply as big buckets of Photos: Spring 08, July - Nov 06 are typical Events in my Library. I use keywords and Smart Albums extensively. I title the pics broadly.
    I keyword on a
    Who
    What
    Where basis (The When is in the photos's Exif metadata). I also rate the pics on a 1 - 5 star basis.
    Using this system I can find pretty much find any pic in my 44k library in a couple of seconds.
    So, for example, I have a batch of pics titled 'Seattle 08' and a  typical keywording might include: John, Anne, Landscape, mountain, trees, snow. With a rating included it's so very easy to find the best pics we took at Mount Rainier.
    File -> New Smart Album
    set it to 'All"
    title contains Seattle
    keyword is mountain
    keyword is snow
    rating is 5 stars
    Or, want a chronological album of John from birth to today?
    New Smart Album
    Keyword is John
    Set the View options to Sort By Date Ascending
    Want only the best pics?
    add Rating is greater than 4 stars
    The best thing about this system is that it's dynamic. If I add 50 more pics of John  to the Library tomorrow, as I keyword and rate them they are added to the Smart Album.
    In the end, organisation is about finding the pics. The point is to make locating that pic or batch of pics findable fast. This system works for me.

  • Can I use the blank white master more than once in a document?

    I've been trying to create my own mini-theme with styled masters for the various pages I use again and again. I keep getting fouled up. Is it part of the program that this can't be done, or is it my mistake that I'm not catching?

    You might want to try this routine which has sorted quite a few Keynote problems:
    1
    Close all iWork applications
    2
    Uninstall all the iWork applications; this must be done with an application remover tool to delete the installation properly. Appcleaner is known to work correctly for this purpose, it is free and can be downloaded from here: Appcleaner Download
    3
    empty the trash
    4
    shutdown the Mac and restart. After the start up chime, hold down the shift key until the apple logo appears
    let the Mac complete the start up procedure completely, it will take longer than usual as the hard drive is being repaired
    5
    go to;   Applications > Utilities > Disc Utility > First Aid > Repair Disc Permissions
    when this is completed restart the Mac normally
    6
    Reinstall iWork or Keynote as appropriate using the original discs or logging into the Mac App Store and installing from there
    Post back on how this worked

  • Can I use the blank white master more than once in a document-2

    Marked it solved, because it was for a full day. But no. Original question:
    I've been trying to create my own mini-theme with styled masters for the various pages I use again and again. I keep getting fouled up. Is it part of the program that this can't be done, or is it my mistake that I'm not catching?
    MacBook Air, Mac OS X (10.7.5)
    Gary Scotland solved my problem:
    best to create a new slide master:
    view > slide masters
    select the slide master you want to base the new master on; 
    edit > duplicate
    rename the new master by double clicking the name box and type in
    add objetcs and position them to the new master
    file > Save Theme
    you can apply a slide master as many times in a presentation as you need
    I created it, saved it as theme, and successfully used it to make a presentation. Marked it solved. Slept. Woke up, started working again--poof! The theme I had saved and used was a blank white slide again, all masters. What the heck?
    My apologies to Gary. I think I marked a reply of my own as the solution. Stupid but unfixable.

    You might want to try this routine which has sorted quite a few Keynote problems:
    1
    Close all iWork applications
    2
    Uninstall all the iWork applications; this must be done with an application remover tool to delete the installation properly. Appcleaner is known to work correctly for this purpose, it is free and can be downloaded from here: Appcleaner Download
    3
    empty the trash
    4
    shutdown the Mac and restart. After the start up chime, hold down the shift key until the apple logo appears
    let the Mac complete the start up procedure completely, it will take longer than usual as the hard drive is being repaired
    5
    go to;   Applications > Utilities > Disc Utility > First Aid > Repair Disc Permissions
    when this is completed restart the Mac normally
    6
    Reinstall iWork or Keynote as appropriate using the original discs or logging into the Mac App Store and installing from there
    Post back on how this worked

  • Statement in tutorial for useing full screen i dont get ?

    When in full-screen exclusive mode, you don't have to worry
    anymore about the window being resized, moved, exposed, or occluded
    (unless you've ignored my suggestion to turn off resizing). now how do i turn of resizeing ? it doesn't say in the tutorial or i missed it somewhere .
    thanks in advance.

    ackkk im totally stumped can someone run this and
    tell me how i draw to the screen or were to go from were im at
    what im missing what i need to do ect...
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.Image.*;
    public class fullscreentest extends Frame
      // VARIABLES OR USED CLASSES
         private static DisplayMode OD_Mode;
         private static DisplayMode D_Mode;
         Frame mainFrame;
      // CONSTRUCTOR
      public fullscreentest(){
         go(); // call go method
               // could make render loop here as main thread should exit go
               // and stay in full screen mode
      // METHODS
      public static void main(String[] args) {
               try {
            fullscreentest test = new fullscreentest();// call constructor to begin
            } catch (Exception e) {
                e.printStackTrace();
            System.exit(0);
         public void go(){
         GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
      // grab monitor device so we can use it to change the monitor resolution
      GraphicsDevice device = env.getDefaultScreenDevice();
       // i already know the mode im going to set is support so ill skip by this
       if(device.isFullScreenSupported() == false){System.out.println(" Warning full screen is not supported "); }
       if(device.isFullScreenSupported() == true){
        device.setFullScreenWindow(this);
        //device.setFullScreenWindow(Window w);
        System.out.println(" full screen is supported ");
       // graphics configuration class not to sure about this
       // looks like were grabing the default config which is in full screen becacuse we set device to fullscreen
       // or not? because were geting the default configuration  im a lil confused here
       GraphicsConfiguration gc = device.getDefaultConfiguration();
       // create a frame is it in full screen below or not ?
       mainFrame = new Frame(gc);
       mainFrame.setUndecorated(true);// get rid of title bars and stuff
       mainFrame.setIgnoreRepaint(true);// ignore repainting que
       mainFrame.setResizable(false);// do not allow the frame to be resized
       OD_Mode = device.getDisplayMode();// save the old device configuration
       D_Mode = device.getDisplayMode();// initialy make new config as old
       if (device.isDisplayChangeSupported() == false) {
        System.out.println(" warning display mode change is unsupported ");
       if (device.isDisplayChangeSupported() == true) {// hopefully this is possible
        // set new d_mode to 640,480
        DisplayMode D_MODE = new DisplayMode(640, 480, 32, 0);
        // mow d_mode should basically have all the info for the device and the screen size
        // and the colormodel that is being used
        System.out.println(" display mode change is supported ");
       // is this still correct ?
       // know i have no idea how to use a volitile image or if i even need to
       Graphics pen = mainFrame.getGraphics();
       int acc_mem = device.getAvailableAcceleratedMemory();
       System.out.println(" available accelerated memory or ram left reported "+acc_mem);
       boolean done = true;
       long count = 0;
       while (done) {
       // Draw as appropriate using myGraphics ???? draw to what. memory ??
       // thats kinda a cut off in the tutorial left me hanging.
            count ++;
            //pen = getPaintGraphics();
            //pen = mainFrame.getPaintGraphics();
            //pen.setColor(Color.blue);
            //pen.drawLine(100,100,50,50);
            pen.drawLine(100,100,50,50);
         // check for exit  
         if(count > 200000000){
         System.out.println(" count "+count);
         done = false;
         pen.dispose();
    }thanks in advance for any help.

  • Using the jprogress bar for file byte array downloads

    I am currently using a byte array to send files back and forth between computers. To show a file is transferring i change the mouse to the hour glass but would like to use the jprogressbar.
    To send the file i read the file from one computer into a byte array, and then send it through an objectoutputstream. I am not sure how the file is sent or received though. What can i use to judge the length of time it takes to get one file from one computer to the other? In doing a debug, it looks like the oos sends the file to the other computer, and it is basically like an uploading process. is there a way for me to judge or tell how much of the file that is being uploaded is left?
    Thanks in advance

    If i know the file size how can i then check the progression? I would also like to use an progress bar on the upload of a file to the other computer, and for the download of the byte array to the other computer i could first give it the file size. if then what can i use to base my progression off of?
    i looked at this and it says i am not able to do it, but thought there might have been improvements in the jdk since then, and i might not be seeing them
    http://forum.java.sun.com/thread.jspa?threadID=357217&messageID=1490887
    Thanks

Maybe you are looking for

  • Open links in same window, not new

    Help greatly appreciated! My links open in a new window, but I need them to open in the same window. What do I need to add to my code so that this happens. Here is my code- stop(); var arrLinks:Array = new Array(); arrLinks[1] = ' http://www.diesel-e

  • My Mac Book Pro do not install OS, say error HD but not repear it. Now do not load the system.

    I have a MacBookPro 2012 no retina. I got it 22 December 2012. Mountain Lion installed. 2 months ago I updated to Yosemite. Yesterday, my MacPB did´t start up. Stay in White screen with a folder and a question mark flashing inside. I have a time mach

  • BUG: Airtunes does not work on all networks

    I have a brand new AX. When configured as a standalone wireless network for Airtunes, the iTunes errors out with "Unknown Error -15000" on 10.5.8, iTunes 8.2.1, IPV6:Auto, Firewall:Set to... or Allow all... I only had two networks to test this featur

  • What is .MTS video filetype and how to open?

    I have a Sony HX5V Cyber-shot camera that shoots nice video, but how to get it off the camera. I plugged the camera card into my computer and got what i think are the video files but they are named .MTS and Streamclip says it cannot open them. Any Id

  • HP M1319 MFP laserjet scan issues

    First off I'd like to thank all the admins and HP reps here for the fine work you all do... Ok to start, my wife has an HP LaserJet M1319 MFP Series, We installed the software from the disk but failed to load, So I went here to HP and downloaded the