tengo el siguiente codigo;
Código Java:
Ver originalpublic class Ventana
extends JPanel //con JFrame visualiza lo que necesito realizar {
{
super ();
this.setSize(470, 350);
this.
setBackground(Color.
white); 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);
country.
setFont(new java.
awt.
Font("Arial",
1,
14)); item.
setFont(new java.
awt.
Font("Arial",
1,
8)); item_comp.
setFont(new java.
awt.
Font("Arial",
1,
8)); item_no.
setFont(new java.
awt.
Font("Arial",
1,
20)); image.setIcon(icon);
qty.
setFont(new java.
awt.
Font("Arial",
1,
20)); Quantity.
setFont(new java.
awt.
Font("Arial",
1,
8)); q.
setFont(new java.
awt.
Font("Arial",
1,
8)); image_q.setIcon(icon_q);
l.
setFont(new java.
awt.
Font("Arial",
1,
20)); lot.
setFont(new java.
awt.
Font("Arial",
1,
8)); lo.
setFont(new java.
awt.
Font("Arial",
1,
8)); image_l.setIcon(icon_l);
c.
setFont(new java.
awt.
Font("Arial",
1,
20)); cus.
setFont(new java.
awt.
Font("Arial",
1,
8)); country2.
setFont(new java.
awt.
Font("Arial",
1,
14)); 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);
this.paint(g);
ImageIO.
write(imagen,
"jpg",
new File("c:/prueba.jpg")); }
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 originalpublic class Ventana
extends JFrame {
{
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);
g.
setXORMode(Color.
black); this.paint(g);
ImageIO.
write(imagen,
"jpg",
new File("c:/prueba.jpg")); }
Ventana obj= new Ventana();
obj.setVisible(true);
}
}
si alguien puede ayudarme se los agradecere infinitamente