Dsy Network www | forum | my | didattica | howto | wiki | el goog | stats | blog | dona | rappresentanti
Homepage
 Register   Calendar   Members  Faq   Search  Logout 
.dsy:it. : Powered by vBulletin version 2.3.1 .dsy:it. > Community > Forum De Bell Tolls > [JAVA]PrintPreview
Pages (2): [1] 2 »   Last Thread   Next Thread
Author
Thread    Expand all | Contract all    Post New Thread    Post A Reply
Collapse
0m4r
.grande:maestro.

User info:
Registered: Mar 2002
Posts: 7287 (0.86 al dì)
Location: Düsseldorf (DE)
Corso:
Anno: ESAMI FINITI
Time Online: 49 Days, 0:42:50 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged
[JAVA]PrintPreview

c'è qualche buon anima che è in grado di aiutarmi a capire come utilizzare questa classse java?
Dovrebbe servire a visualizzare una PrintPreview di un elemento awt/Swing ma non la riesco ad usare...piu che altro non capisco come creare un oggetto di tipo Printable da poassare al costruttore dato che Printable è una classe astratta!

Scusate se lo allego ma è un po lunghino da postare...

questa è la fonte: http://www.spindoczine.com/sbe/

Attachment: printpreview.java
This has been downloaded 22 time(s).

__________________
http://www.twitter.com/0m4r

05-05-2003 16:13
Click Here to See the Profile for 0m4r Click Here to See the Blog of 0m4r Click here to Send 0m4r a Private Message Find more posts by 0m4r Add 0m4r to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
0m4r
.grande:maestro.

User info:
Registered: Mar 2002
Posts: 7287 (0.86 al dì)
Location: Düsseldorf (DE)
Corso:
Anno: ESAMI FINITI
Time Online: 49 Days, 0:42:50 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

nessuno ci capisce niente?

__________________
http://www.twitter.com/0m4r

05-05-2003 18:25
Click Here to See the Profile for 0m4r Click Here to See the Blog of 0m4r Click here to Send 0m4r a Private Message Find more posts by 0m4r Add 0m4r to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
0m4r
.grande:maestro.

User info:
Registered: Mar 2002
Posts: 7287 (0.86 al dì)
Location: Düsseldorf (DE)
Corso:
Anno: ESAMI FINITI
Time Online: 49 Days, 0:42:50 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

up!

__________________
http://www.twitter.com/0m4r

06-05-2003 16:17
Click Here to See the Profile for 0m4r Click Here to See the Blog of 0m4r Click here to Send 0m4r a Private Message Find more posts by 0m4r Add 0m4r to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
aesse
args[]

