PC SOFT

FOROS PROFESIONALES
WINDEVWEBDEV y WINDEV Mobile

Inicio → WINDEV 2024 → External Java Classes
External Java Classes
Iniciado por anthony, 14,may. 2008 14:18 - 3 respuestas
Publicado el 14,mayo 2008 - 14:18
Hi all, I wish to use an external Java *.class or *.java in a windev application. Firstly I know nothing about Java and I normally avoid it like the plague. The background is that this particular java class generates Maxicode barcodes (which Windev still doesn't do in v12 it seems). I need to use it like I would say an ActiveX to generate my barcodes.
I've searched the forums and have read "Java Libraries (Ben) 03/04/2008 08:52 AM" but am still coming up blanks. The external libraries only seems to want to import *.WDL files and not classes. Can I actually do this and if so how?
You help is greatly appreciated...
Anthony
Publicado el 15,mayo 2008 - 12:15
Anthony W schrieb:
Hi all, I wish to use an external Java *.class or *.java in a windev application. Firstly I know nothing about Java and I normally avoid it like the plague. The background is that this particular java class generates Maxicode barcodes (which Windev still doesn't do in v12 it seems). I need to use it like I would say an ActiveX to generate my barcodes.
I've searched the forums and have read "Java Libraries (Ben) 03/04/2008 08:52 AM" but am still coming up blanks. The external libraries only seems to want to import *.WDL files and not classes. Can I actually do this and if so how?
You help is greatly appreciated...
Anthony


In *general* it is possible to call java class methods from Windev.
1) You have to load the class --See JavaLoad
2) You can now execute a class method -- See JavaExecuteFunction


AFAIK
the called methods have to be public.
only basic datatype parameters are supported int, bool, string.... again
see Online help ->JavaExecuteFunction

hth bjoern
Publicado el 11,marzo 2015 - 08:57
I'm building a basic Point of Sale application and I've been looking for ways of having my main POS JFrame listen for bar code input. I found this code (slightly modified) posted by Cyrusmith, which looks like what I want but I don't know how to implement it in my JFrame. It looks like its intended to be a separate class, which is how I have it in my project currently. I asked my coworker and he doesn't know either.

Thanks for your help.
package barcode;

import java.awt.KeyEventDispatcher;
import java.awt.KeyboardFocusManager;
import java.awt.event.KeyEvent;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;

/**
* Listens for bar code Input AND puts it into a string Buffer.
*
*/
PUBLIC class BarcodeReader {

PRIVATE static final long THRESHOLD = 100;
PRIVATE static final int MIN_BARCODE_LENGTH = 8;

PUBLIC interface BarcodeListener {

void onBarcodeRead(string barcode);
}
PRIVATE final StringBuffer barcode = new StringBuffer();
PRIVATE final List<BarcodeListener> listeners = new CopyOnWriteArrayList<>();
PRIVATE long lastEventTimeStamp = 0L;

PUBLIC BarcodeReader() {

KeyboardFocusManager.getCurrentKeyboardFocusManager().addKeyEventDispatcher(new KeyEventDispatcher() {
@Override
PUBLIC boolean dispatchKeyEvent(KeyEvent e) {
try {
IF (e.getID() != KeyEvent.KEY_RELEASED) {
RETURN False;
}

IF (e.getWhen() - lastEventTimeStamp > THRESHOLD) {
barcode.delete(0, barcode.length());
}

lastEventTimeStamp = e.getWhen();

IF (e.getKeyCode() == KeyEvent.VK_ENTER) {
IF (barcode.length() >= MIN_BARCODE_LENGTH) {
fireBarcode(barcode.toString());
}
barcode.delete(0, barcode.length());
} ELSE {
barcode.append(e.getKeyChar());
}
RETURN False;
} catch (UnsupportedOperationException err) {
throw new UnsupportedOperationException(err); //To change body of generated methods, choose Tools | Templates.
}

}
});

}

PROTECTED void fireBarcode(string barcode) {
for (BarcodeListener listener : listeners) {
listener.onBarcodeRead(barcode);
}
}

PUBLIC void addBarcodeListener(BarcodeListener listener) {
listeners.add(listener);
}

PUBLIC void removeBarcodeListener(BarcodeListener listener) {
listeners.remove(listener);
}
}

______________________________________
http://www.businessrefinery.com/
Publicado el 11,marzo 2015 - 13:22
Hi Jacob

if you posted on the correct forum (ie WINDEV), then you do not need any
of this, as a barcode reader can be seen as a keyboard, and therefore
the only thing you need to do is to set the focus in the appropriate field

If your question is about a windev MOBILE development, then please post
it in the windev mobile forum and make sure you give more information
about your target (android, ios, etc)

Best regards

--
Fabrice Harari
International WinDev, WebDev and WinDev mobile Consulting

NEW: WXReplication, your open source replication system is available on
my web site!!!
WXShowroom.com: Show your projects!
More information on http://www.fabriceharari.com


On 3/11/2015 2:57 AM, jacoblee wrote:
I'm building a basic Point of Sale application and I've been looking for
ways of having my main POS JFrame listen for bar code input. I found
this code (slightly modified) posted by Cyrusmith, which looks like what
I want but I don't know how to implement it in my JFrame. It looks like
its intended to be a separate class, which is how I have it in my
project currently. I asked my coworker and he doesn't know either.

Thanks for your help.
package barcode;

import java.awt.KeyEventDispatcher;
import java.awt.KeyboardFocusManager;
import java.awt.event.KeyEvent;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;

/**
* Listens for bar code input and puts it into a String Buffer.
*
*/
public class BarcodeReader {

private static final long THRESHOLD = 100;
private static final int MIN_BARCODE_LENGTH = 8;

public interface BarcodeListener {

void onBarcodeRead(String barcode);
}
private final StringBuffer barcode = new StringBuffer();
private final List<BarcodeListener> listeners = new
CopyOnWriteArrayList<>();
private long lastEventTimeStamp = 0L;

public BarcodeReader() {


KeyboardFocusManager.getCurrentKeyboardFocusManager().addKeyEventDispatcher(new
KeyEventDispatcher() {
@Override
public boolean dispatchKeyEvent(KeyEvent e) {
try {
if (e.getID() != KeyEvent.KEY_RELEASED) {
return false;
}

if (e.getWhen() - lastEventTimeStamp > THRESHOLD) {
barcode.delete(0, barcode.length());
}

lastEventTimeStamp = e.getWhen();

if (e.getKeyCode() == KeyEvent.VK_ENTER) {
if (barcode.length() >= MIN_BARCODE_LENGTH) {
fireBarcode(barcode.toString());
}
barcode.delete(0, barcode.length());
} else {
barcode.append(e.getKeyChar());
}
return false;
} catch (UnsupportedOperationException err) {
throw new UnsupportedOperationException(err); //To
change body of generated methods, choose Tools | Templates.
}

}
});

}

protected void fireBarcode(String barcode) {
for (BarcodeListener listener : listeners) {
listener.onBarcodeRead(barcode);
}
}

public void addBarcodeListener(BarcodeListener listener) {
listeners.add(listener);
}

public void removeBarcodeListener(BarcodeListener listener) {
listeners.remove(listener);
}
}

______________________________________
http://www.businessrefinery.com/