Hi I'm fairly novice at programming in java, and currently writing a Java application in Jbuilder5 that is and communicating to a database using JDBC, that's pretty simple and is workinf fine.
I would now like to extend my appliation so that some of the textfields can listen for input that will arrive at the comm port after an item's barcode is scanned with a barcode scanner.
I've looked the examples that come with the Java Comm API, and looked through the JAVA I/O book. However these examples seem rather complex. I have included a sample code of an app below that has just two text fields I just want one of them to listen for input. (If that text field is currently selected).
I would be greatful if someone would be kind enough to help me out with this problem, if it makes thngs easier the code that is nessarry can be added below so that the jTextField1 can listen for data coming into the serial port.
public class Frame1 extends JFrame { JPanel contentPane; XYLayout xYLayout1 = new XYLayout(); JTextField jTextField2 = new JTextField(); JTextField jTextField1 = new JTextField();
/**Construct the frame*/ public Frame1() { enableEvents(AWTEvent.WINDOW_EVENT_MASK); try { jbInit(); } catch(Exception e) { e.printStackTrace(); } } /**Component initialization*/ private void jbInit() throws Exception { //setIconImage(Toolkit.getDefaultToolkit().createImage(Frame1.class.getResour ce("[Your Icon]"))); contentPane = (JPanel) this.getContentPane(); contentPane.setLayout(xYLayout1); this.setSize(new Dimension(198, 132)); this.setTitle("Frame Title"); contentPane.add(jTextField1, new XYConstraints(45, 20, 100, 25)); contentPane.add(jTextField2, new XYConstraints(45, 60, 100, 25)); } /**Overridden so we can exit when window is closed*/ protected void processWindowEvent(WindowEvent e) { super.processWindowEvent(e); if (e.getID() == WindowEvent.WINDOW_CLOSING) { System.exit(0); } } }