Displaying Progress Bar

Hello,
I want to display progress bar based on the bytes received from socket.  The tutorials and examples show only image loading.  Is it possible to display progress bar based on bytes received for socket.  If so, can anyone tell me how to do it?
var total_bytes:Number=0;
public function bytesReceived(event:ProgressEvent):void
       var bytes_received = event.bytes.loaded;
       total_bytes = bytes_received + total_bytes;
Thanks

Use SwingWorker, which is not included in Swing library, but you can find it on http://java.sun.com/docs/books/tutorial/uiswing/components/example-swing/SwingWorker.java;
see alse http://java.sun.com/docs/books/tutorial/uiswing/components/progress.html.

Similar Messages

  • How to display progress bar

    In the AIUserSuite there is not a way to display the progress bar, seached everywhere and found nothing.
    Please help!

    minimum99 wrote:
    Is that something you can share?
    I'm afraid not. Even if I were allowed to, it wouldn't be much use -- it's built on a ton of internal stuff
    I think you're on the right track with just doing it manually. Throwing up a simple progress window isn't too bad; the only pain is in the flags, to make it semi-modal. The rest is very straight forward.

  • Display progress bar and message for delay

    hi all,
        I have an application in which, when i execute the RFC it is taking time to get the data. So it is displaying a white screen for the user untill the data is retrieved from the backend.
    I want to show a progress bar or any thing of that kind so that user knows that data is being loaded.
    Is there a way to do that?
    Regards,
    Gopi

    Hi,
       You might want to go through <a href="/people/valery.silaev/blog/2006/10/09/loading-please-wait blog.
    Regards,
    Satyajit.

  • Displaying progress bar while components load

    I'm going to display a JTree that's quite huge (takes time to load; I need to get the info as XML from a server, etc.)
    So, I want to display a JProgressBar while it is loading.
    My plan was to use a cardlayout, and show the panel with the progress bar until the tree was loaded and then do a .show("tree") on the main panel with the card layout.
    However, this does not seem to work. Nothing is displayed before the tree is loaded ...
    Any suggestions on best ways to do this?
    Here's my class so far:
    public class HierarchyJTree extends JPanel {
        private static Logger logger = Logger.getLogger(HierarchyJTree.class);
        private JProgressBar progress;          // keep track on progress
        private TreeMap idmap = new TreeMap(); // to map nodes created up against their id's; needed to create the tree structure when we have a parent id and want the node
        private dataAccess access = dataAccess.getInstance();
        private JTree tree;
        private CardLayout card = new CardLayout();
        private int maxProgress = 20;
         * Construct a new JTree. Collect the category information from the database.
        public HierarchyJTree() {
            this.setLayout(card);
            JPanel progressPanel = new JPanel();
            progress = new JProgressBar(0,maxProgress);
            progressPanel.add(progress);
            this.add(progressPanel, "progress");
            card.show(this,"progress");
        public void startCollectingData() {
            progress.setValue(2);
            ResultSet rs = access.sendXML("<request>\n<runQuery>getCategories</runQuery>\n</request>");
            progress.setValue(10);
            tree = new JTree(new DefaultMutableTreeNode("Categories", true));
            tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
            JPanel treePanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
            treePanel.add(tree);
            this.add(treePanel, "tree");
            addFromResultSetToTree(rs);
            card.show(this, "tree");
         * Constructor that will use incomming ResultSet to create the tree, instead of contacting
         * the server to get a new one
         * @param resultset containing the category info from MOD_category
        public HierarchyJTree(ResultSet resultset) {
            this.setLayout(card);
            tree = new JTree(new DefaultMutableTreeNode("Categories", true));
            BasicConfigurator.configure();
            tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
            addFromResultSetToTree(resultset);
         * This will take a jaxb.ResultSet object containing ID, categoryName and parentID of all the
         * categories in the database, and add them as Nodes in the JTree this class represents.
         * @param r the jaxb.ResultSet object
        private void addFromResultSetToTree(ResultSet r) {
             // code to load the info into the tree here, and inc the progress
                progressValue += incValue;
                progress.setValue((int)Math.round(progressValue));
    }

    Use SwingWorker, which is not included in Swing library, but you can find it on http://java.sun.com/docs/books/tutorial/uiswing/components/example-swing/SwingWorker.java;
    see alse http://java.sun.com/docs/books/tutorial/uiswing/components/progress.html.

  • Display Progress Bar

    Hi all,
    i am j2me programer i am receving data or file from server but i want to diaplay actual progress bar how it is possible. provide some code
    thanks in advance
    Regards,
    Nagendra Kumar

    for using scroll bar we have in j2me a gauge class in high level display.
    it will work acc to ur req.
    work for it ok

  • Display progress bar during silent install?

    Hello everybody,
    as the silent installation takes up to several minutes, it would be useful to display a progress bar during the installation. Is there a parameter which allows to enable such a progess window during the installation?
    Thanks for any ideas.

    The progress bar means the system is Auto booting to Safe Mode, not a good sign.
    The reasons it is Auto Booting into Safe mode can vary but more then likely it is either a hard drive problem, failing hard drive, or a corrupted hard drive. I would save all your personal files, data, to an external drive and start over by erasing the complete drive and reinstalling the OS and all your programs. Then copy your data back to the drive. If it happens again then it means the drive is starting to fail and needs to be replaced.

  • Volume Display (progress bar)

    Nano used to show slide bar for volume and song length(progress bar), Now is appears as 5 dots and i can no longer see how long until the end of the song. I can't figure out how this setting changed but i want it back the old way. Help.

    just press the center button while the song is playing. The setting changed when you updated to the newest software update v1.1
    The lyrics, album art, rating screen, stay on screen and must be changed manually.

  • How can i Create a PROGRESSIVE BAR   while process of a procedure is going

    hi,
    I have a push button in my form that runs the procedure .the process will approx 15 minutes. while processing is started, i want to display PROGRESSIVE BAR
    until process complete and exits automatically after process . please suggest me how to create the same, is it possible..
    please send me solution as soon as possible please
    thanks in advance
    prasanth

    The forms demos contains a progress bar bean which you can use if web deployed.
    Regards
    Grant Ronald
    Forms Product Management

  • Progress bar for RTMP protocol

    Hi Guys,
    Anyone know about progress bar in rtmp i m making player using rtmp protocol because it allow to seek in any position even if the video data is not cache but i did not solve this issue how to display progress bar data is loaded i can do this in http protocol using Netstream.bytesLoaded and Netstream.bytesTotal i know rtmp is streaming video but i just want to know the when we pause in youtube u can see bufferlength in light gray which indicate this much of video cache i want to does they rtmp protocol or something else.

    Hi,
    Why can't you use NetStream.bytesLoaded and NetStream.bytesTotal for RTMP streams as well ? NetStream is a top level object that can bind to both HTTP as well as RTMP streams. Please give it a try and let us know if that worked for you.
    Thank you  !

  • Progress bar for database connection

    hi all,
    while connecting to databse the application is frozen for some time. i want to display progress bar to let the user know what is happening.
    how to display progress bar while connecting to database. help me out with sample code.
    Thanks n regards
    suresh

    http://java.sun.com/docs/books/tutorial/uiswing/components/progress.html

  • Progress bar inside datagrid

    Hi All,
    I have a datagrid in which i have to display progress bar with the task completed in %.
    for example i have  two fields in a table source count and completion count.
    where source count in 100000 rows and 50000 rows have been inserted.
    in another table and status is displayed in the table.
    so i need to display in a progress bar that 50% task has been completed.
    Any suggestions or ideas.
    Sample ex:

    Hello,
    here is something to play with:
    public class ProgressInTableTest {
        private static final Random RANDOM = new Random();
        private final class RunnableDummyProgressProducer implements Runnable {
            private final DefaultTableModel defaultTableModel;
            private final JProgressBar allProgress;
            private RunnableDummyProgressProducer(
                    DefaultTableModel defaultTableModel, JProgressBar allProgress) {
                this.defaultTableModel = defaultTableModel;
                this.allProgress = allProgress;
            @Override
            public void run() {
                for (int i = 0; i < progressEntries.size(); i++) {
                    ProgressEntry progressEntry = progressEntries.get(i);
                    while (100 > progressEntry.progress * 100
                            / progressEntry.fileSize) {
                        progressEntry.progress += 10;
                        defaultTableModel.fireTableCellUpdated(i, 2);
                        try {
                            Thread.sleep(50);
                        } catch (InterruptedException e) {
                            e.printStackTrace();
                    progressEntry.progress = progressEntry.fileSize;
                    SwingUtilities.invokeLater(new Runnable() {
                        @Override
                        public void run() {
                            allProgress.setValue(allProgress.getValue() + 1);
                            allProgress.setString(String.format("%s / %s",
                                    allProgress.getValue(),
                                    allProgress.getMaximum()));
                    defaultTableModel.fireTableCellUpdated(i, 2);
        private final class DefaultTableCellRendererExample extends
                DefaultTableCellRenderer {
            private static final long serialVersionUID = 1L;
            @Override
            public Component getTableCellRendererComponent(JTable table,
                    Object value, boolean isSelected, boolean hasFocus, int row,
                    int column) {
                Component rendererComponent = super.getTableCellRendererComponent(
                        table, value, isSelected, hasFocus, row, column);
                JTextField newRenderer = new JTextField();
                ProgressEntry progressEntry = progressEntries.get(row);
                switch (progressEntry.progress * 100 / progressEntry.fileSize) {
                case 0:
                    newRenderer.setText("pending");
                    return newRenderer;
                case 100:
                    newRenderer.setText("done");
                    return newRenderer;
                default:
                    rendererComponent = new JProgressBar(0, progressEntry.fileSize);
                    JProgressBar jProgressBar = (JProgressBar) rendererComponent;
                    jProgressBar.setValue(progressEntry.progress);
                    jProgressBar.setStringPainted(true);
                return rendererComponent;
        private final class DefaultTableModelExample extends DefaultTableModel {
            private static final long serialVersionUID = 1L;
            private final String[] columnNames = { "file name", "file size",
                    "progress" };
            private DefaultTableModelExample(int rowCount, int columnCount) {
                super(rowCount, columnCount);
            @Override
            public String getColumnName(int column) {
                return columnNames[column];
            @Override
            public Class<?> getColumnClass(int collumn) {
                switch (collumn) {
                case 1:
                    return Integer.class;
                case 2:
                    return ProgressEntry.class;
                default:
                    return String.class;
            @Override
            public Object getValueAt(int row, int column) {
                switch (column) {
                case 0:
                    return progressEntries.get(row).fileName;
                case 1:
                    return progressEntries.get(row).fileSize;
                case 2:
                    return progressEntries.get(row).progress;
                default:
                    return super.getValueAt(row, column);
        public class ProgressEntry {
            private final String fileName;
            private final int fileSize;
            private int progress = 0;
            public ProgressEntry(String fileName, int fileSize) {
                this.fileName = fileName;
                this.fileSize = fileSize;
        private final List<ProgressEntry> progressEntries = new ArrayList<ProgressEntry>();
        @Test
        public void test() {
            initializeSampleData();
            JProgressBar allProgress = createFileCountProgress();
            DefaultTableModel defaultTableModel = new DefaultTableModelExample(
                    progressEntries.size(), 3);
            JTable table = createTable(defaultTableModel);
            startDummyProcess(allProgress, defaultTableModel);
            JPanel message = completeGUI(allProgress, table);
            JOptionPane.showMessageDialog(null, message, "ProgressTest",
                    JOptionPane.PLAIN_MESSAGE);
        private JPanel completeGUI(final JProgressBar allProgress, JTable table) {
            JPanel message = new JPanel(new BorderLayout());
            message.add(new JScrollPane(table), BorderLayout.CENTER);
            message.add(allProgress, BorderLayout.SOUTH);
            return message;
        private void startDummyProcess(final JProgressBar allProgress,
                final DefaultTableModel defaultTableModel) {
            new Thread(new RunnableDummyProgressProducer(defaultTableModel,
                    allProgress), "ProgressTest").start();
        private JTable createTable(final DefaultTableModel defaultTableModel) {
            JTable table = new JTable(defaultTableModel);
            table.setDefaultRenderer(ProgressEntry.class,
                    new DefaultTableCellRendererExample());
            return table;
        private JProgressBar createFileCountProgress() {
            final JProgressBar allProgress = new JProgressBar(0,
                    progressEntries.size());
            allProgress.setStringPainted(true);
            return allProgress;
        private void initializeSampleData() {
            for (int i = 0; i < 20; i++) {
                progressEntries.add(new ProgressEntry(String.format("IMG_%03d.jpg",
                        i), RANDOM.nextInt(1000)));
            for (int i = 0; i < 3; i++) {
                progressEntries.get(i).progress = progressEntries.get(i).fileSize;
            progressEntries.get(3).progress = 50;
    bye
    TPD

  • Progress bar according to databases status?

    Helo frens........
    i need to display progress bar according to database status i.e. as one programm is taking data (mobile no ) and sending msg to that mobile no how to display it

    Helo frens........
    i need to display progress bar according to database
    status i.e. as one programm is taking data (mobile no
    ) and sending msg to that mobile no how to display itI don't know of a way to estimate how much of your query job is done, nor do I know of a database tool that is sufficiently accurate to allow a percentabe type of update progress to be shown, but you could make a moving bar that resets when it hits the end--make it fairly rapidly moving to not confuse anyone looking at it--so they don't think it is an actual one time through and your are done progress type.
    The progress bar needs to run in a seperate thread then and when your process returns from it's call, then you shut down your progress bar.

  • Jsf progress bar

    Hello,
    I have an application where I need to read a large text file and insert data to database.I want to display progress bar(I am using netbeans 6.1 and hence woodstock progress bar) while the above process running in the background.I am not sure whether I have run that process in a separate thread.Please help with any ideas on how to use progress bar for this purpose.
    Thanks in advance

    harish7447 wrote:
    Can you please explain how you fixed it?Use Javascript to display an initially hidden element which has an animated loading gif in it.
    If you want a realtime 0-100% progress bar, have a look to RichFaces. They have such a component.
    Also if possible put in your code snippet. I would appreciate it a lot. This is not a code factory or so. Start your own topic where in you elaborate the problem [the smart way|http://catb.org/esr/faqs/smart-questions.html].

  • How to determine a sql query size to display a progress bar

    I would like to show a progress of an sql query within a jsp page.
    Background:
    I have a reporting web application, where over 500 contacts can run reports based on different criteria such as date range....
    I current display a message stating 'executng query please wait', however the users (hate users) do not seem to wait, thereofore they decide to run the query all over again which affected my reportign sever query size (eventually this crashes, stopping all reports)
    Problem:
    The progress bar is not a problem, how would I determine the size of the query at runtime therefore adding the time onto my progress bar.

    Yes it's doable (we do it) but it sure ain't easy.
    We've got about 23,500,000 features (and counting) in a geodata database. Precise spatial selection algorithms are expensive. Really expensive.
    We cannot impose arbitrary limits on search criteria. If the client requires the whole database we are contractually obligated to provide it...
    For online searches We use statistics to approximate the number of features which a given query is likely to return... more or less the same way that the query optimiser behind any half decent (not mysql (5 alteast)) database management system does.
    We have a batch job which records how many features are linked to each distinct value of each search criteria... we just do the calculations (presuming a normal (flat) distribution) and...
    ... if the answer is more than a 100,000 we inform the user that the request must be "batched", and give them a form to fill out confirming there contact details. We run the extract overnight and send the user an email containing a link which allows them to download the result the next morning.
    ... if the answer is more than a million features we inform the user that the request must batched over the weekend... same deal as above, except we do it over the weekend to (a) discourage this; and (b) the official version ensure we have enough time to run the extract without impinging upon the maintenance window.
    ... if the answer is more than 5 million we display our brilliant "subscribe to our DVD service to get the latest version of the whole shebang every three months (or so), so you can kill your own blooody server with these ridiculous searches" form.
    Edited by: corlettk on Dec 5, 2007 11:12 AM

  • Displaying an Indeterminate Progress Bar While a DB2 Stored Proceedure Runs

    How do I display a dialog with an indeterminate progress bar while a DB2 query runs? Could anyone point me to an example or some strong docs?
    I learned Java about six months ago, so I'm relatively new to the language. Through searching and documentation, I've been able to find all the examples and answers I've needed so far. Now I've run into an issue I can't find anywhere. It seems like the most basic thing in the world. I have a DB2 stored procedure that takes about 5 minutes to run. While it's running, I want to display a simple dialog with a progress bar going back and forth (no buttons, no user interaction).
    I'm using Eclipse 3.3.1.1 as my IDE, and running the application from a JAR file. I have Java 1.6.0.30 installed. The DB2 query is running in response to a user clicking a button on the form (an ActionEvent). All of my forms are using Swing (JFrame, JDialog, etc.).
    The crux of my problem seems to be that I can bring up a dialog (which should contain the progress bar), but I can't get it to paint. All I get is a window that's the right size/location, but contains an after-image of what was behind it. I can't even get a dialog to display with a "Please Wait" label while the DB2 procedure runs.
    I tried separating both the DB2 stored procedure and the progress dialog into separate threads. I tried yielding in the DB2 thread to give the progress dialog a chance to update. I tried using invokeAndWait, but I got the following error:
    Exception in thread "AWT-EventQueue-0" java.lang.Error: Cannot call invokeAndWait from the event dispatcher thread
    It seems like I'm doing something wrong in my use of Theads, but I can't for the life of me figure out what it is. If anyone could help out a bit of a Java newbie, I would be extremely grateful.

    Demo:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class ProgressBarExample2 {
        private JProgressBar bar = new JProgressBar(0,99);
        private JButton button = new JButton("Lengthy operation");
        private ActionListener al = new ActionListener(){
           public void actionPerformed(ActionEvent evt) {
                button.setEnabled(false);
                bar.setIndeterminate(true);
                new Worker().execute();
        private class Worker extends SwingWorker<Boolean, Boolean>{
            protected Boolean doInBackground() {
                try {
                    Thread.sleep(10000); //10 secs
                } catch (InterruptedException e) {
                return Boolean.TRUE;
            protected void done() {
                button.setEnabled(true);
                bar.setIndeterminate(false);
        public static void main(String[] args) {
            EventQueue.invokeLater(new Runnable() {
                public void run() {
                    new ProgressBarExample2();
        ProgressBarExample2() {
            button.addActionListener(al);
            JPanel cp = new JPanel();
            cp.add(button);
            cp.add(bar);
            JFrame f = new JFrame("ProgressBarExample2");
            f.setContentPane(cp);
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.pack();
            f.setLocationRelativeTo(null);
            f.setVisible(true);
    }

Maybe you are looking for

  • How do I stop my itunes from opening everytime I download a song.

    Whenever I download a song or album from the internet my itunes opens and starts playing the song automatically. How do I stop this?

  • ICloud problems - multiple apple ids, ids in non-email format , bugs

       There is a major bug involving AppleIDs.  I searched the web and contacted tech support and gave up after hours on the phone of them trying things that didn't fix the problem.    The bug has to do with AppleIDs - I had an appleID, "myname" that I

  • Am I able to switch to the iPhone 4S... without ch...

    I have a Nokia E72 and I was wondering if I could upgrade to a better plan if optus waves the switch of contract fee or whatever? thanks

  • WebLogicManaged Server

    I'm very new to wls60. I just finished installing it on an NT 4.0 server. It's working fine when staring the default server and connecting to it from a remote browser. However, I'm trying to add a weblogic managed server to the mydomain(default) from

  • Getting blue screen all of a sudden

    Any idea why I would be getting a blue screen when using my MBP? I normally don't wait to see if it will clear itself, i will usually just restart my laptop. It happens once every other day.