User info:
Registered: Dec 2002
Posts: 50 (0.01 al dì)
Location: Milano
Corso: TICO
Anno: 1
Time Online: 1 Day, 19:15:38 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Se printable è una classe astratta potresti estenderla ridefinendone i metodi (come ridefinirli è il problema!)..così poi potresti passarla senza problemi al costruttore!
Il costruttore di printpreview accetta solo quella classe astratta o anche qualche interfaccia? (magari c'è qualche componente swing che la implementa.. e saresti a posto)

09-05-2003 21:56
Click Here to See the Profile for aesse Click here to Send aesse a Private Message Visit aesse's homepage! Find more posts by aesse Add aesse to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
0m4r
.grande:maestro.

User info:
Registered: Mar 2002
Posts: 7287 (0.86 al dì)
Location: Düsseldorf (DE)
Corso:
Anno: ESAMI FINITI
Time Online: 49 Days, 0:42:50 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

grazie ell'aiuto...ma sono al punto di partenza! ;(

__________________
http://www.twitter.com/0m4r

10-05-2003 11:02
Click Here to See the Profile for 0m4r Click Here to See the Blog of 0m4r Click here to Send 0m4r a Private Message Find more posts by 0m4r Add 0m4r to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
0m4r
.grande:maestro.

User info:
Registered: Mar 2002
Posts: 7287 (0.86 al dì)
Location: Düsseldorf (DE)
Corso:
Anno: ESAMI FINITI
Time Online: 49 Days, 0:42:50 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

ri-up...dai dai che ce la fate!

__________________
http://www.twitter.com/0m4r

14-10-2003 16:44
Click Here to See the Profile for 0m4r Click Here to See the Blog of 0m4r Click here to Send 0m4r a Private Message Find more posts by 0m4r Add 0m4r to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
Rocco.Li
38 Primavere, Dottore !

User info:
Registered: Sep 2003
Posts: 609 (0.08 al dì)
Location: BARLASSINA (MI)
Corso: COMUNICAZIONE DIGITALE
Anno: Finitooooo !!!!
Time Online: 8 Days, 2:31:26 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

printable e' un interfaccia, quindi sulle classi che vuoi stampare devi implementare tale interfaccia (public MiaClasse implements Printable ...)

Molto probabilmente ti mancano molti pezzi del mosaico, ti conviene consultare una documentazione abbastanza completa di AWT (sito SUN o libri sull'argomento) visto che l'interfaccia menzionata fa parte di quest'ultimo.

puoi iniziare a consultare il capitolo 22 del libro scaricabile all'indirizzo menzionato. Qualche info in piu' la trovi.

Ciao.

Rocco

__________________
Alcuni uomini vedono le cose come sono e dicono: << Perche' ? >>
Io sogno le cose come non sono mai state e dico: << Perche' No ? >>
George Barnard Shaw, Commediografo.

"non preoccuparti troppo, comunque vada la vita, non ne uscirai vivo !" - anonimo

14-10-2003 19:00
Click Here to See the Profile for Rocco.Li Click Here to See the Blog of Rocco.Li Click here to Send Rocco.Li a Private Message Find more posts by Rocco.Li Add Rocco.Li to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
0m4r
.grande:maestro.

User info:
Registered: Mar 2002
Posts: 7287 (0.86 al dì)
Location: Düsseldorf (DE)
Corso:
Anno: ESAMI FINITI
Time Online: 49 Days, 0:42:50 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

riuppo, dato che nonostante sia passato un sacco di tempo ancoira non ho risolto il problema...qualcuno mi illumina?

dai raga, lo so che ce la possiamo fare.

__________________
http://www.twitter.com/0m4r

15-03-2004 21:38
Click Here to See the Profile for 0m4r Click Here to See the Blog of 0m4r Click here to Send 0m4r a Private Message Find more posts by 0m4r Add 0m4r to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
Lord_Tom
gentiluomo

User info:
Registered: Dec 2001
Posts: 177 (0.02 al dì)
Location: PAVIA
Corso: laurea quinquennale info
Anno: 5
Time Online: 2 Days, 0:17:35 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

http://java.sun.com/j2se/1.4.2/docs/api/java/awt/print/class-use/Printable.html
qui trovi gli usi di printable.
La documentazione e' raggiungibile da quella pagina!

16-03-2004 10:42
Click Here to See the Profile for Lord_Tom Click here to Send Lord_Tom a Private Message Find more posts by Lord_Tom Add Lord_Tom to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
Ryudo
.precettore.

User info:
Registered: Apr 2003
Posts: 85 (0.01 al dì)
Location: Arcore
Corso: Informatica
Anno: 1
Time Online: 3 Days, 8:05:43 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

devi implementare l'interfaccia Printable in ogni componente Swing che vuoi stampare e ridefinire il metodo print() all'interno di questi componenti.

Es.

PHP:

public class MyPrintablePanel extends   JPanel implements Printable {
    public int print(Graphics g, PageFormat pf, int pageIdx) throws PrinterException {
      // controlli se pageIdx esiste
      // crei e imposti il rettangolo da stampare
     // return Printable.PAGE_EXISTS oppure Printable.NO_SUCH_PAGE a seconda se pageIdx esiste o meno.
}



poi crei l'oggetto PrintPreview passandogli un new MyPrintablePanel().
Se cerchi qualche tutorial trovi il codice di print() gia' pronto, io ai tempi l'avevo scopiazzato da un articolo :D

16-03-2004 21:00
Click Here to See the Profile for Ryudo Click here to Send Ryudo a Private Message Visit Ryudo's homepage! Find more posts by Ryudo Add Ryudo to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
0m4r
.grande:maestro.

User info:
Registered: Mar 2002
Posts: 7287 (0.86 al dì)
Location: Düsseldorf (DE)
Corso:
Anno: ESAMI FINITI
Time Online: 49 Days, 0:42:50 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

io non capisco cose devo metterci dentro print, l'ho scopiazzato anche io, ma non riesco a vededre nulla...è proprio questo il problema, l'implementazione di print.

Non è che mi faresti scopiazzare il tuo? ;P

__________________
http://www.twitter.com/0m4r

16-03-2004 21:07
Click Here to See the Profile for 0m4r Click Here to See the Blog of 0m4r Click here to Send 0m4r a Private Message Find more posts by 0m4r Add 0m4r to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
Ryudo
.precettore.

User info:
Registered: Apr 2003
Posts: 85 (0.01 al dì)
Location: Arcore
Corso: Informatica
Anno: 1
Time Online: 3 Days, 8:05:43 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Originally posted by 0m4r

Non è che mi faresti scopiazzare il tuo? ;P

l'ho usato a lavoro ma un annetto fa altrimenti te lo passavo, hai provato a vedere se c'e' qualcosa su javaworld.com ? Altrimenti posta il tuo print() e vediamo che c'e' dentro :)

16-03-2004 21:18
Click Here to See the Profile for Ryudo Click here to Send Ryudo a Private Message Visit Ryudo's homepage! Find more posts by Ryudo Add Ryudo to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
0m4r
.grande:maestro.

User info:
Registered: Mar 2002
Posts: 7287 (0.86 al dì)
Location: Düsseldorf (DE)
Corso:
Anno: ESAMI FINITI
Time Online: 49 Days, 0:42:50 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

il mio print è un utante ormai....vedo se riesco a ritrovare l'originale piu significatico che ho usato...
thx dell'aiuto...

P.S.
andando un po ot, non è che sai in che modo ricavare una immagine da un oggetto AWT o Swing?

__________________
http://www.twitter.com/0m4r

16-03-2004 21:20
Click Here to See the Profile for 0m4r Click Here to See the Blog of 0m4r Click here to Send 0m4r a Private Message Find more posts by 0m4r Add 0m4r to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
0m4r
.grande:maestro.

User info:
Registered: Mar 2002
Posts: 7287 (0.86 al dì)
Location: Düsseldorf (DE)
Corso:
Anno: ESAMI FINITI
Time Online: 49 Days, 0:42:50 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

questo, nel caso perticolare servirebbe per una tabella, se funzionasse...

code:
public int print(Graphics g, PageFormat pageFormat, int pageIndex) { Graphics2D g2 = (Graphics2D) g; g2.setColor(Color.black); int fontHeight=g2.getFontMetrics().getHeight(); int fontDesent=g2.getFontMetrics().getDescent(); //leave room for page number double pageHeight = pageFormat.getImageableHeight()-fontHeight; double pageWidth = pageFormat.getImageableWidth(); double tableWidth = (double) getColumnModel().getTotalColumnWidth(); double scale = 1; if (tableWidth >= pageWidth) { scale = pageWidth / tableWidth; } double headerHeightOnPage=getTableHeader().getHeight()*scale; double tableWidthOnPage=tableWidth*scale; double oneRowHeight=(getRowHeight()+getRowMargin())*scale ; int numRowsOnAPage=(int)((pageHeight-headerHeightOnPage)/oneRowHeight); double pageHeightForTable=oneRowHeight*numRowsOnAPage; int totalNumPages=(int)Math.ceil(((double)getRowCount())/numRowsOnAPage); if(pageIndex>=totalNumPages) { return NO_SUCH_PAGE; } g2.translate(pageFormat.getImageableX(),pageFormat.getImageableY()); //bottom center g2.drawString("Page: "+(pageIndex+1),(int)pageWidth/2-35, (int)(pageHeight+fontHeight-fontDesent)); g2.translate(0f,headerHeightOnPage); g2.translate(0f,-pageIndex*pageHeightForTable); //If this piece of the table is smaller //than the size available, //clip to the appropriate bounds. if (pageIndex + 1 == totalNumPages) { int lastRowPrinted = numRowsOnAPage * pageIndex; int numRowsLeft = getRowCount() - lastRowPrinted; g2.setClip(0,(int)(pageHeightForTable * pageIndex),(int) Math.ceil(tableWidthOnPage),(int) Math.ceil(oneRowHeight * numRowsLeft)); } //else clip to the entire area available. else{ g2.setClip(0, (int)(pageHeightForTable*pageIndex), (int) Math.ceil(tableWidthOnPage), (int) Math.ceil(pageHeightForTable)); } g2.scale(scale,scale); paint(g2); g2.scale(1/scale,1/scale); g2.translate(0f,pageIndex*pageHeightForTable); g2.translate(0f, -headerHeightOnPage); g2.setClip(0, 0, (int) Math.ceil(tableWidthOnPage), (int)Math.ceil(headerHeightOnPage)); g2.scale(scale,scale); getTableHeader().paint(g2); //paint header at top return Printable.PAGE_EXISTS; }

__________________
http://www.twitter.com/0m4r

Last edited by 0m4r on 16-03-2004 at 21:27

16-03-2004 21:24
Click Here to See the Profile for 0m4r Click Here to See the Blog of 0m4r Click here to Send 0m4r a Private Message Find more posts by 0m4r Add 0m4r to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
Ryudo
.precettore.

User info:
Registered: Apr 2003
Posts: 85 (0.01 al dì)
Location: Arcore
Corso: Informatica
Anno: 1
Time Online: 3 Days, 8:05:43 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Originally posted by 0m4r

andando un po ot, non è che sai in che modo ricavare una immagine da un oggetto AWT o Swing?

intendi dire che vuoi ottenre un' immagine del componente stesso ? francamente non ne ho idea pero' e' interessante magari quando ho tempo vedo se trovo qualcosa :D

16-03-2004 21:28
Click Here to See the Profile for Ryudo Click here to Send Ryudo a Private Message Visit Ryudo's homepage! Find more posts by Ryudo Add Ryudo to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
All times are GMT. The time now is 18:05.    Post New Thread    Post A Reply
Pages (2): [1] 2 »   Last Thread   Next Thread
Show Printable Version | Email this Page | Subscribe to this Thread | Add to Bookmarks

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is ON
 

Powered by: vBulletin v2.3.1 - Copyright ©2000 - 2002, Jelsoft Enterprises Limited
Mantained by dsy crew (email) | Collabora con noi | Segnalaci un bug | Archive | Regolamento | Licenze | Thanks | Syndacate
Pagina generata in 0.087 seconds (72.51% PHP - 27.49% MySQL) con 22 query.