Professional Documents
Culture Documents
4ISC11
PRACTICA:
“GENERACION DE CODIGO QR”
16/12/2013
package imagenqr;
import com.barcodelib.barcode.QRCode;
import java.awt.Desktop;
import java.io.File;
public class Angelica extends javax.swing.JFrame {
int udt=0;
int resol=72;
float mi=0.000f;
float md=0.000f;
float ms=0.000f;
float min=0.000f;
int rot=0;
float tam=6.000f;
private String nombre;
public Angelica() {
initComponents();
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jLabel1.setText("CODiGO QR");
jButton1.setText("GENERAR QR");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
jButton2.setText("SALIR");
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});
x.setColumns(20);
x.setRows(5);
jScrollPane1.setViewportView(x);
pack();
}// </editor-fold>
try{
QRCode cod=new QRCode();
String texto=x.getText();
cod.setData(texto);
cod.setDataMode(QRCode.MODE_BYTE);
cod.setUOM(udt);
cod.setLeftMargin(mi);
cod.setResolution(resol);
cod.setRightMargin(md);
cod.setBottomMargin(min);
cod.setRotate(rot);
cod.setModuleSize(tam);
String archiv=System.getProperty("user.home")+"/"+nombre+"imagenQR.gif";
cod.renderBarcode(archiv);
Desktop d=Desktop.getDesktop();
d.open(new File(archiv));
}
catch (Exception e){}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(Angelica.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(Angelica.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(Angelica.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(Angelica.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>