|
Hi, I am trying to make a progress monitor bar for a long execution. The program is basically trying to scan the local network (which takes about two minutes). I have a result class which prepares a JPanel that can be placed in the UI with the results. I want to have a neat progress bar for the whole process. I did make a ProgressMonitor object with a Task class and PropertyChangeListener as of the example in: http://download.oracle.com/javase/tutorial/uiswing/components/progress.html class Task extends SwingWorker<Void, Void> { @Override public Void doInBackground() {
so currently it is like a fake progress bar which just based on the thread sleep time. Currently my approach is create another thread in action listener class that runs the result class but for some reason I can't call back the JPanel object from asynchronously.... I tried to used the ExecutorService with FutureTask but not sure whether I am using it the right way. A general flowchart of my current app is like UI-->scan button-->at actionlistener for scan button creation of the swingworker for task and executorservice public void actionPerformed(ActionEvent e) { if (e.getActionCommand ().equals ("Close")) { System.exit(0); }
||1*||------------------------>f = new FutureTask(new resultset()); es.submit(f);
||1*|| is what i what to run parallel to the progress monitor in the above code the scan button gets clicked and stays enabled until the scan is done but the progress monitor bar never shows up. removing ||1*|| just shows up the progress bar but ofcourse the scan never took place. ANY HELP IN CORRECT WAY OF SETTING IT UP or USE OF A DIFFERENT APPROACH WOULD BE GREATLY APPRECIATED!!
(comments are locked)
|
|
yes, i gotcha boss! first and mostly go to Timer & TimerTask ( prob in util or something ) then do an un-sync() something or other on an [][] ( Raster.java ) obtained from a BufferedImage which is used as the object upon which graphics.draw() in paint operates this no fun the first time and many times thereafter but getting the Timer & TimerTask to operate something like what you want is the first thing to do prior to doing any draw operation = the way you have it is ( short of testing to find out what it really does ) is likely to get you a form of Thread starvation the the Timer & TimerTask keep you from that Drag_ON by design as they run in the JVM in a manner designed by engineers to avoid beginner style thread starvation
Nick
(comments are locked)
|