The Artima Developer Community
Sponsored Link

Java Answers Forum
Help with Java comm API

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Mandz

Posts: 1
Nickname: mandz
Registered: Mar, 2002

Help with Java comm API Posted: Mar 2, 2002 3:06 PM
Reply to this message Reply
Advertisement
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.

Regards
Mandz


Here is the sample app:

//start of code

package testcomm;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import com.borland.jbcl.layout.*;
import javax.comm.*;

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);
}
}
}

//end of code

Topic: Applet Reading file froom Client m/c and coiping to server machine Previous Topic   Next Topic Topic: OnLoad Event?????

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use