Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


sabeer
usb detection
3 Answer(s)      3 years and 10 months ago
Posted in : Java Beginners


i want to detect usb device using javacode


Advertisement
View Answers

June 9, 2012 at 4:50 PM


try this:

import java.io.*;
import javax.swing.*;
public class DetectWin extends JFrame
{
    JPanel loginPnl = new JPanel();
    JTextField Dfield = new JTextField("", 20);
    
    DetectWin()
    {
        super("AUTHORIZATION");
        setSize(350, 100);
        setLocation(400, 300);
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        add(loginPnl);
        setVisible(true);
        setResizable(false);
        
        loginPnl.add(Dfield);
        String[] letters = new String[]{ "A", "B", "C", "D", "E", "F", "G", "H", "I", "Z"};
        File[] drives = new File[letters.length];
        boolean[] isDrive = new boolean[letters.length];

        for ( int i = 0; i < letters.length; ++i )
            {
            drives[i] = new File(letters[i]+":/");

            isDrive[i] = drives[i].canRead();
            }

         Dfield.setText("Waiting for devices....");

         while(true)
            {
            for ( int i = 0; i < letters.length; ++i )
                {
                boolean pluggedIn = drives[i].canRead();

                if ( pluggedIn != isDrive[i] )
                    {
                    if ( pluggedIn )
                    	Dfield.setText("Drive "+letters[i]+" has been plugged in");
                    else
                    	Dfield.setText("Drive "+letters[i]+" has been unplugged");

                    isDrive[i] = pluggedIn;
                    }
                }

            try { Thread.sleep(100); }
            catch (InterruptedException e) { }
            }
    }
    public static void main(String args[])
    {
        DetectWin AUTHORIZATION = new DetectWin();
    }
}



January 30, 2013 at 7:30 AM


hiii...

i tried this program but cannot read or detect my USB device. can you explain me, why...?

tq



February 25, 2013 at 8:40 AM


Hiii, nice posting...

i tried this code and running more than 5 minutes but can not read or detect my USB device. i'm using windows 7-64 bit, netbeans 7.1.2 and my device using USB type B connected to PC using USB type A.

can you explain me, why...?

best regards

-kiper-



Related Tutorials/Questions & Answers:
usb detection
usb detection  i want to detect usb device using javacode
JMF WebCam detection problem - Framework
JMF WebCam detection problem  Hello friends, I am using JMF to operate my web cam.My usb webcam works perfectly with JMF, I used it in JMStudio... = CaptureDeviceManager.getDeviceList( null ); my USB "webcam" is detected however when i
Advertisements
unique manufacturing id of a usb flash drive.
unique manufacturing id of a usb flash drive.  I need code for java application to read the unique manufacturing id of a usb flash drive. Please help me ? thanking you
VoIP USB Phone
VoIP USB Phone          A Corinex VoIP USB Phone A USB phone which can... included in the USB phone packaging to be able to use this software
php browser detection script - PHP
php browser detection script   I need a browser detection script in PHP. I am creating my application compatible to firefor, mozila and IE too
detection of the operating system on the client machine
detection of the operating system on the client machine  How to detect the operating system on the client machine
Java Circle to Circle collision detection
Java Circle to Circle collision detection  Java Circle to Circle collision detection
Collision Detection between two images in Java
Collision Detection between two images in Java  Collision Detection between two images in Java
java collision detection between two images
java collision detection between two images  java collision detection between two images
how to run java program that has several classes under package from usb drive?
how to run java program that has several classes under package from usb drive?  I have an assignment where I have to submit my code in flash drive. I did all coding in eclipse and getting all output. I tried running it through
error detection - Java Beginners
{ public static void main (string[] args) { Queue q=new
Flex event phase detection example
Flex event phase detection example       With example below an introduction of phases in flex is demonstrated. In flex there are three phases. capturing, targeting and bubbling
What is eToken?
. It looks similar to pen drive and fixes in the USB port of the computer... with USB interface that attaches in the USB Port. As it fixes in the USB port
VoIP Headsets
wireless headset for VoIP applications with remote call detection and answer... comfortable wearing options, and hands-free convenience via your USB port. A complete wireless VoIP softphone solution that quickly connects to your USB port
jUSB api
jUSB api  How can i access the USB using jUSB api and also hw to add this api to the netbeans
Mobile phones in 2011
, USB, Geo-tagging, touch focus, face and smile detection OS: Android...: GPRS, EDGE, 3G, Bluetooth, USB Memory: Internal 90 MB, external up to 8 GB..., RSS, Geo tagging, and Face Detection features OS: Android OS, v2.1
VoIP Adapters
number with an area code and a unique number.      USB Telebox Adapter for VoIP The telebox adapter connects to your PC via USB.... There are some features of USB telebox adapter is following here's
VoIP Modem
cancellation, high-pass filter, and voice activity detection (VAD) * Issuing redundant... * Differentiating modem signals from voice and fax signals, indicating the detection... to a computer through either a 10/100Base-T Ethernet or a USB data port.  
ajay
ajay  can anyone tell me how intrusion detection system works. and how it can be developed by using java
We are providing Knoppix 3.6 Live Linux CD's
. It auto-detects hardware and supports many graphics cards, sound cards, USB... update - FreeNX-Server package from Fabian Franz - hardware detection updates &... or IMPS/2-compatible USB-mouse * If your computer doesn't have that much RAM
Objective C resize UIImage
Objective C resize UIImage  i just want to resize the image on the touch detection. That means if a user double clicks on the UIImage it must resize the image
can anyone help me to implement strength of the password - Security
can anyone help me to implement strength of the password  hi.. i have to implement password strength detection algorithm. How can i use dictionary in linux system
VoIP Router
and a USB printer port and support for all current ADSL technologies... standard broadband ADSL connectivity using USB, Ethernet and Wireless and now... it direct into your PC via USB. If you?re using Windows XP/2000, Mac OS X or Linux
C Language - Java Beginners
. What is USB ? 9. What is Computer Network? What is the necessary of using
What is WiFi Finder?
the direction of the signal. Some models come with built in USB ports. This way you... configured. Further, the models automatically recharge once they connect with the USB.... Another important factor to check is the USB standards of the WiFi finder
VoIP Free Software
activity detection, and noise reduction, according to the company. Talking..., these are intended to get Mac users up and running quickly. They include a USB
Advertisements
 

 

 

DMCA.com