Re: size of a string in pixel ?

> the thing is that in order to preserve the layout, I'd like to set the
> component's size to its maximum
> ( eg. if the JtextField contains a Date, i'll set it to the size
> necessary to hold "wednesday, december 25th" )
> in order to compute this size, I need to translate number of characters
> to pixels. ( taking into account the fonts )
> How can I do this ?
see FontMetrics#stringWidth(String s);

Andrey Kuznetsov Unified I/O for Java Java image reader Java GUI components and utilities


Relevant Pages

  • Re: Desire to unify UI for HyperCard VisualBasic Java and HTMLform
    ... > how are VB layouts more flexible than the standard Java layout ... Well I suppose with extremely contorted mis-use of GridBagLayout you ... standard layout managers in the expected way, ... manager in Java, just manually place each component by explicit x,y ...
  • Re: VS.NET against JAVA
    ... Java's layout managers take a while to get used to, ... Java wins hands down IMO. ... The JIT compiler is a compiler :-) ... Well, I think it already does a fair amount of optimisation, but I'm ...
  • Re: Graphic InterfaceBuilder for Java on Mac
    ... Is there some sort of InterfaceBuilder-type product that generates pure Java? ... The idea is to work directly with a graphical layout and get the precise ... output fields in the skeleton of a class definition as on the Mac, ... offerings are not available for the Mac. ...
  • Re: Currying the code
    ... Usually Maven is used for Java builds. ... That is, as long as your project follows a certain layout, you can use a very simple default pom.xml for building, reporting and documentation. ... In the end, your application is twice as big as nescessary, including libraries you never heard of and you have no idea, if you really need them or not. ... Signs that you shouldn't be a programmer. ...
  • Java Evolution
    ... multi-platform without any source or object code change. ... comes with a large number of libraries. ... where should Java go next? ... Style sheet layouts that can layout and label a given set of fields ...