Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| Path | csiph.com!eternal-september.org!feeder.eternal-september.org!aioe.org!.POSTED!not-for-mail |
|---|---|
| From | "Dr.UgoGagliardelli" <do.not.spam@me.please> |
| Newsgroups | it.comp.java |
| Subject | Re: importi giustificati a destra |
| Date | Tue, 6 Oct 2015 06:57:35 +0200 |
| Organization | Aioe.org NNTP Server |
| Lines | 32 |
| Message-ID | <muvkbt$ubc$1@speranza.aioe.org> (permalink) |
| References | <muu5lr$s1h$1@speranza.aioe.org> <muu9hm$6fd$1@speranza.aioe.org> <muuadj$8fd$1@speranza.aioe.org> <muudgc$gjn$1@speranza.aioe.org> <muug4n$n8q$1@speranza.aioe.org> |
| NNTP-Posting-Host | o+A5Qai+uOOCJdrsv5N6zA.user.speranza.aioe.org |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=iso-8859-15; format=flowed |
| Content-Transfer-Encoding | 8bit |
| X-Complaints-To | abuse@aioe.org |
| User-Agent | Mozilla/5.0 (Windows NT 6.3; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 |
| X-Notice | Filtered by postfilter v. 0.8.2 |
| Xref | csiph.com it.comp.java:8586 |
Show key headers only | View raw
Il 05.10.2015 20.36, Gulp® ha scritto: > Il 05/10/15 19:54, Dr.UgoGagliardelli ha scritto: >> Il font di solito proviene dal >> contesto da cui prelevi l'oggetto Graphics, oppure da uno impostato, > > lo potrei comunque impostare fisso. > >> comunque con g2d.getFont(). Utilizzando tale font puoi calcolare la >> dimensione il pixel da utilizzare per calcolare la dimensione della tua >> stringa. Ad esempio: >> >> Font font = g2d.getFont(); >> FontMetrics fm = Toolkit.getDefaultToolkit().getFontMetrics(font); >> int width = fm.charsWidth(text.toCharArray(), 0, text.length); > > Mi da un problema: > FontMetrics fm = Toolkit.getDefaultToolkit().getFontMetrics(fonti); > > getFontMetrics nel codice viene barrato come non fosse disponibile. > Il metodo e' marcato deprecato dal jdk 1.2, il javadoc suggerisce di utilizzare un oggetto LineMetrics, che pero' non ha metodi 'comodi come FontMetrics. Dagli altri post ho capito che devi stampare su una stampante, quindi immagino che tu stia utilizzando l'interfaccia Printable, in tal caso dovresti utilizzare g2d.getFontMetrics() oppure g2d.getFontMetrics(font) Ti segnalo anche il metodo: int width = fm.stringWidth(text); che fa esattamente la stessa cosa del metodo che ti avevo consigliato in precedenza, charsWidth, che e' quello che utilizzo per abitudine.
Back to it.comp.java | Previous | Next — Previous in thread | Next in thread | Find similar
importi giustificati a destra Gulp® <gulp@hotmail.it> - 2015-10-05 17:37 +0200
Re: importi giustificati a destra 4ndre4 <a.laforgia@gmail.com> - 2015-10-05 08:49 -0700
Re: importi giustificati a destra Gulp® <gulp@hotmail.it> - 2015-10-05 17:57 +0200
Re: importi giustificati a destra "Dr.UgoGagliardelli" <do.not.spam@me.please> - 2015-10-05 18:46 +0200
Re: importi giustificati a destra Gulp® <gulp@hotmail.it> - 2015-10-05 18:59 +0200
Re: importi giustificati a destra 4ndre4 <a.laforgia@gmail.com> - 2015-10-05 10:36 -0700
Re: importi giustificati a destra Gulp® <gulp@hotmail.it> - 2015-10-05 20:46 +0200
Re: importi giustificati a destra "Dr.UgoGagliardelli" <do.not.spam@me.please> - 2015-10-05 19:54 +0200
Re: importi giustificati a destra Gulp® <gulp@hotmail.it> - 2015-10-05 20:36 +0200
Re: importi giustificati a destra "Dr.UgoGagliardelli" <do.not.spam@me.please> - 2015-10-06 06:57 +0200
Re: importi giustificati a destra Gulp® <gulp@hotmail.it> - 2015-10-05 20:44 +0200
Re: importi giustificati a destra Delta11 <delta11NSP@email.it> - 2015-10-05 21:13 +0200
Re: importi giustificati a destra "Dr.UgoGagliardelli" <do.not.spam@me.please> - 2015-10-06 07:15 +0200
Re: importi giustificati a destra Delta11 <delta11NSP@email.it> - 2015-10-06 09:09 +0200
Re: importi giustificati a destra "Dr.UgoGagliardelli" <do.not.spam@me.please> - 2015-10-06 17:00 +0200
Re: importi giustificati a destra 4ndre4 <a.laforgia@gmail.com> - 2015-10-06 08:50 -0700
csiph-web