Switch status

i have a motor which 
rotates in clockwise if switch s1 is actuated or 
rotates in Anti-clockwise if switch s2 is actuated. (both are separate switches)
In my logic it is stated that s1 state must be saved . (can i use a flip flop or latch or shift register ? )
It is also stated that S1-hold state .. what exactly it means and how can i realize it?

Hi John,
have you been able to solve your problem? You have not replied to my request to upload your file.
Best regards,
Abduelkerim
Sales
NI Germany

Similar Messages

  • How to read USER1 DIP-switch status of a cRIO chassis from FPGA?

    How can I  read the status of the DIP switches on a cRio chassis from the FPGA?
    I am working with a  cRIO 9022.. My idea is to set the system into a "service" mode by setting the USER1 switch to ON and communicate with the FPGA via the FPGA-GUI(VI) on the host computer instead via the RT module which is used under normal conditions.
    Any ideas? Unfortunately, I do not have an unused channel left ...and (as far as I know) can't use the RS232 from the FPGA.
    Many thanks in advance,
    Luke
    Solved!
    Go to Solution.

    Hi, this is the correct information. You cannot read from the FPGA the DIP switch status. The only thing you could do is to use the Read Switch.vi function located under Functions -> Real Time -> RT utilities  palette
    This is how you probably know only for the RT Host side and not the FPGA.
    Regards Anoj
    Anoj Mubarak
    National Instruments

  • 3560 switch status showing as amber

    Hi,
    In 3560 24 port PoE switch status is showing as amber and i given the sh env all command in the swiych i got the following output. Please help me to resolve the issue.
    The ouput as follows.
    3560#sh env all
    FAN is FAULTY
    TEMPERATURE is FAULTY
    POWER is OK
    RPS is NOT PRESENT.
    Regards,
    Ram

    Hie Ram,
    I guess the fan has gone faulty and hence switch is heating up. I would suggest to replace the fan immediately and keep the switch off till then.

  • FM - Switch Status error....

    In Cisco MDS FMS running on Windows 2003 Server, I see errors like "UknownUSer Name(Server), "Invalid Auth Password or Wrong Digest (Server)" under Status column against each switches and they are yellowed out and errors are occuring randomly. Switches are configured for TACACS authentication and they working fine.
    But when I launch the FM installed on my laptop and login, I do not see those errors.
    Could someone explain what causes those errors to come.
    Thanks
    Mohan A

    thanks Colin for your time.
    But AAA (tacacs+) uses Windows AD here. So, whenever a CLI user is created , automatically MDS creates an SNMP user (which I think is temporary) or vice versa. When it is automatically created, why do i need to create one more...would it not amount to duplication
    Or are they temporary ?
    Do you mean to say "create permanent users' using snmp-server command.
    If that is going to be the case,then how the passwords will be synchronised between CLI users (AD users via TACACS+) and SNMP users...i know some automatic synchronization happen implicitly.
    Also, I read the following Note from Cisco MDS config guide 3.0
    For an SNMPv3 operation using the external AAA server, user configurations in the external AAA server require AES to be the
    privacy protocol to use SNMP PDU encryption.
    --Thanks
    Mohan

  • Fabric Manager - switches status - No Traps.

    Greetings,
    When I am looking at the Fabric in Fabric Manager, the switches present information like name, etc.. and tere is a Status entry. I see Status of No Traps. What does it mean?
    Stephen

    If you get yellow text 'No Traps' in FM client means that the FM has not registered trap address on this switch successfully and hence not receiving traps from those switches. It may be that the trap address table is full (max is 10 entries) on the switch. If table is full, then delete any stale/unused addresses in the switch. The FMS's next periodic poll will add it's trap address to the switch and the 'No Traps' warning will go away after this. Try
    refreshing the Switch table in the FM client to see an updated status.
    And also check the Switches remain manageable even when "No Traps" is displayed. Then you are hitting bug CSCta72679. To workaround this Rediscovering the Fabric will change the status back to "ok" but this is only a temporary solution.

  • When/how do the scheduled packages switch status from 'scheduled' to 'ready' in the package Scheduler Status?

    Hi,
    I've scheduled FX Restatement packages to run each day in two different versions (6 times a day starting at 0615) for a year or so. However when I check out the 'View Package Status' the jobs I set up in the first version doesn't run when they are supposed to. I checked out the 'Package Scheduler Status' and I found that the jobs that DIDN'T run was stuck in a status called 'scheduled' while the jobs running had status 'ready'.
    So the question is how can I make sure all the jobs are running? Do I have to or can I do something about this myself? If I try to set up a package in two different versions, can the fact that I set them both to run at 0615 generate a conflict resulting in just one of them running?
    Hope someone has answers to these questions, would be so great to get this out of the way. Thanks!
    K

    Hi Kristoffer,
    remember to click on enable schedule when you schedule a package.
    To know if a scheduled package is ok you can see first if present in the tblschedule of your appset and also if present in the windows task schedulerif with status "ready".
    After you just have to check the view status if you found the package execution completed you're sure it's running. " version at the same time can cause issues also with different packages better to schedule with a sufficient delay to be sure that the first has ended, in your case 1 package is ok.
    I would delete the 2 packages from bpc, checking also the windows scheduler to be sure that no packages are running and rebuild one from scratch setting repeat every 4 hours and checking "enable schedule".
    Regards
         Roberto

  • How to include limit switches into my control loop and how to access them through Labview

    I'm developing a six degrees of freedom machine with servo motors,UMI flex6 and Labview-5.1.I was unable to access the limitswithes.So I would like to know the connections diagram,UMIflex6 board settings and the Vi's to be included in the program.please help me out in solving this problem.

    Hi Kolakanuru,
    Thanks for using our discussion forums. How you connect your limit switches depends on what type of motion board you are using. For example, if you look at the connection diagram for a PCI-7344, you can see that Forward Limit switches connect to pins 39, 45, 51, and 57. These will then pin out directly to the UMI. For the connection diagram for your particular motion control board, you can go to www.ni.com/manuals and pull up the necessary information. In regards to reading this in LabVIEW, the first thing you will want to check out is Measurement and Automation Explorer. In the interactive windows for your board, you can check the limit switch status there- Press your limit switch on and off and make sure that it changes the LED in MAX. Once that i
    s all set, then you can go into LabVIEW and use the "Read Limit Status" VI which you can find in Functions>>All Functions>>NI Measurements>>Motion>>FlexMotion>>Motion I/O palette. Good luck with your application.
    Regards
    Dan
    National Instruments

  • Get approval status in edit form

    Is there an easy way to retrieve item approval status (moderationStatus) inside the edit form? During display of edit form I need to know wheather the currently edited item was approved or not. I see that the information is not reflected in a hidden column
    or else. I have the following ideas:
    Custom flag column that indicates if the item was approved.
    Get the current item via js rest call and check OData__ModerationStatus.
    I just want to know if there is an easier way to get the moderationStatus of the item I am editing.
    Thank you!

    Hi Eng,
    As we all know, the approval status column is a hidden column in SharePoint and it cannot be edited manually, so there is no OOB way to display the column value in item edit form.
    The easiest way is to use code to get the current item and then display the _ModerationStatus value in your Edit Item form.
    Here is the code example:
    <script language="javascript" type="text/javascript">
    ExecuteOrDelayUntilScriptLoaded(runCode, 'sp.js');
    function runCode() {
    var value1=window.location.href.indexOf("?")+4;
    var value2=window.location.href.indexOf("&");
    var url=window.location.href;
    var itemId=url.substring(value1,value2);
    var clientContext = new SP.ClientContext();
    var targetList = clientContext.get_web().get_lists().getByTitle('Case Date');
    targetListItem = targetList.getItemById(itemId);
    clientContext.load(targetListItem, '_ModerationStatus');
    clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));
    function onQuerySucceeded() {
    var status=targetListItem.get_item('_ModerationStatus');
    switch(status) {
    case 0:
    alert("Approved");
    break;
    case 1:
    alert("Rejected");
    break;
    case 2:
    alert("Pending");
    break;
    case 3:
    alert("Draft");
    break;
    function onQueryFailed(sender, args) {
    alert('Request failed. \nError: ' + args.get_message() + '\nStackTrace: ' + args.get_stackTrace());
    </script>
    You can also take a look at the link below about changing the Approval Status column in Edit item form:
    http://www.codeproject.com/Articles/718575/Change-of-Approval-Status-in-SharePoint-Edit-Form
    Best regards.
    Thanks
    Victoria Xia
    TechNet Community Support

  • Test coverage of switch when using an enum

    I'm writing a unit test for the following: -
    switch (status) {
        case ACTIVE:
            return "A";
        case POSTED:
            return "P";
        default:
            throw new IllegalArgumentException("unknown status: " + status);
    }Where status variable is an enum type like: -
    public enum BatchStatus {
        ACTIVE, POSTED
    }I'm of the opinion that having the default branch above makes the code safer and more robust (it means that if the enum grows, problems can be immediately identified).
    So the question is... is it impossible to achieve 100% test coverage, but still retain the default branch above? Since the BatchStatus is an enum (and hence final, and cannot be instantiated), I can't create a third mock value that is neither ACTIVE nor POSTED, so I can't test the default branch.
    ???

    rather than use the switch block - which isn't very OO, and is a maintenance pain - why not have the enum itself return these values?
    public enum BatchStatus {
    ACTIVE("A"),
    POSTED("P");
    private BatchStatus(String status) {
        this.status = status;
    private String status;
    public String getStatus() {
        return this.status;
    }that way, the maintenance programmers have no option but to keep the lot up to date. this over-simplified example probably doesn't address your real problem, but it might point you in a direction you hadn't considered before

  • Front Panel Bank of Switches and related indicators

    I am designing a test system.  I would like a bank of switches on the from panel to turn individual test cases on/off.  I've figured out how to do that.  And I can do individual banks for the indicator (pass/fail) LEDs and the numeric test result field.  But, I'd like to tie them all together.  I'm  guessing I should start by using a cluster rather than an array.  But how to I get the various banks to act as a single group?
    As I have it so far, I have a back of switches and a bank of indicators (of switch status) for just playing around.  The indicators do not line up with the switches. I'd like a 1-to-1 correspondence for the operator's ease of use.  When I use "properties" to expand the indicator bank, it won't take the number.  It is internally limited somehow.
    DH
    Solved!
    Go to Solution.

    I've got an array of clusters now.  Much better, but not there yet.
    In the example provided, all of the indicators are labeled "T1".  I have the same issue with my implementation.  Change one label and it changes them all.  I would like to see "T1, T2, T3, ..." but cannot find a way to do that.  Also, I'd like each type in the cluster to be labeled at the head of the row or column on the front panel.  I can do this by brute force (just create a text field and plop it next to the array.  But I figure there has to be a more elegant solution.  One that ties the pieces together.
    Any thoughts?
    DH

  • Change Status Profile : User Status

    Hello Experts,
    We have created 14 User Status Values for Support Message in Solution Manager
    Status Profile: ZLFN0001 (Copy of SLFN0001) and modified to the requirements.
    Assigned this Status Profile to transaction type Zxxx
    Current settings:
    Status No.--Status-- Lowest -
    Highest -
    Trans.
    10--Status 01-1020--
    20--Status 02 -20--
    50 -
    INPR
    30--Status 03 -30--
    60 -
    INPR
    40--Status 04 -40--
    70 -
    INPR
    50--Status 05 -50--
    50 -
    FINI
    60--Status 06 -40--
    80 -
    INPR
    70--Status 07 -60--
    70 -
    FINI
    80--Status 08--80--
    91 -
    INPR
    90--Status 09--90--
    92 -
    INPR
    91--Status 10--60--
    91 -
    INPR
    92--Status 11--92--
    95 -
    INPR
    94--Status 12--94--
    94 -
    FINI
    95 -
    Status 13----9595--
    FINI
    96--Status 14--9696--
    FINI
    One of our requirements is that when the user status is Changed from "Status 08" to "Status 10", the only possible status available should be "Status 06" and the other statuses(07, 08 & 09) should be inactive or greyed out. Is there a possibility to hide status that is/are not required and the user should be able to see only 1 active status.
    What is the significance of Auth Code and Select Profile? Where do we assign Select profile to a Status Profile?
    Can anyone shed some light on this. Appreciate your response.
    Thanks,
    nancy

    Nancy, hi
    as far as I know, it is not possible to mark a status as inactive in certain cases.
    However, there might be a solution to your question:
    One ofcourse, is to change the order of the statuses so that you don't have to "skip" a status. For instance: switch status 8 with status 9, and change the properties of status 10 so that only status 9 can be reached (lowest status)
    The other option is to use authorizations on statuses, that's were the AUTH_KEY comes in. You can use the standard defined key, or you can create additional authorization keys.
    Let's say you create an additional key called Z_AUTH_1, and link this key to Status 08.
    An end user would then need to have this authorization key value in his role profile (object B_USERSTAT) to be able to set status 08.
    hope this answers your question.
    best regards,
    Jeroen.

  • 1815dn Scanner lock switch is STUCK

    I work as an internal support student for my coop placement. We have a dell 1815 all-in-one printer, and all be it old, it still works for exactly what the office needs
    Somehow in the morning, one of the employees accidentally locked the scanner. Its obvious that the lock switch is on the roof of the output tray. We even see the switch status indicator on the inside of the glass. But for some reason, it is STUCK. We have tried pulling it, pushing it, but we cannot for the life of us figure out why it wont budge. There seems to be a small locking feature beside the indicator on the inside of the glass, but we cannot get in to move the switch manually.
    We have tried gently and forcefully to move the lock switch, but it will NOT budge no matter how hard we push/pull 
    Has anyone solved this issue before? Or rather, does anyone know how to get inside the glass of the scanner? We understand that this printer is old, and no longer covered by any sort of warranty.
    Any help would be greatly appreciated!

    We had a representative from HP look at our printer when they were in servicing our other hardware. You failed to make it known that all switches have a small latch on the interior. All you have to do is use a small screwdriver and pull it down before attempting to pull it back into place...thats it.
    Im sure glad i didnt follow your "advice" in disassembling our entire printer for something so simple. Thanks for the delayed support, we will be continuing our business relationship with other companies that have the ability to support both their own products better then "here is a service manual, good luck"

  • Comparing switch control and switch output and setting switch control accordingly

    Hello,
            i am developing a GUI for a system which contains relays to control the motors. For the same purpose i am using switch control on my GUI to control these relays.when these relay  are turned ON by the switch control on my GUI, they give back status to the GUI, which i am displaying as a switch status .
    Now the switch control and switch status on GUI must be same every time so that user can know the actual state of relay and control it.
    Now i have a condition when i have already turned ON switch from my GUI but due to some reason (may be communication fault or anything else) rellay is not turned ON and i get status of relay as OFF on my switch indicator. So the situation is" the switch control is in ON state and switch indicator displays OFF state".  which is practically wrong.
    I want that in this case the GUI should detect the status of the switch indicator and if the switch control is not the same , the switch control should be set as per the switch indicator so that user can use the switch again to turn the switch ON

    Hello Mike,
                        Thanks for the response!!
    As i have described the situation above, in any case if switch control fails to send message to relay due to some hardware fault , in that case relays will be off and the switch on GUI will be ON , and user will think that the relay is ON.Which is false condition.
    i tried to use property value(signl)   to give back the status of switch indicator to the switch control.
    You can have a look at attached files which i have made as demo.
    Now the problem is when i run my GUI for the first time all the switch on the front panel are off by default which creates a conflict to control the switches.
    Besides i am unaware of the timing events and how to implement it in my application . It would be great if you could provide some more details about it.
    Thanks & Regards,
    Shivkant Paswan
    Attachments:
    switch control trial.zip ‏16 KB

  • Satellite L350 - Can't switch off wireless LAN

    The wireless switch and the Fn-F8 key combo don't appear to be switching off the wireless adapter (REALTEK RTL8187B) in my Satellite L350 (Win 7 Home Premium x32).
    ConfigFree shows the correct switch status i.e. OFF when it's off and ON when it's on. And the Fn+F8 key toggles between On and Off and recognises when the switch is off or on. But no matter whether they are on or off, the wireless connection icon in the notification area always show that "connections are available" and I can always establish a wireless connection. After toggling the Fn+F8 key a few times the established connection is dropped by conections are still shown as available.
    I've updated the BIOS and REALTEK device driver to the latest versions, but the wireless adapter still appears to be always on/enabled unless I disable it via the control panel or the ConfigFree icon that's in the notification area.
    Any suggestions about what the problem might be and is there a fix?
    Also, what is supposed to happen and what notifications are you supposed to get when you switch the wirelss off - either via the switch or Fn+F8? I only recently bought the L350 to replace my ageing Toshiba Satellite A30 so am new to wireless networking and Windows 7.
    TIA

    I have a Satellite L350 purchased pre loaded with Win7 Home Premium (32) and RealTek RTL8187B adapter which also has the fault described above.
    Namely: -
    1) The front panel RF/Wireless switch lights the LED in the "On" position and turns it off in the "Off" position. The wireless connection is not affected, it stays ON.
    2) The use of the FN+F8 keys gives an error message to turn the switch "On" if it is set to "Off", then once it is "On" correctly displays the setting. With the switch set to "On" the keys will turn off the LED on the front panel. The actual connection is unaffected by these actions and stays connected at all times unless disconnected via the notification area icon.
    I initially thought this was a hardware fault and returned it to the retailers as the switch was quite sloppy. It has been returned and shows the same problem as before even though the switch has been replaced.
    Therefore, having read the contents of this board it would seem there is a software issue here.
    How do we get this resolved or what update am I missing?
    The PC was bought at the end of Dec.

  • How do I set proxy settings for a Java app behind a corporate server?

    I have the source code of a Download Manager program written in Java. It has to be run within my college network in which we use the "Corporate Client" server to access the internet. The HTTP proxy is 172.16.68.6 and Port number is 3128. How do I define these parameters in my java program so that it can download files from the internet?
    The source code for the program is:
    There are four classes:
    1. DownloadManager.java
    2. Download.java
    3. DownloadTable.java
    4. ProgressRenderer.java
    /*__DownloadManager.java__*/
    import java.awt.*;
    import java.awt.event.*;
    import java.net.*;
    import java.util.*;
    import javax.swing.*;
    import javax.swing.event.*;
    // The Download Manager.
    public class DownloadManager extends JFrame
            implements Observer {
        // Add download text field.
        private JTextField addTextField;
        // Download table's data model.
        private DownloadsTableModel tableModel;
        // Table listing downloads.
        private JTable table;
        // These are the buttons for managing the selected download.
        private JButton pauseButton, resumeButton;
        private JButton cancelButton, clearButton;
        // Currently selected download.
        private Download selectedDownload;
        // Flag for whether or not table selection is being cleared.
        private boolean clearing;
        // Constructor for Download Manager.
        public DownloadManager() {
            // Set application title.
            setTitle("Download Manager");
            // Set window size.
            setSize(640, 480);
            // Handle window closing events.
            addWindowListener(new WindowAdapter() {
                public void windowClosing(WindowEvent e) {
                    actionExit();
            // Set up file menu.
            JMenuBar menuBar = new JMenuBar();
            JMenu fileMenu = new JMenu("File");
            fileMenu.setMnemonic(KeyEvent.VK_F);
            JMenuItem fileExitMenuItem = new JMenuItem("Exit",
                    KeyEvent.VK_X);
            fileExitMenuItem.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    actionExit();
            fileMenu.add(fileExitMenuItem);
            menuBar.add(fileMenu);
            setJMenuBar(menuBar);
            // Set up add panel.
            JPanel addPanel = new JPanel();
            addTextField = new JTextField(30);
            addPanel.add(addTextField);
            JButton addButton = new JButton("Add Download");
            addButton.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    actionAdd();
            addPanel.add(addButton);
            // Set up Downloads table.
            tableModel = new DownloadsTableModel();
            table = new JTable(tableModel);
            table.getSelectionModel().addListSelectionListener(new
                    ListSelectionListener() {
                public void valueChanged(ListSelectionEvent e) {
                    tableSelectionChanged();
            // Allow only one row at a time to be selected.
            table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
            // Set up ProgressBar as renderer for progress column.
            ProgressRenderer renderer = new ProgressRenderer(0, 100);
            renderer.setStringPainted(true); // show progress text
            table.setDefaultRenderer(JProgressBar.class, renderer);
            // Set table's row height large enough to fit JProgressBar.
            table.setRowHeight(
                    (int) renderer.getPreferredSize().getHeight());
            // Set up downloads panel.
            JPanel downloadsPanel = new JPanel();
            downloadsPanel.setBorder(
                    BorderFactory.createTitledBorder("Downloads"));
            downloadsPanel.setLayout(new BorderLayout());
            downloadsPanel.add(new JScrollPane(table),
                    BorderLayout.CENTER);
            // Set up buttons panel.
            JPanel buttonsPanel = new JPanel();
            pauseButton = new JButton("Pause");
            pauseButton.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    actionPause();
            pauseButton.setEnabled(false);
            buttonsPanel.add(pauseButton);
            resumeButton = new JButton("Resume");
            resumeButton.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    actionResume();
            resumeButton.setEnabled(false);
            buttonsPanel.add(resumeButton);
            cancelButton = new JButton("Cancel");
            cancelButton.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    actionCancel();
            cancelButton.setEnabled(false);
            buttonsPanel.add(cancelButton);
            clearButton = new JButton("Clear");
            clearButton.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    actionClear();
            clearButton.setEnabled(false);
            buttonsPanel.add(clearButton);
            // Add panels to display.
            getContentPane().setLayout(new BorderLayout());
            getContentPane().add(addPanel, BorderLayout.NORTH);
            getContentPane().add(downloadsPanel, BorderLayout.CENTER);
            getContentPane().add(buttonsPanel, BorderLayout.SOUTH);
        // Exit this program.
        private void actionExit() {
            System.exit(0);
        // Add a new download.
        private void actionAdd() {
            URL verifiedUrl = verifyUrl(addTextField.getText());
            if (verifiedUrl != null) {
                tableModel.addDownload(new Download(verifiedUrl));
                addTextField.setText(""); // reset add text field
            } else {
                JOptionPane.showMessageDialog(this,
                        "Invalid Download URL", "Error",
                        JOptionPane.ERROR_MESSAGE);
        // Verify download URL.
        private URL verifyUrl(String url) {
            // Only allow HTTP URLs.
            if (!url.toLowerCase().startsWith("http://"))
                return null;
            // Verify format of URL.
            URL verifiedUrl = null;
            try {
                verifiedUrl = new URL(url);
            } catch (Exception e) {
                return null;
            // Make sure URL specifies a file.
            if (verifiedUrl.getFile().length() < 2)
                return null;
            return verifiedUrl;
        // Called when table row selection changes.
        private void tableSelectionChanged() {
        /* Unregister from receiving notifications
           from the last selected download. */
            if (selectedDownload != null)
                selectedDownload.deleteObserver(DownloadManager.this);
        /* If not in the middle of clearing a download,
           set the selected download and register to
           receive notifications from it. */
            if (!clearing) {
                selectedDownload =
                        tableModel.getDownload(table.getSelectedRow());
                selectedDownload.addObserver(DownloadManager.this);
                updateButtons();
        // Pause the selected download.
        private void actionPause() {
            selectedDownload.pause();
            updateButtons();
        // Resume the selected download.
        private void actionResume() {
            selectedDownload.resume();
            updateButtons();
        // Cancel the selected download.
        private void actionCancel() {
            selectedDownload.cancel();
            updateButtons();
        // Clear the selected download.
        private void actionClear() {
            clearing = true;
            tableModel.clearDownload(table.getSelectedRow());
            clearing = false;
            selectedDownload = null;
            updateButtons();
      /* Update each button's state based off of the
         currently selected download's status. */
        private void updateButtons() {
            if (selectedDownload != null) {
                int status = selectedDownload.getStatus();
                switch (status) {
                    case Download.DOWNLOADING:
                        pauseButton.setEnabled(true);
                        resumeButton.setEnabled(false);
                        cancelButton.setEnabled(true);
                        clearButton.setEnabled(false);
                        break;
                    case Download.PAUSED:
                        pauseButton.setEnabled(false);
                        resumeButton.setEnabled(true);
                        cancelButton.setEnabled(true);
                        clearButton.setEnabled(false);
                        break;
                    case Download.ERROR:
                        pauseButton.setEnabled(false);
                        resumeButton.setEnabled(true);
                        cancelButton.setEnabled(false);
                        clearButton.setEnabled(true);
                        break;
                    default: // COMPLETE or CANCELLED
                        pauseButton.setEnabled(false);
                        resumeButton.setEnabled(false);
                        cancelButton.setEnabled(false);
                        clearButton.setEnabled(true);
            } else {
                // No download is selected in table.
                pauseButton.setEnabled(false);
                resumeButton.setEnabled(false);
                cancelButton.setEnabled(false);
                clearButton.setEnabled(false);
      /* Update is called when a Download notifies its
         observers of any changes. */
        public void update(Observable o, Object arg) {
            // Update buttons if the selected download has changed.
            if (selectedDownload != null && selectedDownload.equals(o))
                updateButtons();
        // Run the Download Manager.
        public static void main(String[] args) {
            DownloadManager manager = new DownloadManager();
            manager.show();
    This example shows how to create a simple download manager in Java. It contains four classes in foru Java source files:
    Download.java: Contains Download class which downloads a file from a URL.
    DownloadManager.java: Contains the main class for download manager application.
    DownloadsTableModel.java: Contains the class which manages the download table's data.
    ProgressRenderer.java: Contains the class which is responsible to render a JProgressBar in a table cell.
    The contents of the listed files are written below.
    /*__Download.java__*/
    import java.io.*;
    import java.net.*;
    import java.util.*;
    // This class downloads a file from a URL.
    class Download extends Observable implements Runnable {
        // Max size of download buffer.
        private static final int MAX_BUFFER_SIZE = 1024;
        // These are the status names.
        public static final String STATUSES[] = {"Downloading",
        "Paused", "Complete", "Cancelled", "Error"};
        // These are the status codes.
        public static final int DOWNLOADING = 0;
        public static final int PAUSED = 1;
        public static final int COMPLETE = 2;
        public static final int CANCELLED = 3;
        public static final int ERROR = 4;
        private URL url; // download URL
        private int size; // size of download in bytes
        private int downloaded; // number of bytes downloaded
        private int status; // current status of download
        // Constructor for Download.
        public Download(URL url) {
            this.url = url;
            size = -1;
            downloaded = 0;
            status = DOWNLOADING;
            // Begin the download.
            download();
        // Get this download's URL.
        public String getUrl() {
            return url.toString();
        // Get this download's size.
        public int getSize() {
            return size;
        // Get this download's progress.
        public float getProgress() {
            return ((float) downloaded / size) * 100;
        // Get this download's status.
        public int getStatus() {
            return status;
        // Pause this download.
        public void pause() {
            status = PAUSED;
            stateChanged();
        // Resume this download.
        public void resume() {
            status = DOWNLOADING;
            stateChanged();
            download();
        // Cancel this download.
        public void cancel() {
            status = CANCELLED;
            stateChanged();
        // Mark this download as having an error.
        private void error() {
            status = ERROR;
            stateChanged();
        // Start or resume downloading.
        private void download() {
            Thread thread = new Thread(this);
            thread.start();
        // Get file name portion of URL.
        private String getFileName(URL url) {
            String fileName = url.getFile();
            return fileName.substring(fileName.lastIndexOf('/') + 1);
        // Download file.
        public void run() {
            RandomAccessFile file = null;
            InputStream stream = null;
            try {
                // Open connection to URL.
                HttpURLConnection connection =
                        (HttpURLConnection) url.openConnection();
                // Specify what portion of file to download.
                connection.setRequestProperty("Range",
                        "bytes=" + downloaded + "-");
                // Connect to server.
                connection.connect();
                // Make sure response code is in the 200 range.
                if (connection.getResponseCode() / 100 != 2) {
                    error();
                // Check for valid content length.
                int contentLength = connection.getContentLength();
                if (contentLength < 1) {
                    error();
          /* Set the size for this download if it
             hasn't been already set. */
                if (size == -1) {
                    size = contentLength;
                    stateChanged();
                // Open file and seek to the end of it.
                file = new RandomAccessFile(getFileName(url), "rw");
                file.seek(downloaded);
                stream = connection.getInputStream();
                while (status == DOWNLOADING) {
            /* Size buffer according to how much of the
               file is left to download. */
                    byte buffer[];
                    if (size - downloaded > MAX_BUFFER_SIZE) {
                        buffer = new byte[MAX_BUFFER_SIZE];
                    } else {
                        buffer = new byte[size - downloaded];
                    // Read from server into buffer.
                    int read = stream.read(buffer);
                    if (read == -1)
                        break;
                    // Write buffer to file.
                    file.write(buffer, 0, read);
                    downloaded += read;
                    stateChanged();
          /* Change status to complete if this point was
             reached because downloading has finished. */
                if (status == DOWNLOADING) {
                    status = COMPLETE;
                    stateChanged();
            } catch (Exception e) {
                error();
            } finally {
                // Close file.
                if (file != null) {
                    try {
                        file.close();
                    } catch (Exception e) {}
                // Close connection to server.
                if (stream != null) {
                    try {
                        stream.close();
                    } catch (Exception e) {}
        // Notify observers that this download's status has changed.
        private void stateChanged() {
            setChanged();
            notifyObservers();
    /*__DownloadTableModel.java__*/
    import java.util.*;
    import javax.swing.*;
    import javax.swing.table.*;
    // This class manages the download table's data.
    class DownloadsTableModel extends AbstractTableModel
            implements Observer {
        // These are the names for the table's columns.
        private static final String[] columnNames = {"URL", "Size",
        "Progress", "Status"};
        // These are the classes for each column's values.
        private static final Class[] columnClasses = {String.class,
        String.class, JProgressBar.class, String.class};
        // The table's list of downloads.
        private ArrayList downloadList = new ArrayList();
        // Add a new download to the table.
        public void addDownload(Download download) {
            // Register to be notified when the download changes.
            download.addObserver(this);
            downloadList.add(download);
            // Fire table row insertion notification to table.
            fireTableRowsInserted(getRowCount() - 1, getRowCount() - 1);
        // Get a download for the specified row.
        public Download getDownload(int row) {
            return (Download) downloadList.get(row);
        // Remove a download from the list.
        public void clearDownload(int row) {
            downloadList.remove(row);
            // Fire table row deletion notification to table.
            fireTableRowsDeleted(row, row);
        // Get table's column count.
        public int getColumnCount() {
            return columnNames.length;
        // Get a column's name.
        public String getColumnName(int col) {
            return columnNames[col];
        // Get a column's class.
        public Class getColumnClass(int col) {
            return columnClasses[col];
        // Get table's row count.
        public int getRowCount() {
            return downloadList.size();
        // Get value for a specific row and column combination.
        public Object getValueAt(int row, int col) {
            Download download = (Download) downloadList.get(row);
            switch (col) {
                case 0: // URL
                    return download.getUrl();
                case 1: // Size
                    int size = download.getSize();
                    return (size == -1) ? "" : Integer.toString(size);
                case 2: // Progress
                    return new Float(download.getProgress());
                case 3: // Status
                    return Download.STATUSES[download.getStatus()];
            return "";
      /* Update is called when a Download notifies its
         observers of any changes */
        public void update(Observable o, Object arg) {
            int index = downloadList.indexOf(o);
            // Fire table row update notification to table.
            fireTableRowsUpdated(index, index);
    /*__ProgressRenderer.java__*/
    import java.awt.*;
    import javax.swing.*;
    import javax.swing.table.*;
    // This class renders a JProgressBar in a table cell.
    class ProgressRenderer extends JProgressBar
            implements TableCellRenderer {
        // Constructor for ProgressRenderer.
        public ProgressRenderer(int min, int max) {
            super(min, max);
      /* Returns this JProgressBar as the renderer
         for the given table cell. */
        public Component getTableCellRendererComponent(
                JTable table, Object value, boolean isSelected,
                boolean hasFocus, int row, int column) {
            // Set JProgressBar's percent complete value.
            setValue((int) ((Float) value).floatValue());
            return this;
    }

    Thank you for the quick reply! But the solution provided by you, it seems, has still not been able to address my issue. I ran the program at command prompt with your said parameters, but the download still gave an error in the App window.
    Also, is there some way of defining these parameters in the source code? I am keen in using NetBeans to run the program.
    Cheers!

Maybe you are looking for