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
http://uio.imagero.com Unified I/O for Java
http://reader.imagero.com Java image reader
http://jgui.imagero.com 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 ...
    (comp.programming)
  • 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 ...
    (microsoft.public.dotnet.general)
  • 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. ...
    (comp.lang.java.softwaretools)
  • 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 ...
    (comp.lang.java.advocacy)
  • Re: field name for jOptionPane when using Eclipse?
    ... > I'd rather deal with any problems which come up than try to deal with java ... You should know, though, that use of layout managers ... actually easier to build Java GUIs by hand rather than use a visual GUI ... The reason is that layout managers actually give you a much ...
    (comp.lang.java.programmer)