Não consigo chamar uma classe dentro da outra

1 resposta
Willdoidao

Fiz o import e no codigo coloquei:

Impressao_os imprimir = new Impressao_os();
               imprimir.main(Impressao_os);

Mas nw está dando certo a classe q quero chamar é essa?!

public class Impressao_os {

    private static Font catFont = new Font(Font.FontFamily.HELVETICA, 18, Font.BOLD);
    private static Font dogFont = new Font(Font.FontFamily.HELVETICA, 10, Font.BOLD);

    public static void main(String a[]) throws Exception {
        //Pegando data do Micro
        Date now = new Date();
        DateFormat df = DateFormat.getDateInstance();
        String data_micro = df.format(now);

        String Nome_micro = "H:/" + Cadastro.Nome_cliente + ".pdf";
        String Nome_cliente = Cadastro.Nome_cliente;
        //Criando Documento
        Document doc = new Document();
        PdfWriter.getInstance(doc, new FileOutputStream(Nome_micro));
        doc.open();


        Paragraph[] p = new Paragraph[4];
        p[0] = new Paragraph("Data: " + data_micro + "");
        p[1] = new Paragraph("Ordem de Serviço: " + data_micro + "", catFont);
        p[2] = new Paragraph("Cliente: " + Cadastro.Nome_cliente + "");
        p[3] = new Paragraph(" ");
        for (int i = 0; i < 4; i++) {
            p[i].setAlignment(Element.ALIGN_JUSTIFIED);
            doc.add(p[i]);
        }

        //Tabela com Grau
        //Longe
        doc.add(new Paragraph(" "));
        PdfPTable table = new PdfPTable(5);
        PdfPCell cell = new PdfPCell(new Paragraph("LONGE"));
        cell.setColspan(5);
        table.addCell(cell);
        table.addCell(" ");
        table.addCell("ESF.");
        table.addCell("CIL.");
        table.addCell("EIXO");
        table.addCell("DIP");
        table.addCell("O.D");
        table.addCell(OrdemServ.lde);
        table.addCell(OrdemServ.ldc);
        table.addCell(OrdemServ.ldeixo);
        table.addCell(OrdemServ.lddip);
        table.addCell("O.E");
        table.addCell(OrdemServ.lee);
        table.addCell(OrdemServ.lec);
        table.addCell(OrdemServ.leeixo);
        table.addCell(OrdemServ.ledip);
        table.setWidthPercentage(50);
        table.setHorizontalAlignment(Element.ALIGN_LEFT);
        doc.add(table);
//Perto
        doc.add(new Paragraph(" "));
        // step 4: we add a table to the document
        PdfPTable table2 = new PdfPTable(5);
        PdfPCell cell2 = new PdfPCell(new Paragraph("PERTO"));
        cell2.setColspan(5);
        table2.addCell(cell2);
        table2.addCell(" ");
        table2.addCell("ESF.");
        table2.addCell("CIL.");
        table2.addCell("EIXO");
        table2.addCell("DIP");
        table2.addCell("O.D");
        table2.addCell(OrdemServ.pde);
        table2.addCell(OrdemServ.pdc);
        table2.addCell(OrdemServ.pdeixo);
        table2.addCell(OrdemServ.pddip);
        table2.addCell("O.E");
        table2.addCell(OrdemServ.pee);
        table2.addCell(OrdemServ.pec);
        table2.addCell(OrdemServ.peeixo);
        table2.addCell(OrdemServ.pedip);
        table2.setWidthPercentage(50);
        table2.setHorizontalAlignment(Element.ALIGN_LEFT);
        doc.add(table2);

        doc.add(new Paragraph("Lente   : " + OrdemServ.lenteI + ""));
        doc.add(new Paragraph("Altura  : " + OrdemServ.alturaI + ""));
        doc.add(new Paragraph("Armação : " + OrdemServ.armacaoI + ""));
        doc.add(new Paragraph("Vendedor: " + Entrar.Entrar_user + ""));
        doc.add(new Paragraph("Preço   : " + OrdemServ.precoI + "  Saldo: " + OrdemServ.saldoI + ""));
        doc.add(new Paragraph("---------------------------------------------------------------------"));

        doc.add(new Paragraph("  Ótica Jardim Das Flores".toUpperCase(), catFont));
        doc.add(new Paragraph("           Est. do M' Boi Mirin # 489 - Jd. das Flores", dogFont));
        doc.add(new Paragraph("                   Fone: 5515-1120 / 5515-1120", dogFont));
        doc.add(new Paragraph("Data:" + data_micro + " OS: " + Nome_cliente + "", dogFont));
        doc.add(new Paragraph("Nome: " + Cadastro.Nome_cliente + "".toUpperCase()));
        doc.add(new Paragraph("Preço   : " + OrdemServ.precoI + "  Saldo: " + OrdemServ.saldoI + ""));

        doc.close();
    }
}

Alguem poderia me ensinar como chamar essa classe??!!??!

1 Resposta

ViniGodoy

Como mais é um método estático, basta fazer:

Impressao_os.main(new String[] {});

Agora, é bom pegar uma apostila básica de Java ou de OO, para você entender bem os conceitos. O ideal é nunca usar métodos estáticos, e saber definir bem uma classe.

Criado 4 de agosto de 2010
Ultima resposta 4 de ago. de 2010
Respostas 1
Participantes 2