HII need u Help...!!I have a Jframe and a Jbutton ()i dont know how to send
values to my PrintUtilitres ClassPlease if someone could correct these codes.
-----------------public void
recorrerTable(){System.out.println(jTdetalle.getRowCount());PrintUtilities
impr=new PrintUtilities();int a=1;int hasta=jTdetalle.getRowCount();while
(a<=hasta) { impr.addCantidad((String)
jTdetalle.getValueAt(a,0)); impr.addDescripcion((String)
jTdetalle.getValueAt(a,1)); impr.addPrecio((String)
jTdetalle.getValueAt(a,3));
System.out.println(jTdetalle.getValueAt(a,0) + " "+ jTdetalle.getValueAt(a,1)
+" "+jTdetalle.getValueAt(a,3));a=a+1;
}impr.addCantidad("4");impr.addDescripcion("artocilo
");impr.addPrecio("1500");//impr.addTotal(Integer.parseInt(txttotal.getText()));
impr.Imprimir(Integer.parseInt(txttotal.getText())); }
------------------- ----------------import java.util.ArrayList;
import java.awt.*; import java.awt.print.*; public class PrintUtilities
implements Printable { private Font fnt = new
Font("Helvetica",Font.PLAIN,8); ArrayList cantidad=new ArrayList();
ArrayList des=new ArrayList(); ArrayList precio=new ArrayList(); int x=300;
private int total; public void addCantidad(String cant){
cantidad.add(cant); } public void addDescripcion(String cant){
des.add(cant); } public void addPrecio(String cant){
precio.add(cant); } public void addTotal(int tot){
} public void Imprimir (int total1) { // Get a PrinterJob
total=total1; PrinterJob job = PrinterJob.getPrinterJob(); //
Specify the Printable is an instance of SimplePrint //job.setPrintable(new
PrintUtilities()); // Put up the dialog box if
(job.printDialog()) { // Print the job if the user didn't
cancel printing try { job.print(); } catch (Exception e) {
/* handle exception */ } } System.exit(0); } public int
print(Graphics g, PageFormat pf, int pageIndex) throws PrinterException {
// pageIndex 0 to 4 corresponds to page numbers 1 to 5. if
(pageIndex >= 1) return Printable.NO_SUCH_PAGE; g.setFont(fnt);
g.setColor(Color.green); g.drawString("COMERCIAL
EZEQUIEL",160,160);g.drawString("DISTRIBUIDOR
AUTORIZADO",160,170);g.drawString("LACTEOS LA
FORTUNA",160,180);g.drawString("RUC: xxxxxxxxxxxxxx",160,190);g.drawString("Av.
Aviadores del Chaco",160,200);g.drawString("========================",160,210);
int i=0;
while(i<=cantidad.size()){
g.drawString((String) cantidad.get(i), 60, x);
g.drawString((String) des.get(i), 80, x);
g.drawString((String) precio.get(i), 100, x); x=x+3;
i++; }
g.drawString("========================",160,x);x=x+5; g.drawString("Total
:"+total,160,x);x=x+5; g.drawString("========================",160,x);
return Printable.PAGE_EXISTS; } }
----------------
_________________________________________________________________
Discover the new Windows Vista
http://search.msn.com/results.aspx?q=windows+vista&mkt=en-US&form=QBRE
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to javaprogrammingwithpassion@googlegroups.com
To unsubscribe from this group, send email to
javaprogrammingwithpassion+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/javaprogrammingwithpassion?hl=en
-~----------~----~----~----~------~----~------~--~---