Help with code that reads fro usb barcode scanner

pls I'm trying to read fro a USB metrologic scanner the code I'm using works but it reads the barcode in two parts
here is the code can anyone help I need it to read the barcode at once
import java.io.*;
import java.util.*;
import javax.comm.*;
public class SimpleRead implements Runnable, SerialPortEventListener
static CommPortIdentifier portId;
static Enumeration portList;
InputStream inputStream;
SerialPort serialPort;
Thread readThread;
public SimpleRead()
try {
serialPort = (SerialPort) portId.open("SimpleReadApp", 2000);
} catch (PortInUseException e) {}
try {
inputStream = serialPort.getInputStream();
} catch (IOException e) {}
try {
serialPort.addEventListener(this);
} catch (TooManyListenersException e) {}
serialPort.notifyOnDataAvailable(true);
try {
serialPort.setSerialPortParams(9600, SerialPort.DATABITS_8,
SerialPort.STOPBITS_1,
SerialPort.PARITY_NONE);
} catch (UnsupportedCommOperationException e) {}
readThread = new Thread(this);
readThread.start();
public static void main(String[] args)
boolean portFound = false;
String defaultPort = "COM5";
if (args.length > 0) {
defaultPort = args[0];
portList = CommPortIdentifier.getPortIdentifiers();
while (portList.hasMoreElements()) {
portId = (CommPortIdentifier) portList.nextElement();
if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL) {
if (portId.getName().equals(defaultPort)) {
System.out.println("Found port: "+defaultPort);
portFound = true;
SimpleRead reader = new SimpleRead();
if (!portFound) {
System.out.println("port " + defaultPort + " not found.");
* Method declaration
* @see
public void run() {
try {
Thread.sleep(20000);
} catch (InterruptedException e) {}
* Method declaration
* @param event
* @see
public void serialEvent(SerialPortEvent event) {
switch (event.getEventType()) {
case SerialPortEvent.BI:
case SerialPortEvent.OE:
case SerialPortEvent.FE:
case SerialPortEvent.PE:
case SerialPortEvent.CD:
case SerialPortEvent.CTS:
case SerialPortEvent.DSR:
case SerialPortEvent.RI:
case SerialPortEvent.OUTPUT_BUFFER_EMPTY:
break;
case SerialPortEvent.DATA_AVAILABLE:
byte[] readBuffer = new byte[30];
try {
while (inputStream.available() > 0) {
int numBytes = inputStream.read(readBuffer);
System.out.print(new String(readBuffer));
} catch (IOException e) {}
break;
}

pls I'm trying to read fro a USB metrologic scanner the code I'm using works but it reads the barcode in two parts
here is the code can anyone help I need it to read the barcode at once
import java.io.*;
import java.util.*;
import javax.comm.*;
public class SimpleRead implements Runnable, SerialPortEventListener
static CommPortIdentifier portId;
static Enumeration portList;
InputStream inputStream;
SerialPort serialPort;
Thread readThread;
public SimpleRead()
try {
serialPort = (SerialPort) portId.open("SimpleReadApp", 2000);
} catch (PortInUseException e) {}
try {
inputStream = serialPort.getInputStream();
} catch (IOException e) {}
try {
serialPort.addEventListener(this);
} catch (TooManyListenersException e) {}
serialPort.notifyOnDataAvailable(true);
try {
serialPort.setSerialPortParams(9600, SerialPort.DATABITS_8,
SerialPort.STOPBITS_1,
SerialPort.PARITY_NONE);
} catch (UnsupportedCommOperationException e) {}
readThread = new Thread(this);
readThread.start();
public static void main(String[] args)
boolean portFound = false;
String defaultPort = "COM5";
if (args.length > 0) {
defaultPort = args[0];
portList = CommPortIdentifier.getPortIdentifiers();
while (portList.hasMoreElements()) {
portId = (CommPortIdentifier) portList.nextElement();
if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL) {
if (portId.getName().equals(defaultPort)) {
System.out.println("Found port: "+defaultPort);
portFound = true;
SimpleRead reader = new SimpleRead();
if (!portFound) {
System.out.println("port " + defaultPort + " not found.");
* Method declaration
* @see
public void run() {
try {
Thread.sleep(20000);
} catch (InterruptedException e) {}
* Method declaration
* @param event
* @see
public void serialEvent(SerialPortEvent event) {
switch (event.getEventType()) {
case SerialPortEvent.BI:
case SerialPortEvent.OE:
case SerialPortEvent.FE:
case SerialPortEvent.PE:
case SerialPortEvent.CD:
case SerialPortEvent.CTS:
case SerialPortEvent.DSR:
case SerialPortEvent.RI:
case SerialPortEvent.OUTPUT_BUFFER_EMPTY:
break;
case SerialPortEvent.DATA_AVAILABLE:
byte[] readBuffer = new byte[30];
try {
while (inputStream.available() > 0) {
int numBytes = inputStream.read(readBuffer);
System.out.print(new String(readBuffer));
} catch (IOException e) {}
break;
}

Similar Messages

  • Combo box and Check box..help with code please?

    Here is my problem...i have a list of check boxes and according to which one is checked, i need combo boxes to populate different choices.
    as an easy example im only using 2 check boxes and two combo boxes.
    the check boxes are named Choice 1or2 with export values of 1 and 2
    the Combo Boxes are named List A and List B..
    both containing options that say you checked box 1 and you checked box 2
    any help would be greatly appreciated

    Implode wrote:
    "Help with code please."
    In the future, please use a meaningful subject. Given that you're posting here, it's kind of a given that you're looking for help with the code. The whole point of the subject is to give people a high level idea of what KIND of help with what KIND of code you need, so they can decide if they're interested and qualified to help.
    Exception in thread "main" java.lang.NumberFormatException: For input string: "fgg"
         at java.lang.NumberFormatException.forInputString(Unknown Source)
         at java.lang.Integer.parseInt(Unknown Source)
         at java.lang.Integer.parseInt(Unknown Source)
         at assignment1.Game.Start(Game.java:120)
         at assignment1.RunGame.main(RunGame.java:18)This error message is telling you exactly what's wrong. At line 120 of Game.java, in the Start method (which should start with lowercase "s" to follow conventions, by the way), you're calling Integer.parseInt, but "fgg" is not a valid int.

  • Help with opening Adobe Reader and downloading updates

    I can not open Adobe .pdf files any longer (this started yesterday, prior to that I could open adobe files).
    When I double click a .pdf file I get this notice on my screen: Windows cannot access the specified device path or file. You may not have the appropriate permission to access file.
    So I went to the Adobe download site to download a new copy of Adobe.  When I start the download I get this on the screen:  The instruction at "0x0e3a0068" referenced memory at "0x0e3a0068."  The memory could not be written.  Then two options are listed: click OK to terminate or cancel to debug.  So I click on cancel and I get this on my screen: Internet Explorer has closed this webpage to help protect your computer.   A malfunctioning or malicious addon has caused I.E. to close this webpage.
    I don't have AVG running, I do have avast but I've disabled it.  I ran Registry Mechanic and an I.E. erasure program but nothing helps.
    I have gone into I.E. and reduced the security level to its lowest state but no joy.
    So, any ideas or suggestions on what's the problem and how to overcome it would be appreciated.  Thanks, in advance, for your reply.  Jim R.

    Hi Mike..tried that as well but no joy.  A friend of mine was looking at it all and noticed that it was an I.E. thing as far as not letting me redownload the reader so I went to Mozilla Firefox and I could download a new version but....whenever I attempt to open a .pdf file I get that message, "Windows can not open the specified device, path or file. You man not have the appropriate permissions to access the item." 
    Damn...this is irritating as I need to get to some of thos files as I need them for a Journal I'm working on as editor-in-chief. 
    It all worked just fine last Saturday but starting Monday when I was on my flight out to D.C.  no joy. 
    Sigh...Jim R.
    Jim R.
    Date: Tue, 1 Dec 2009 14:50:27 -0700
    From: [email protected]
    To: [email protected]
    Subject: Help with opening Adobe Reader and downloading updates
    Under the help menu, there is an option to repair the installation of reader. Did you try that?
    >

  • I need help with adobe iv reader.

    iam trying to pin a website using ie.it says the reader cannot read the website,i am not computer saavy so i donot know how to fix this issue, pls help,tyvm.

    i am trying to pin a website in internet explorer to my task bar,i get a 
    message that adobe v1 could not decode the website, i am not computer saavy
    so i  don't know what that means,plus this is a new computer 4 me.plus it
    worked fine  a few days ago. tyvm 4 ur help.
    regards,
    ray nist
    In a message dated 6/11/2013 9:27:11 P.M. Eastern Daylight Time, 
    [email protected] writes:
    Re: i  need help with adobe iv reader.
    created by Pat Willener (http://forums.adobe.com/people/pwillener)  in 
    Adobe Reader - View the full  discussion
    (http://forums.adobe.com/message/5400013#5400013)

  • Can you help with Problems that one of our users i having with regiistration of Premiere Pro?

    Can you help with Problems that one of our users i having with registration of Premiere Pro?

    Link for Download & Install & Setup & Activation problems may help
    -Online Chat http://www.adobe.com/support/download-install/supportinfo/
    More information needed for someone to help... please click below and provide the requested information
    -Premiere Pro Video Editing Information FAQ http://forums.adobe.com/message/4200840

  • How would I create an USB Barcode Scanner Listener using Adobe AIR?

    I want to create a USB barcode scanner listener that would read in the scanned barcode, and place the barcode in a field in my AIR App even if the program wasn't focused on that particular field in the App.  If the client was using the application at the time for something else the scan would be buffered in AIR till requested or the AIR App has been idle for x period of time where upon the field would be brought into focus.
    How would I go about this (I'm developing on windows)  Was hoping for a USB solution within AIR but not fussy at all if I have to go outside AIR to solve this problem.  Java, Flex, ActionScript, Flash, C, C++, C#, VB (currently I've developed the rest of the App using Adobe AIR and JavaScript)
    I thought after some research that I could make a Java App (if all else fails) that listens and buffers the input and passes it along using a socket but JUSB doesn't work on Windows properly.
    I'm not stuck on any one particular implementation or idea just want to get development underway so...  Any ideas? or suggestions would be awesome.  I've googled a lot but haven't found any examples or solid suggestions, so any URL pointing to that information would be great too, if you know of a good one, then I'd be able to read up on any suggestion.
    Thanks,
    Marty

    Thanks Joe,
    Just for anyone else.  I bought a Metologic Scanner - VoyagerCG.  I was trying to get it to work using Java USB for a bit with no luck.  But if you get this scanner or one like it, it can be configured as a Virtual COM Port.  Which is very very easy in Java to set up as a listener and use sockets to transfer the data and listen within AIR.
    This PDF has links to drivers and instructions if this is useful to anyone.
    http://taltechnologies.com/products/Eclipse-Voyager%20Interface%20Options.pdf
    All the best,
    Marty

  • How to get data from usb barcode scanner and display on GUI

    pls anyone with ideas on how to communicate with usb barcode scanner

    http://www.google.com/search?hl=en&q=java+usb+barcode+scanner&btnG=Google+Search

  • Newbie needing help with code numbers and if-else

    I'm 100% new to any kind of programming and in my 4th week of an Intro to Java class. It's also an on-line class so my helpful resources are quite limited. I have spent close to 10 hours on my class project working out P-code and the java code itself, but I'm having some difficulty because the project seems to be much more advanced that the examples in the book that appear to only be partly directly related to this assignment. I have finally come to a point where I am unable to fix the mistakes that still show up. I'm not trying to get anyone to do my assignment for me, I'm only trying to get some help on what I'm missing. I want to learn, not cheat.
    Okay, I have an assignment that, in a nutshell, is a cash register. JOptionPane prompts the user to enter a product code that represents a product with a specific price. Another box asks for the quanity then displays the cost, tax and then the total amount plus tax, formatted in dollars and cents. It then repeats until a sentinel of "999" is entered, and then another box displays the total items sold for the day, amount of merchandise sold, tax charged, and the total amount acquired for the day. If a non-valid code is entered, I should prompt the user to try again.
    I have this down to 6 errors, with one of the errors being the same error 5 times. Here are the errors:
    C:\PROGRA~1\XINOXS~1\JCREAT~1\MyProjects\Sales.java:50: 'else' without 'if'
    else //if invalid code entered, output message
    ^
    C:\PROGRA~1\XINOXS~1\JCREAT~1\MyProjects\Sales.java:39: unexpected type
    required: variable
    found : value
    100 = 2.98;
    ^
    C:\PROGRA~1\XINOXS~1\JCREAT~1\MyProjects\Sales.java:41: unexpected type
    required: variable
    found : value
    200 = 4.50;
    ^
    C:\PROGRA~1\XINOXS~1\JCREAT~1\MyProjects\Sales.java:43: unexpected type
    required: variable
    found : value
    300 = 6.79;
    ^
    C:\PROGRA~1\XINOXS~1\JCREAT~1\MyProjects\Sales.java:45: unexpected type
    required: variable
    found : value
    400 = 5.29;
    ^
    C:\PROGRA~1\XINOXS~1\JCREAT~1\MyProjects\Sales.java:47: unexpected type
    required: variable
    found : value
    500 = 7.20;
    ^
    And finally, here is my code. Please be gentle with the criticism. I've really put a lot into it and would appreciate any help. Thanks in advance.
    import java.text.NumberFormat; // class for numeric formating from page 178
    import javax.swing.JOptionPane; // class for JOptionOPane
    public class Sales {
    //main method begins execution ofJava Application
    public static void main( String args[] )
    double quantity; // total of items purchased
    double tax; // total of tax
    double value; // total cost of all items before tax
    double total; // total of items including tax
    double totValue; // daily value counter
    double totTax; // daily tax counter
    double totTotal; // daily total amount collected (+tax) counter
    double item; //
    String input; // user-entered value
    String output; // output string
    String itemString; // item code entered by user
    String quantityString; // quantity entered by user
    // initialization phase
    quantity = 0; // initialize counter for items purchased
    // get first code from user
    itemString = JOptionPane.showInputDialog(
    "Enter item code:" );
    // convert itemString to double
    item = Double.parseDouble ( itemString );
    // loop until sentinel value read from user
    while ( item != 999 ) {
    // converting code to amount using if statements
    if ( item == 100 )
    100 = 2.98;
    if ( item == 200 )
    200 = 4.50;
    if ( item == 300 )
    300 = 6.79;
    if ( item == 400 )
    400 = 5.29;
    if ( item == 500 )
    500 = 7.20;
    else //if invalid code entered, output message
    JOptionPane.showMessageDialog( null, "Invalid code entered, please try again!",
    "Item Code", JOptionPane.INFORMATION_MESSAGE );
    } // end if
    } // end while
    // get quantity of item user
    itemString = JOptionPane.showInputDialog(
    "Enter quantity:" );
    // convert quantityString to int
    quantity = Double.parseDouble ( quantityString );
    // add quantity to quantity
    quantity = quantity + quantity;
    // calculation time! value
    value = quantity * item;
    // calc tax
    tax = value * .07;
    // calc total
    total = tax + value;
    //add totals to counter
    totValue = totValue + value;
    totTax = totTax + tax;
    totTotal = totTotal + total;
    // display the results of purchase
    JOptionPane.showMessageDialog( null, "Amount: " + value +
    "\nTax: " + tax + "\nTotal: " + total, "Sale", JOptionPane.INFORMATION_MESSAGE );
    // get next code from user
    itemString = JOptionPane.showInputDialog(
    "Enter item code:" );
    // If sentinel value reached
    if ( item == 999 ) {
    // display the daily totals
    JOptionPane.showMessageDialog( null, "Total amount of items sold today: " + quantity +
    "\nValue of ites sold today: " + totValue + "\nTotal tax collected today: " + totTax +
    "\nTotal Amount collected today: " + totTotal, "Totals", JOptionPane.INFORMATION_MESSAGE );
    System.exit( 0 ); // terminate application
    } // end sentinel
    } // end message
    } // end class Sales

    Here you go. I haven't tested this but it does compile. I've put in a 'few helpful hints'.
    import java.text.NumberFormat; // class for numeric formating from page 178
    import javax.swing.JOptionPane; // class for JOptionOPane
    public class TestTextFind {
    //main method begins execution ofJava Application
    public static void main( String args[] )
         double quantity; // total of items purchased
         double tax; // total of tax
         double value; // total cost of all items before tax
         double total; // total of items including tax
    //     double totValue; // daily value counter
    //     double totTax; // daily tax counter
    //     double totTotal; // daily total amount collected (+tax) counter
    // Always initialise your numbers unless you have a good reason not too
         double totValue = 0; // daily value counter
         double totTax = 0; // daily tax counter
         double totTotal = 0; // daily total amount collected (+tax) counter
         double itemCode;
         double item = 0;
         String itemCodeString; // item code entered by user
         String quantityString; // quantity entered by user
         // initialization phase
         quantity = 0; // initialize counter for items purchased
         // get first code from user
         itemCodeString = JOptionPane.showInputDialog("Enter item code:" );
         // convert itemString to double
         itemCode = Double.parseDouble ( itemCodeString );
         // loop until sentinel value read from user
         while ( itemCode != 999 ) {
    * 1. variable item mightnot have been initialised
    * You had item and itemCode the wrong way round.
    * You are supposed to be checking itemCode but setting the value
    * for item
              // converting code to amount using if statements
              if ( item == 100 )
              {itemCode = 2.98;}
              else if ( item == 200 )
              {itemCode = 4.50;}
              else if ( item == 300 )
              {itemCode = 6.79;}
              else if ( item == 400 )
              {itemCode = 5.29;}
              else if ( item == 500 )
              {itemCode = 7.20;}
              else {//if invalid code entered, output message
                   JOptionPane.showMessageDialog( null, "Invalid code entered, please try again!",
                   "Item Code", JOptionPane.INFORMATION_MESSAGE );
              } // end if
         } // end while
         // get quantity of item user
         itemCodeString = JOptionPane.showInputDialog("Enter quantity:" );
    * 2.
    * You have declared quantityString here but you never give it a value.
    * I think this should be itemCodeString shouldnt it???
    * Or should you change itemCodeString above to quantityString?
         // convert quantityString to int
    //     quantity = Double.parseDouble ( quantityString );  // old code
         quantity = Double.parseDouble ( itemCodeString );
         // add quantity to quantity
         quantity = quantity + quantity;
         // calculation time! value
         value = quantity * itemCode;
         // calc tax
         tax = value * .07;
         // calc total
         total = tax + value;
         //add totals to counter
    * 3. 4. and 5.
    * With the following you have not assigned the 'total' variables a value
    * so in effect you are saying eg. "total = null + 10". Thats why an error is
    * raised.  If you look at your declaration i have assigned them an initial
    * value of 0.
         totValue = totValue + value;
         totTax = totTax + tax;
         totTotal = totTotal + total;
         // display the results of purchase
         JOptionPane.showMessageDialog( null, "Amount: " + value +
         "\nTax: " + tax + "\nTotal: " + total, "Sale", JOptionPane.INFORMATION_MESSAGE );
         // get next code from user
         itemCodeString = JOptionPane.showInputDialog("Enter item code:" );
         // If sentinel value reached
         if ( itemCode == 999 ) {
              // display the daily totals
              JOptionPane.showMessageDialog( null, "Total amount of items sold today: " + quantity +
              "\nValue of ites sold today: " + totValue + "\nTotal tax collected today: " + totTax +
              "\nTotal Amount collected today: " + totTotal, "Totals",           JOptionPane.INFORMATION_MESSAGE );
              System.exit( 0 ); // terminate application
         } // end sentinel
    } // end message
    } // end class SalesRob.

  • Need help with code

    Hi,
    I'm new to java, i'm creating java analog clock application. but i'm getting so many errors. i still try to figur out what are those. can someone please help me with this code. Thank you
    here is my code
    import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    import java.text.*;
    import javax.swing.*;
    //The main class
    public class AnalogClock extends JFrame
    // Initialize all the variables
    SimpleDateFormat f_s = new SimpleDateFormat ("ss", Locale.getDefault());
    SimpleDateFormat f_m = new SimpleDateFormat ("mm", Locale.getDefault());
    SimpleDateFormat f_h = new SimpleDateFormat ("hh", Locale.getDefault());
    SimpleDateFormat standard = new SimpleDateFormat ("HH:mm:ss", Locale.getDefault());
    int xs, ys, xm, ym, xh, yh, s, xcenter, ycenter, m, h, x, y, mouse_x, mouse_y;
    String temp;
    Dimension d;
    Date now;
    Thread thr = null;
    Image im;
    Boolean M = false;
    Graphics gIm;
    Dimension dIm;
    int sx, sy, sx2, sy2;
    Color digital = Color.blue, hour = Color.blue, minute = Color.yellow,
    second = Color.green, circle = Color.red, hours = Color.blue, mute_logo = Color.green;
    // paint(): the main part of the program
    public void paint(Graphics g)
    d = getSize();
    xcenter = d.width/2;
    ycenter = d.height/2;
    x = d.width;
    y = d.height;
    if(im == null)
    im = createImage(x, y);
    gIm = im.getGraphics();
    dIm = new Dimension(x, y);
    // Get the current timestamp
    now = new Date();
    // Get the seconds
    temp = f_s.format(now);
    s = Integer.parseInt(temp);
    temp = f_m.format(now);
    m = Integer.parseInt(temp);
    temp = f_h.format(now);
    h = Integer.parseInt(temp);
    // Calculate all the positions of the hands
    xs = (int) (Math.cos(s * Math.PI / 30 - Math.PI / 2) * 45 + xcenter);
    ys = (int) (Math.sin(s * Math.PI / 30 - Math.PI / 2) * 45 + ycenter);
    xm = (int) (Math.cos(m * Math.PI / 30 - Math.PI / 2) * 40 + xcenter);
    ym = (int) (Math.sin(m * Math.PI / 30 - Math.PI / 2) * 40 + ycenter);
    xh = (int) (Math.cos((h * 30 + m / 2) * Math.PI / 180 - Math.PI / 2) * 30 + xcenter);
    yh = (int) (Math.sin((h * 30 + m / 2) * Math.PI / 180 - Math.PI / 2) * 30 + ycenter);
    // Refresh the image
    gIm.setColor(getBackground());
    gIm.fillRect(0, 0, dIm.width, dIm.height);
    // Draw the circle of the clock
    gIm.setColor(circle);
    gIm.drawOval(0, 0, d.width-1, d.height-1);
    gIm.setColor(hours);
    // Draw the stripes of the hours
    for(int i = 0;i<12;i++)
    sx = (int) (Math.cos((i * 30) * Math.PI / 180 - Math.PI / 2) * 47 + xcenter);
    sy = (int) (Math.sin((i * 30) * Math.PI / 180 - Math.PI / 2) * 47 + xcenter);
    sx2 = (int) (Math.cos((i * 30) * Math.PI / 180 - Math.PI / 2) * 49 + xcenter);
    sy2 = (int) (Math.sin((i * 30) * Math.PI / 180 - Math.PI / 2) * 49 + xcenter);
    gIm.drawLine(sx, sy, sx2, sy2);
    // Draw the time on the top of the clock
    gIm.setColor(digital);
    gIm.drawString(standard.format(now), 25, 30);
    // Draw the mute logo
    Mute m = new Mute(M, gIm);
    // Draw the hands
    // Seconds
    gIm.setColor(second);
    gIm.drawLine(xcenter, ycenter, xs, ys);
    // Minutes
    gIm.setColor(minute);
    gIm.drawLine(xcenter, ycenter-1, xm, ym);
    gIm.drawLine(xcenter-1, ycenter, xm, ym);
    // Hour
    gIm.setColor(hour);
    gIm.drawLine(xcenter, ycenter-1, xh, yh);
    gIm.drawLine(xcenter-1, ycenter, xh, yh);
    // Paint the generated image on the screen
    if(im != null)
    g.drawImage(im, 0, 0, null);
    if(M == false)
    play(getCodeBase(), "Sound/Click.wav");
    public void update(Graphics g)
    paint(g);
    class Mute
    Mute(Boolean mute, Graphics g)
    g.setColor(mute_logo);
    Polygon p = new Polygon();
    p.addPoint(1, 7);
    p.addPoint(6, 2);
    p.addPoint(6, 12);
    g.fillPolygon(p);
    g.drawLine(7, 5, 7, 9);
    g.drawLine(9, 4, 9, 10);
    g.drawLine(11, 3, 11, 11);
    if(mute == true)
    g.drawLine(13, 3, 1, 11);
    /* // All the mouse events
    public void mousePressed(MouseEvent evt)
    mouse_x = evt.getX();
    mouse_y = evt.getY();
    if(mouse_x <= 11 && mouse_x >= 1 && mouse_y <= 12 && mouse_y >= 2)
    if(M == true)
    M = false;
    } else {
    M = true;
    repaint();
    public void mouseReleased(MouseEvent evt){}
    public void mouseEntered(MouseEvent evt){}
    public void mouseExited(MouseEvent evt){}
    public void mouseClicked(MouseEvent evt){}
    }

    There is a gross misconception among the new and learning programmers that a lot of code is good and once you put that last close scope in place that things are wonderful because you have all the code down...
    Please repeat this: NO, short debugged runs and incremental builds are better.
    As a matter of fact, that is so important, go back and say it again and again until it really truly sinks in.
    This concept is really pounded into your soul when you program in assembler--probably an ailment of the new generation of programmers, they never have had to do assembler or machine coding--but any time you get more than about 20 lines of code that hasn't been checked for bugs, you should start thinking... "Oh, do I really have the skills and patience to go back and debug (yes, actually use the debugger to step through it all.) that big of mess?" The biggest project is just like eating an elephant, you do it one small bite at a time over as long a time as it takes--you don't cook half the elephant and sit down and expect to eat it in one meal; neither do you sit down and decide to code a whole program and then debug it. You just don't have the skill to do it.
    When you modify someone else's code, the same is true--small changes and debug as you change. Making all the changes you want, then debugging just runs into a huge error file of related problems that are basically indiscernible from each other because many of them are probably related.
    Most of the request for "Help, I cannot get this to run." Also contain the words: "I just finished coding..." That statement in and of itself is one of the great flawed concepts that anyone can have--coding is complete when you have an acceptable release candidate, and then only until you decide or are asked to make further changes.
    Work in small blocks of code and incrementally build a project--your frustration levels will be much less. And as you gain skill, increase the size of the code blocks (I had a friend in college that never had 5 consecutive lines of code compile--ever! He works for MS now.) and get to know your debugger. Your debugger is your friend, if you've not been introduced to your debugger, then get acquainted soon! Like maybe before you even try to cut another piece of code.
    On the other side of things... cheer up, we've all been there and learned the lessons... some lessons just come harder than others... make your life less frustrating, it's a lot more fun and enjoyable.

  • Help with the Korg nano key usb keyboard!

    I recently bought the Kord Nano Key usb keyboard for the purpose of triggering drum sounds and sounds from the library. Will this keyboard do this?
    I have very limited time with which to read manuals and experiment. Could anyone just tell me how to get going with this keyboard. I have installed the driver and can see that some sort of signal is getting into logic.
    If it is possible, can you get me up and running quickly?
    Thanks

    I'm assuming the Akai came with a manual, I know Logic did, you're going to have to do a little of the work yourself, your question is so vauge that no one knows what you're tried, or if you've even tried anything at all! This is professional software... you HAVE to read manuals...  have you used Garageband?  Have you plugged the Akai in, have you looked in Logic's online help systen to see how to load a software instrument?
    Or job is not to hold your hand, this is a user forum, there are people here that will help but you need to to some work on your own. 

  • Help with code errors

    Can somebody help me get rid of the following compile errors:
    coreservlets/OrderPage.java:61: setNumOrdereed(int, int) in coreservlets.ShoppingCart
    cannont be applied to (java.lang.String,int)
    cart.setNumOrdered(recordingid, numItems);
    .\coreservlets\shoppingCart.java:44 cannot resolve symbol
    symbol : variable recordingid
    location: class coreservlets.ShoppingCart
    if (order.getrecordingid() == (recordingid)) {
    .\coreservlets\ShoppingCart.java:49: cannot resolve symbol
    symbol : variable recordingid
    location: class coreservlets.ShoppingCart
    itemOrder new order = new ItemOrder(Catalog.getItem(recordingid));I know that not very helpful with out the code but the code is very big so if anyone wants me to post extracts from the code please tell me.

    Thank you i put that code in but now get the following:
    coreservlets/OrderPage.java:40:  incompatible types
    found : java.lang.strgin
    required: int int recordingid = request.getParameter("recordingid")!=null?request.getParameter("recordingid"):1;
    ^/code]
    coreservlets/OrderPage.java:48: addItem(java.lang.String) in coreservlets.ShoppingCart cannot be applied to (int)
    cart.additem(recordingid);
    .\coreservlets\AhoppingCart.java:44: cannot resolve symbol
    symbol: variable recordingid
    location: class coreservlets.ShoppingCart
    if (order.getrecordingid() == (recordingid)) {
    .\coreservlets\AhoppingCart.java:49: cannot resolve symbol
    symbol: variable recordingid
    location: class coreservlets.ShoppingCart
    ItemOrder newOrder = new ItemOrder(Catalog.getItem(recordingid));
    4 errors.
    Also could you explain what the line you added to the code means:
    !=null?request.getParameter("recordingid"):1;
    !=null?request.getParameter("numItems"):"1";and how come you got rid of if (recordingid != null) {Thanks for any help with these errors
    OK I HAVE GOT RID OF ALL THE ERRORS APART FROM THE TOP ONE:
    code]coreservlets/OrderPage.java:40: incompatible types
    found : java.lang.strgin
    required: int
    int recordingid = request.getParameter("recordingid")!=null?request.getParameter("recordingid"):1;
                                            /code]
    Message was edited by:
            ajrobson                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Help with code...emergency

    Hi!
    We are making a game in school, it's a boat crossing the
    ocean.
    We have a problem that the boat doesn't stop when it gets to
    the end of the screen, it just continues moving away.
    So, If anyone can help us with the code that makes the boat
    stop inside the border... PLEASE
    This is the size of the border that we want the boat to stay
    inside:
    W: 4381.4 X: -2190.7
    H: 2352.0 Y: -1176.0
    This is the code we have now:
    on (keyPress "<Left>")
    this._x = this._x + this._parent.boatSpeed;
    on (keyPress "<Right>")
    this._x = this._x - this._parent.boatSpeed;
    on (keyPress "<Up>") {
    this._y = this._y + this._parent.boatSpeed;
    on (keyPress "<Down>") {
    this._y = this._y - this._parent.boatSpeed;
    Thank you in advance!!

    Hi!
    Thanks for your answer.... I've tried this code...but I can't
    get it to work... can you see what is wrong??
    var top:Number=0;
    var left:Number=0;
    var right:Number=500;
    var bottom:Number=500;
    on (keyPress "<Left>")
    if(this._x<left)
    this._x=left;
    }else
    this._x = this._x + this._parent.boatSpeed;
    on (keyPress "<Right>")
    if(this._x>right)
    this._x=right;
    }else
    this._x = this._x - this._parent.boatSpeed;
    on (keyPress "<Up>") {
    if(this._y<top)
    this._y=top;
    }else
    this._y = this._y - this._parent.boatSpeed;
    on (keyPress "<Down>") {
    if(this._y>bottom)
    this._y=bottom;
    }else
    this._y = this._y + this._parent.boatSpeed;

  • Need help with a vowel reading program :(

    Hi, im trying to create a program that does the following:
    "a program that reads a list of vowels (a, e, i, o, u) and stores them in an array. The maximum number of vowels to be read should be obtained from the user before beginning to read the vowels, however, the user may cancel the reading of vowels at any time by entering '#'. The algorithm should then count and display the number of times each vowel appears in the array. Finally the algorithm should also output the index in the array where the each vowel first appeared or a suitable message if a particular vowel is not in the array at all."
    It says to store the input in an array so I've probably started all wrong :( but any help at all would be greatly accepted.
    Im trying to go through it doing one method at a time but im having trouble with the reading input method
    the 1 error i get is marked with ***.
    Is it that I need to do a for loop first to find the length of the string?
    import java.io.*;
    import javax.swing.JOptionPane;
    class prac7
          public static String readIn()
                    BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
                    String max = null;
                    String sentence = null;
               try
                    System.out.println("\nEnter the amount of characters to read in: ");
                    max = input.readLine();
                    int total = Integer.parseInt(max);
               catch(Exception e) {System.out.println("invalid");}
               do
                    sentence = JOptionPane.showInputDialog("Enter a sentence, ("+max+" characters maximum): ");
                    int ind = sentence.length();
               }while(ind <= max);     //*** the arrow is under 'ind' and says "cannot resolve symbol"
               return sentence;
          public static void main(String[] args)
               String data = "";
               data = readIn();
          }Thanks.

    thanks for your reply Paul ^^ , but im still having trouble with that part of the program :(
    Its saying "operator <= cannot be applied to int,java.lang.String" (Ive marked in asterisks)
    Also i've add the rest of the program code, but in the calcPrint method i am having trouble understanding some of it (some of the code was used from another program) and it would be great if someone could show me a more simplier way of coding the same thing? even if its more typing, i just want to understand it better.
    (i've marked the area im having trouble understanding with asterisks)
    Once again any help would be fantastic :)
    here is the code
    import java.io.*;
    import javax.swing.JOptionPane;
    class prac7
          public static String readIn()
               BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
               String max = null;
               String sentence = null;
               try
                    System.out.println("\nEnter the amount of characters to read in: ");
                    max = input.readLine();
                    int total = Integer.parseInt(max);
               catch(Exception e) {System.out.println("invalid");}
               do
                    sentence = JOptionPane.showInputDialog("Enter a sentence, ("+max+" characters maximum): ");
                    sentence.toLowerCase();
               }while(sentence.length() <= max);     /******operator error******/
               return sentence;
          public static void calcPrint(String data)
               String vowels[] = {"a","e","i","o","u","Other letters"};
               String screen = "";
               int alpha[] = new int [6];
               for (int i = 0; i < data.length(); i++)
               /********from here*********/
                    try
                         alpha["aeiou".indexOf(data.charAt(i))]++;
                         if(data.charAt(i) != ' ') alpha[5]++;
                    catch(Exception e){}
               for (int i = 0; i < alpha.length; i++)
               screen += vowels[i]+" Amount = "+alpha[i]+"\n";
              /**********to here**********/
               JOptionPane.showMessageDialog(null,screen);
          public static void main(String[] args)
               String data = "";
               data = readIn();
               calcPrint(data);
    }

  • Help with method for reading coeffecients.

    I am fairly new to Java programming and I was asked by my instructor to wright a program that calculates the quadratic formula via a loop. So far i have the following code:
       // Constructor obtains the number of equations as a parameter
       Quadratic2(int limit) throws IOException {  // Constructor
          // All computations are performed in a loop
          for (int count=0; count<limit; count++) { // setting count to 0, if count is less than limit , then count is incremented by 1
             // Reading the coefficients
             System.out.print("Please enter coefficient a: ");
             double coeffA = Double.parseDouble(inp.readLine());
             System.out.print("Please enter coefficient b: ");
             double coeffB = Double.parseDouble(inp.readLine());
             System.out.print("Please enter coefficient c: ");
             double coeffC = Double.parseDouble(inp.readLine());
             System.out.println();
             double Disc = discr(coeffA, coeffB, coeffC);  // Compute discriminant
             if (Disc >= 0.0) {  // Solution exists
                // Solving the equation
                double root1 = roots(coeffA, coeffB, coeffC, true);
                double root2 = roots(coeffA, coeffB, coeffC, false);
                // Outputting results
                System.out.println("Quadratic equation with the following coefficients:");
                System.out.println("A: " + coeffA + "; B: " + coeffB + "; C: " + coeffC);
                System.out.println("has the following solution:");
                System.out.println("Root1: " + root1 + "; Root2: " + root2);
             else {  // Solution does not exist
                System.out.println("Quadratic equation with the following coefficients:");
                System.out.println("A: " + coeffA + "; B: " + coeffB + "; C: " + coeffC);
                System.out.println("has no solution in the real domain.");
             System.out.println("");
       // A method to compute the discriminant
       double discr(double a, double b, double c) {
          return b*b - 4*a*c;
       // A method to calculate roots
       double roots(double a, double b, double c, boolean which) {
          double Disc = discr(a, b, c);
          if (which) {
             return (-b - Math.sqrt(Disc))/(2*a);
          else {
             return (-b + Math.sqrt(Disc))/(2*a);
       public static void main(String args[]) throws IOException { //Must throw an IO execption
          int noEqs = 1;  // Number of equations
          noEqs = Integer.parseInt(args[0]);  // Passed from command line
          Quadratic2 obj = new Quadratic2(noEqs);
    }I was told to read the coefficients with a method named readCoeffs() but evey time I try to do that I get several errors and as mentioned previously I am new to Java and therefore not able to interpret these errors. As you can see in the above code i read the coeffecients as they are entered but not via a method. I tryed using using the following but to no avail:
      double coeffA = readCoeffs(in);
          double coeffB = readCoeffs(in);
          double coeffC = readCoeffs(in);I was wondering if any of you more experienced programmers are able to show me how or help me write a method to read the coefficients? Any help or advice would be greatly appreciated!

    Sorry I should have been more specific in my question and provided more detail. Anyways i have revised my code to the following:
    //Java Program that Calculates the Quadratic Formula using a loop written by Kris Andrews
    // 10/08/07
    // Intro to Programming/COP 2006
    import java.io.*;//import java library
    class Quadratic2 { //Naming Class
       Quadratic2(int limit) throws IOException {  // Constructor that takes variable as parameter and computes as many times as the value entered
          // All computations are performed in a loop
          for (int i=0; i<limit; i++) { // setting i to 0, if i is less than limit , then i is incremented by 1
       // Declarations necessary to use kbd input //Declaring variable locally
       InputStreamReader inStream = new InputStreamReader(System.in);
       BufferedReader inp = new BufferedReader(inStream);
    // Method to read coefficients
       double readCoeffs() throws IOException {
             System.out.print("Please enter coefficient a: ");
             A = Double.parseDouble(inp.readLine());
             System.out.print("Please enter coefficient b: ");
             B = Double.parseDouble(inp.readLine());
             System.out.print("Please enter coefficient c: ");
             C = Double.parseDouble(inp.readLine());
             System.out.println("");
             return true;
       double Disc = discr(A, B, C);  // Compute discriminant
             if (Disc >= 0.0) {  // Solution exists
                // Solving the equation
                double root1 = roots(A, B, C, true);
                double root2 = roots(A, B, C, false);
                // Outputting results
                System.out.println("Quadratic equation with the following coefficients:");
                System.out.println("A: " + A + "; B: " + B + "; C: " + C);
                System.out.println("has the following solution:");
                System.out.println("Root1: " + root1 + "; Root2: " + root2);
             else {  // Solution does not exist
                System.out.println("Quadratic equation with the following coefficients:");
                System.out.println("A: " + A + "; B: " + B + "; C: " + C);
                System.out.println("has no solution in the real domain.");
             System.out.println("");
       // A method to compute the discriminant
       double discr(double a, double b, double c) {
          return b*b - 4*a*c;
       // A method to calculate roots
       double roots(double a, double b, double c, boolean which) {
          double Disc = discr(a, b, c);
          if (which) {
             return (-b - Math.sqrt(Disc))/(2*a);
          else {
             return (-b + Math.sqrt(Disc))/(2*a);
       public static void main(String args[]) throws IOException { //Must throw an IO execption
          int Equations = 1;  // Number of equations
          Equations = Integer.parseInt(args[0]);  // Passed from command line
          Quadratic2 obj = new Quadratic2(Equations);
    }But I get the following error:
    Quadratic2.java:23: ';' expected
    double readCoeffs() throws IOException {
    ^
    Quadratic2.java:23: not a statement
    double readCoeffs() throws IOException {
    ^
    Quadratic2.java:23: ';' expected
    double readCoeffs() throws IOException {
    ^
    I did not receive this error prior to trying to read the coefficients via a method and what do i need to to correct these errors? Again any help would be appreciated!

  • Error Code 88709 Reading NI USB-6225 OEM

    We have an issue that exists on one of two nearly identical systems that use NI USB-6225 OEM cards.  We are reading 75 channels at 1 kHz once per second.  On one of two systems the Error Code -88079 occurs intermittantly and when this happens the DAQ measurements stop though the code does not freeze.  We do not write to the 6225 card, the only thing we are doing is reading the AI channels.
    Our LabVIEW version is 2013 SP1 f2 and NI-DAQmx is version 14.1.  NI MAX is v14.0.0f0.
    The first system runs on a Windows 7 desktop workstation and has serial mass flow controller software with timers to change flow and concentrations based on a control file as well as a MODBUS TCP NDIR interface.  This system is complex but works perfectly.
    The second system runs on a Windows 8 laptop.  The mass flow software, timers, and NDIR interface were removed from the code of the first system to simplify the software for the second system.
    It is only the second system that produces the Error Code -88079.  This can happen once a month or several times a day.
    I've removed all the 'bloatware' from the Windows 8 laptop and ensured that nothing is set to hybernate or sleep and also turned off the Windows and other automatic updates because these systems must run 24/7 for a year.
    So, what is the best resolution for the Error Code -88079 problem with the second system?
    The DAQ card was calibrated and tested ISO-17025 through NI by an independant agency so it is not likely to be faulty but we could replace it with another (not ISO-17025) card we have on hand for diagnosis
    The USB cable is a possibility.  We could obtain a high quality USB cable and make sure the ends fit tightly.  Disconnecting the USB cable when the code is running produces Error Code -88079...
    Any other suggestions?
    Warm Regards,
    Lloyd

    Hi Saturn233207,
    Could you give more detail about the error that you are getting? What are the steps to reproduce the error? Is there any descriptive text at all in the error dialog box - maybe post a screenshot of the error?
    Also, as you mentioned I believe it would be a good idea to ensure that you are using a quality USB cable.

Maybe you are looking for

  • Creation of Organisation management infottype

    Hi Experts, Iam an abap-hr. I am creating OM infotype. First i created a structure for that infotype. I went to  TCode po10 n create Object n Relationship. After that i want to see my created infotype means Iam not able to see. Can anyone give me the

  • Acrobat X freezes on OCR during "recognizing text" step

    Acrobat X standard freezes every time I try to OCR a document - it starts through the process but when it gets to the "recognizing text" stage it just freezes - wondows says program not responding.

  • My screen shut off but my iPhone is still on. What can I do?

    My screen shut off but my iPhone is still on. What can I do?????????

  • USB interface of WRT160NL is slow?

    I connected a WesternDigital 1TB USB 2.0 hard drive to my WRT160NL's USB port; and connected my PC to the WRT160NL via Ethernet cable. I can detect and configure the hard drive without any problem. But the read/write speed to the USB disk is very slo

  • Problem with HTTP Scenario....

    Hello , While working with the (http >BPM> RFC & FILE ) scenario , I am getting following error... <b> And while using the http Client I posted the test xml ...But I am unable to see it in the SXI_MONITOR...</b> And using RWB --> Componet Monitoring