Código Java:
Ver original
{ { super (); this.setSize(470, 350); Barcode barcode = BarcodeFactory.createCode39("N14U-93110-00",false); barcode.setDrawingText(false); barcode.setBarHeight(50); barcode.setBarWidth(2); BarcodeImageHandler.writeJPEG(barcode, fos); Barcode barcode_q = BarcodeFactory.createCode39("Q8",false); barcode_q.setDrawingText(false); barcode_q.setBarHeight(50); barcode_q.setBarWidth(2); BarcodeImageHandler.writeJPEG(barcode_q, fos_q); Barcode barcode_l = BarcodeFactory.createCode39("L1111",false); barcode_l.setDrawingText(false); barcode_l.setBarHeight(50); barcode_l.setBarWidth(2); BarcodeImageHandler.writeJPEG(barcode_l, fos_l); image.setIcon(icon); image_q.setIcon(icon_q); image_l.setIcon(icon_l); constraints.gridx = 1; constraints.gridy = 0; constraints.gridwidth = 1; constraints.gridheight = 1; constraints.weightx=0; constraints.weightx=0; this.add (country, constraints); constraints.gridx = 0; constraints.gridy = 1; constraints.gridwidth = 1; constraints.gridheight = 1; this.add (item, constraints); constraints.gridx = 0; constraints.gridy = 2; constraints.gridwidth = 1; constraints.gridheight = 1; this.add (item_comp, constraints); constraints.gridx = 1; constraints.gridy = 2; constraints.gridwidth = 1; constraints.gridheight = 1; this.add (item_no, constraints); constraints.gridx = 1; constraints.gridy = 3; constraints.gridwidth = 1; constraints.gridheight = 1; this.add (image, constraints); constraints.gridx = 0; constraints.gridy = 4; constraints.gridwidth = 1; constraints.gridheight = 1; this.add (espacio, constraints); constraints.gridx = 0; constraints.gridy = 5; constraints.gridwidth = 1; constraints.gridheight = 1; this.add (Quantity, constraints); constraints.gridx = 0; constraints.gridy = 6; constraints.gridwidth = 1; constraints.gridheight = 1; this.add (q, constraints); constraints.gridx = 1; constraints.gridy = 6; constraints.gridwidth = 1; constraints.gridheight = 1; this.add (qty, constraints); constraints.gridx = 1; constraints.gridy = 7; constraints.gridwidth = 1; constraints.gridheight = 1; this.add (image_q, constraints); constraints.gridx = 0; constraints.gridy = 8; constraints.gridwidth = 1; constraints.gridheight = 1; this.add (espacio, constraints); constraints.gridx = 0; constraints.gridy = 9; constraints.gridwidth = 1; constraints.gridheight = 1; this.add (lot, constraints); constraints.gridx = 0; constraints.gridy = 10; constraints.gridwidth = 1; constraints.gridheight = 1; this.add (lo, constraints); constraints.gridx = 1; constraints.gridy = 10; constraints.gridwidth = 1; constraints.gridheight = 1; this.add (l, constraints); constraints.gridx = 1; constraints.gridy = 11; constraints.gridwidth = 1; constraints.gridheight = 1; this.add (image_l, constraints); constraints.gridx = 0; constraints.gridy = 12; constraints.gridwidth = 1; constraints.gridheight = 1; this.add (espacio, constraints); constraints.gridx = 0; constraints.gridy = 13; constraints.gridwidth = 1; constraints.gridheight = 1; this.add (cus, constraints); constraints.gridx = 1; constraints.gridy = 13; constraints.gridwidth = 1; constraints.gridheight = 1; this.add (c, constraints); constraints.gridx = 1; constraints.gridy = 14; constraints.gridwidth = 1; constraints.gridheight = 1; this.add (country2, constraints); BufferedImage imagen = new BufferedImage(this.getWidth(), this.getHeight(), BufferedImage.TYPE_INT_RGB); this.paint(g); } public static void main(String args[]) throws BarcodeException, FileNotFoundException, OutputException, IOException{ Ventana obj= new Ventana(); obj.setVisible(true); } }
lo ocupo para poder hacer el diseño de una etiqueta y guardarla en una imagen jpg
el codigo me crea la imagen pero solo me pone el panel en blanco sin ningun componente agregado en las lineas this.add (componente, constraints);
no se que estoy haciendo mal
si cambio public class Ventana extends JPanel por
public class Ventana extends JFrame
se puede ver el diseño de como necesito que quede mi imagen, bueno y tambien necesito encerrar cada segento en un rectangulo
con este codigo me crea los rectangulos q necesito y el tamaño adecuado en la cual debe de quedar mi imagen solo falta hacer q aparescan los componentes q se agregan con this.add (componente, constraints);
solo le agregue al codigo de arriba este pedacito
Código Java:
Ver original
{ { super (); this.setSize(300, 295); . . . g.drawRect(1, 1, 296, 108); g.drawRect(1,109, 296, 72); g.drawRect(1,181, 296, 72); g.drawRect(1,253, 296, 38); this.paint(g); } public static void main(String args[]) throws BarcodeException, FileNotFoundException, OutputException, IOException{ Ventana obj= new Ventana(); obj.setVisible(true); } }
si alguien puede ayudarme se los agradecere infinitamente