Calculate String Width

Is it possible to calculate the width of a String in a certain font without needing a Graphics object? I need to calculate this before a component is displayed in order to adjust the sizes of the components. getGraphics() is returning null at this point.

Didn't my original post answer that question?
My control is being wrapped in a JScrollPane. I need to set the preferred size of the scroll pane based on the width of a String. If I try to do that during initialization before it is displayed, getGraphics() returns null so I get a NullPointerException.

Similar Messages

  • String width

    Hi
    Is there anyway to determine width and height(in pixels or whatever its possible) a String is? I dont want the number of characters in it, I want the "width" and the "height" of some given String with a particular font name,style and size???
    i tried using getStringWidth() in FontMetrics. its giving the width but its not considering the string value. i wanted to get the width for string width also considering the value of string.
    can i use getStringBounds(String str, Graphics context)???
    but what is this Graphics context??
    i wanted to use it in a core java pgm.not using any awt or swing etc???
    Does anyone know how to do this?
    help me out plz??

    can i use getStringBounds(String str, Graphics context)???
    but what is this Graphics context??The context is the graphics object to which you wish to draw this string. As strings sizes are done in a resolution independent format, the size in pixels changes depending on the resolution of the device. You would want a 12pt String to be about the same size if displayed either on 72dpi monitor, or a 300dpi printout.

  • How do I get a strings width w/o getFontMetrics()?

    Now that getFontMetrics() is deprecated - how am I supposed to get the width of a string? The FontMetrics class had a stringWidth() method.

    I dont have the API docs here so I cant give u the exact method names and classes but heres generally how you can do it: You have the Graphics object for the screen/whatever that you want to calculate the bounds for so do this
    Graphics2D g = ...
    FontRenderContext frc = g.getFontRenderContext();
    Font font = g.getFont();
    Rectangle2D bounds = font.getStringBounds("foo", frc);
    or something like that, and if you dont have the Graphics object you can always pass that part by calling the FontRenderContext constructor and passing some null values to it and so creating your own context that does some basic calculations correctly anyways.. Enuff for any font bounds anyway.

  • Calculate string CPI (length of string in pixel)

    Word-wrap position is at the moment done in SAP via length of string (count of letters) via function u201CRKD_WORD_WRAPu201D. But this is counting number of char, this give the problem that different font type and size give different word-wrap position ! -> We need to calculate if possible the word-wrap position via the relative length of text u2013 I tried to find some on SDN and Internet, the only thing I can find is some functionality in JAVA u2026
    Can any one help me how to calculate the length of a string using font type and hight of font... as we use truetype font as arial the length of letter "i" is not the same as 'X' ...
    Best regards Jørgen Jensen

    My problem is not to do the wordwrap, my problem is to find the right position as the length of 'i' is not the same length of 'X'
    example:
    iiiiiiiiii (10)
    XXXXXXXXXX(10)
    must be something like this:
    iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii(wordwrap position 35)
    XXXXXXXXXX(Wordwrap position 10)
    I need a way to find the length of a charactor in a given font and size.
    Best regards Jørgen Jensen

  • Class to calculate string length

    Hi All,
    is there any class having a method to calculate the string length.
    Thanks

    Hi Ravi,
    You can use the FM SWA_STRINGLENGTH_GET
    data: lv_length type SWAEXPDEF-ELEMLENGTH,
                     lv_string type string.
          CALL FUNCTION 'SWA_STRINGLENGTH_GET'
            EXPORTING
              expression                 =   lv_string
    *         CONDENSE_NO_GAPS           =
    *         CONDENSE                   =
    *         WITH_LEADING_BLANKS        =
    *       IMPORTING
             LENGTH                     = lv_length
    *         EX_MODIFY_EXPRESSION       =
    hope it helps you
    Regards!

  • String width in pixels

    Hi All,
    I'm making a small bar chart program that needs to print the bar values at the very end of the bar.
    Is there a way to determine the width of a string in pixels given it's font and length in characters?
    Basically, I'm trying to get the very last character of the value string to be right aligned with the bar itself without having it run off the edge or be too far towards the center of the bar.
    Also, I don't suppose there is a way to print strings leftward instead of rightward?? No no, of course not, I'm just being silly ;) right?
    Thanks for the help
    Marcos

    Anybody ever hear of StringBuffer???
    Fair enough and yes, yes I have thank you -though I feel it is often better for the newbie to see the process manually and if they study this kinfd of thing then they may learn to work stuff out for themselves when they need to implement their own algorithm.
    This - Snr whoIsFred - is what makes a programmer,
    - knowing how to manipulate your data types to make things work
    - it is not about knowing the API's off by heart (though that can help)
    - knowing how to read and utilise the java API docs is the real key
    I think what was posted therefore is moare beneficial than StringBuffer(aString).reverse()

  • String widths

    Hello all,
    Is it possible to get the width of a String? By this I mean that actual space that the String takes up not .length().
    The reason I need this is because I have a JPS that populates an HTML menu with 2 pieces of text on each row. To align the second piece of text properly I need to find out the width of the first piece and apply the neccessary spacing.
    Any ideas?

    Well, you can try and work with Font and FontRenderContext ...
    But you should consider the fact, that you can't really control which font a user specifies in its browser preferences. Therefore it is usually preferable to use HTML elements to do the spacing for you (e.g. with tables).

  • Function to calculate string

    Hi,
    I am looking for a function that you can insert: '5+(8*3)-2' and it will give you the value.
    something like a calculator function but for a text string.
    Did any of you guys have seen something like this before?
    thanks,
    Itay

    Hi,
    You have to do it dynamically, the input parameters are values (for example in your case
    ( 5, 8, 3, 2) operation (* + / -) are formulas...
    R001 = 5, R002 = 8, R003 = 3, R004 = 2
    1. Create parameter 100 char length.
    2. Get the formula from the user (for example  5+ ( 8 * 3 ) - 2 into the parameter field {like (R001 + (R002 * R003 ) - R004}
    3. Use Key word "SPLIT" amd move the values into a internal table (each value will be in a row...
    4. Now get the value of R001,R002,R003,R004  & operators....
    5. Create a progam dynamically (take the help of dynamic program)
    6. Create variables in the program (these variables should be created based on the values in SPLIT commanded used internal table.... with one addition variable for the RESULT, all the varibales declared should be of data type "F".
    7. use the   SYNTAX-CHECK FOR <program> to check the program syntax is correct.
    8. if subrc eq 0 then Submit the dynamic program
    9. WRITE the result....
    You will get the result...take the below code help
      DATA: BEGIN OF fm_split_formula OCCURS 0,
              text(10) TYPE c,
            END OF fm_split_formula,
            BEGIN OF fm_repo OCCURS 0,
              line(72),
            END OF fm_repo.
      DATA: fm_f_check(240),
            fm_h_check(72) ,
            fm_g_check TYPE  i,
            fm_offset1 TYPE i,
            fm_offset2 TYPE i,
            fm_subrc   LIKE sy-subrc,
            fm_mtext1.
      DATA: BEGIN OF fm_func,
              f1(7) VALUE 'STRLEN(',
              f2(7) VALUE 'SQRT(  ',
              f3(7) VALUE 'MOD    ',
              f4(7) VALUE 'DIV    ',
              f5(7) VALUE 'COS(   ',
              f6(7) VALUE 'SIN(   ',
              f7(7) VALUE 'LOG(   ',
              f8(7) VALUE 'EXP(   ',
            END OF fm_func.
      DATA: fm_loc_index LIKE sy-index,
            fm_repo_cnt TYPE i,
            fm_cnt_lp TYPE i,
            fm_name(10) VALUE 'FORMEL'.
      CONSTANTS:  fm_operand(8)  VALUE ' =()+-*/',
                  fm_numbers(12) VALUE ' 1234567890.',
                  fm_result(4)   VALUE 'R1 =',
    *- Start of insert for # DR1K900907 by Prabhu Rajesh
                  fm_result1(3)  VALUE 'R =',
    *- End of insert for # DR1K900907 by Prabhu Rajesh
                  fm_res(1)      VALUE 'R'.
      CLEAR : fm_split_formula, fm_repo,fm_repo_cnt.
      REFRESH: fm_split_formula, fm_repo.
      SPLIT fm_formula AT ' ' INTO TABLE fm_split_formula.
      LOOP AT fm_split_formula.
        IF NOT ( fm_split_formula-text = fm_func-f1 OR
                 fm_split_formula-text = fm_func-f2 OR
                 fm_split_formula-text = fm_func-f3 OR
                 fm_split_formula-text = fm_func-f4 OR
                 fm_split_formula-text = fm_func-f5 OR
                 fm_split_formula-text = fm_func-f6 OR
                 fm_split_formula-text = fm_func-f7 OR
                 fm_split_formula-text = fm_func-f8 OR
                 fm_split_formula-text CO fm_numbers OR
                 fm_split_formula-text CO fm_operand ).
          fm_repo = fm_split_formula-text.
          APPEND fm_repo.
        ENDIF.
      ENDLOOP.
    If the hint is useful… Say thanks by reward….
    Regards,
    Prabhu Rajesh

  • [Flex 4] calculate component width/height inline or with bindable function

    What I want to achive is something like these two examples (it doesn't work, it's just the idea):
    1) Inline
    <s:Group id="main" width="100%" height="100%" minWidth="950" minHeight="650">
         <s:Group width="100%" height="{if (main.height < main.minHeight){return (main.minHeight-footer.height;)} else {return (main.height-footer.height;)}}">
         </s:Group>
         <s:Group id="footer" width="100%" height="50">
         </s:Group>
    </s:Group>
    2) somehow define the calculation outside in a function maybe like this:
    [Bindable] (like this seems to work but the compiler throws error that there should be event name specified like this [Bindable(event="someEvent")], but then it doesn't work)
    public function calcHeight():Number{
         if (main.height < main.minHeight){
              return (main.minHeight-footer.height);
         } else {
              return (main.height-footer.height);
    <s:Group id="main" width="100%" height="100%" minWidth="950" minHeight="650">
         <s:Group width="100%" height="{calcHeight()}">
         </s:Group>
         <s:Group id="footer" width="100%" height="50">
         </s:Group>
    </s:Group>
    This should be something very simple... but I've been googling for this for 2 hours now and I couldn't find what I was looking for. Help please

    In order for the first option (inline) to work you might use short variant of if-else:
    height="{main.height &lt; main.minHeight ? main.minHeight - footer.height : main.height - footer.height}"
    Note the &lt; sequence: since MXML is just an XML file, < and > (and other symbols) have special meaning and must be escaped. But this is an ugly looking code and you should avoid that.
    Now to atchieve that you can use option 2: create a function. The reason it does not work for you is that to bind a function, you need a custom event. In your case you sould listen for propertyChange events on main.heigh, main.minHeight and footer.height properties or resize event on main and who knows what else. This is unnecessary and difficult.
    If my understanding of what you are trying to atchieve is correct, this should do the trick.
    <s:Group id="main" width="100%" height="100%" minWidth="950" minHeight="650">
       <s:layout>
          <s:VerticalLayout gap="0" horizontalAlign="justify"/>
       </s:layout>
       <s:Group height="100%">
       </s:Group>
       <s:Group id="footer" height="50">
       </s:Group>
    </s:Group>
    Or you could do it like this (I prefer this variant):
    <s:Group id="main" width="100%" height="100%" minWidth="950" minHeight="650">
       <s:Group width="100%" top="0" bottom="0">
       </s:Group>
       <s:Group id="footer" height="50" bottom="0" width="100%">
       </s:Group>
    </s:Group>
    As you can see, no data binding or listening to all sorts of events and dispatching custom ones is needed. Proper use of containers and layouts can save your day.
    Cheers,
    Michael
    P.S. You should really look at things in a simpler way somehow.

  • Panel doesn't repaint on time

    Dear Java Community--
    my current task is to develop a splash screen that can display messages, so that the user can see what happens during start up time.
    My solution is a JPanel with a background image and the text on it. I overwrote the panel's paintComponent(Graphics g) method and use the Graphics object to draw the image, and the text as well. I use Java version 4.1.2_07. So far so good. ;-)
    During startup time I have a dialog to popup that requests information from the user. The Splash stays in the back. After the dialog disappeared, my Splash should show up again and display some more messages.
    My problem:
    The dialog disappears but the Splash is not repainted immediately. The dialog leaves a big white area at the position it crossed the Splash. Also, the messages I add to the Splash are not beeing displayed. By the time the Slpash is repainted again (five or six seconds later), my application is up and running. That means, some of the messages (that were posted between dialog.hide() and application.show()) coudn't be delivert to the user at all.
    My Question:
    Do you have any suggestion what I could do to speed up my Splash and make it to repaint itself on time?
    Thank you so much in advance!!!
    Best regards,
    Patrick
    PS: Here's a part of the code:
         * we attach this panel to the content pane of this component
         * and overwrite the panel's paint method to display image, version and messages
        protected JPanel createPanel() {
            JPanel aPanel = new JPanel() {
                public void paintComponent(Graphics g) {
                    //be sure not to break something
                    super.paintComponent(g);
                    //draw image
                    _drawImage(g, image);
                    //draw version number
                    _drawVersionNumber(g, getVersion());
                    //draw messages
                    _drawMessages(g, messages);
            //set the same size as the surrounding window
            aPanel.setSize(getSize());
            //enable double buffering
            aPanel.setDoubleBuffered(true);
            //set transparent
            aPanel.setOpaque(false);
            return aPanel;
         * draws the defined image
         * @param g
         * @param image
        private void _drawImage(Graphics g, Image image) {
            if (image != null) {
                g.drawImage(image, 0, 0, this);
         * draws the given string in the lower right corner of the frame
         * @param g
         * @param version
        private void _drawVersionNumber(Graphics g, String version) {
            //draw version number
            g.setColor(getVersionColor());
            g.setFont(getVersionFont());
            //calculate string width
            FontMetrics fm = getFontMetrics(getVersionFont());
            int width = fm.stringWidth(version);
            //define position where to start
            int x = getWidth() - width - getPadding();
            int y = getHeight() - getPadding();
            //draw string
            g.drawString(version, x, y);
         * draws a list of messages (message by message) into the frame
         * @param g
         * @param messages - list strings to draw
        private void _drawMessages(Graphics g, java.util.List messages) {
            //set font
            g.setFont(getMessageFont());
            //calculate string height
            FontMetrics fm = getFontMetrics(getMessageFont());
            int fontHeigth = fm.getHeight();
            //draw messages
            int positionOffset = messages.size() - 1;
            for (int i = 0; i < Math.min(messages.size(), getMessageAmount()); i++) {
                Object message = messages.get(i);
                if (message != null) {
                    //set color for this message
                    Color c = getMessageColor();
                    int alpha = 255;
                    if (positionOffset == 1) {
                        alpha = 100;
                    } else if (positionOffset > 1) {
                        alpha = 50;
                    g.setColor(new Color(c.getRed(), c.getGreen(), c.getBlue(), alpha));
                    //define clip area for drawing
                    int clipWidth = getWidth() / 2;
                    g.setClip(0, 0, clipWidth, getHeight());
                    //draw message
                    g.drawString(message.toString(), getPadding(), getHeight() - getPadding() - fontHeigth * positionOffset);
                    //message longer than clip area? draw "..." after cutting the message
                    if (fm.stringWidth(message.toString()) > clipWidth) {
                        g.setClip(0, 0, getWidth(), getHeight());
                        g.drawString("...", clipWidth, getHeight() - getPadding() - fontHeigth * positionOffset);
                    //reduce offset for next message
                    positionOffset--;
        }

    The short answer is to use another thread. Everything in Swing runs on the Event
    Dispatch Thread so you must post your gui changes to the edt queue to get them
    shown. The Swing trail in the tutorial has a lesson on using threads and includes
    links to additional resources. Here's a demo that might give you some ideas.
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class Currency
        JTextArea textArea;
        public Currency()
            textArea = new JTextArea();
            JFrame f = new JFrame();
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.getContentPane().add(new JScrollPane(textArea));
            f.setSize(200,200);
            f.setLocation(100,100);
            f.setVisible(true);
            getUserInput(f);
        private void getUserInput(Frame f)
            // show splash screen used to keep user apprised
            // of our ongoing background activities
            final JWindow w = createSplashScreen(f);
            String s = "background work required...";
            final JTextArea ta = new JTextArea(s + "\n");
            w.add(ta);
            // forward gui update to event dispatch thread
            SwingUtilities.invokeLater(new Runnable()
                public void run()
                    w.setVisible(true);
            String[] options = {
                "option 1", "option 2", "option 2"
            // get user selection, this is modal
            final Object retVal = JOptionPane.showInputDialog(null,
                                              "select an option, press \"OK\"",
                                              "background work scheduler",
                                              JOptionPane.PLAIN_MESSAGE,
                                              null,
                                              options,
                                              options[0]);
            if(retVal == null)
                /* defensive action */;
            // forward to edt queue for real-time gui update
            SwingUtilities.invokeLater(new Runnable()
                public void run()
                    ta.setText((String)retVal + " chosen,\n\n" +
                               "background work starting..." + "\n");
            // now we can start the background activity
            startBackgroundWork(w, (String)retVal);
        private void startBackgroundWork(final JWindow splash, final String s)
            new Thread(new Runnable()
                public void run()
                    int taskLength = 8, count = 0;
                    while(count++ < taskLength)
                        textArea.append("count = " + count + "\n");
                        // if you had a JProgressBar in splash window
                        // you could update it from here...
                        // note gui is responsive to user during this
                        try
                            Thread.sleep(1000);
                        catch(InterruptedException ie)
                            System.err.println("interrupt: " + ie.getMessage());
                    splash.dispose();
                    textArea.setText(s + " loaded,\n\tready to go" + "\n");
            }).start();
        private JWindow createSplashScreen(Frame f)
            JWindow splash = new JWindow(f);
            splash.setSize(200,200);
            splash.setLocation(325,100);
            return splash;
        public static void main(String[] args)
            new Currency();
    }

  • How to calculate width of imported image

    I use the code below to layout 12 imported images. The code works fine as long as the images have a consistent width. However, the widths have now changed and my layout is screwed up. To solve the problem I'd like to change my layout formula to place images according to thier widths. However, my problem is that I cannot access the widths of the imported images. So my question is: How can I calculate the width of each imported image?
          for(var i:int=0; i<12;i++){
               imageLoader = new Loader();
               var url:String = "images/animal"+i+".png";
               var urlReq:URLRequest = new URLRequest(url);
               var sprite:Sprite=new Sprite;
               imageLoader.load(urlReq);
               imageLoader.x=70*i
               imageLoader.y=100
               sprite.addChild(imageLoader)
               addChild(sprite);

    Thanks. That makes sense. What type of event do I need for my event handler? If I use:
    imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,  imageLoaded);  
    Should I have:
    public function imageLoaded(e:Event):void {
       trace("Width="+e.contentLoaderInfo.??)

  • Find the width of a text string inside a text box?

    Hi,
    I have a text box with a long text string in it. I would like to know what the width of the text string is so that I can scroll it inside the textbox using the text box scrollviewer.
    var sv = this.foodieItemText.GetFirstDescendantOfType<ScrollViewer>();
    sv.ScrollToHorizontalOffsetWithAnimation(this.foodieItemText.Width, 20);
    The scrolling works fine but I don't know what value to use for the width offset in the first argument to ScrollToHorizontalOffsetWithAnimation. For my purposes I want it to scroll the full length of the text string (which is longer than the actual with of
    the text box). Any ideas?

    Hi duffybr,
    Yes, there is a ScrollViewer inside TextBox template and we could scroll to the specific position as we need, however there is no direct way to get the string width in TextBox, however we could get the width in TextBlock, by measure method.
    See this discussion for more information:
    http://stackoverflow.com/questions/9126076/how-can-i-calculate-the-width-of-a-string-in-metro-without-displaying-it
    Besides, there are some third party libraries help us get the String width.
    --James
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Can't change Text2D's String!

    Hey guys,
    I've got a 2D score board I'd like to update frequently (using 2D to save some FPS instead of Text3D) but I can't manage to change the String dynamicly: I can change the String to another String with the exact same with or less, but if less, the String is S T R E C H E D across the original 3D plane in an ugly way. I tried creating a new TexT2D bigger than what I needed and then set a shorter String in it, same stretching problem...
    Has anyone resolved this? What's the point of having a setString method if you can only set Strings which are the exact same width?! Btw, Text3D automatically handles the change since we're dealing with completly different geometries everytime. Maybe I have to manually setGeometry of the next String to match that String's width? If so, how do I calculate that width?
    Thanks!
    Btw, here's the code I use to get the proper capabilities and get rid of the 3 billion error messages I got!
    highScoreNbr = new Text2D(Long.toString(highScore), COLOR_WHITE, FONT_NAME, FONT_SIZE, FONT_STYLE);
    highScoreNbr.setCapability(Text2D.ALLOW_APPEARANCE_READ);
    highScoreNbr.setCapability(Text2D.ALLOW_APPEARANCE_WRITE);
    highScoreNbr.getAppearance().setCapability(Appearance.ALLOW_TEXTURE_READ);
    highScoreNbr.getAppearance().setCapability(Appearance.ALLOW_TEXTURE_WRITE);
    highScoreNbr.getAppearance().getTexture().setCapability(Texture.ALLOW_IMAGE_READ);
    highScoreNbr.getAppearance().getTexture().setCapability(Texture.ALLOW_IMAGE_WRITE);

    Hi,
    there's a bug in java3d 1.3:
    http://developer.java.sun.com/developer/bugParade/bugs/4809249.html
    My workaround: download java3d 1.2x (SDK) and extract the sourcecode for class Text2D. Then rewrite the code (rename the class) to a new class like MyText2D and use it instead of Text2D.
    Regards,
    Oliver

  • Measuring string bounds in headless mode on a server?

    I have a problem with calculating screen string width for the browser client.
    I'm outputting a stream of content type application/vnd.ms-excel and sending back an XML spreadsheet. (No complaints about using Mc$oft products, it's what's needed!)
    Excel does not autosize columns which contain string data, so the text columns are the standard Excel width, and the text is wrapped onto about 7 lines. See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnexcl2k2/html/odc_xmlss.asp for details of the XML format.
    Excel does allow you to specify the with of a column in points, so I was using the awt Font classes to calculate the string bounds in pixels. I explicitly set the resolution to be used to 72dpi by creating a FontRenderContext with an AffineTransform with a scaling factor of (1.0, 1.0), so that asking the pixel width, gets the point width.
    This worked fine testing it on my windoze machine, but on the Unix server, it's obviously running in headless mode, and anyway, it doesn't have the Arial font which I'm specifying in my spreadsheet as the font to use.
    Is there any way of calculating the width of a string in points knowing its font and the point size of the font? You shouldn't need a graphcs environment, just the font information. I have all the .TTF files, I could copy them to the Unix machine if Java could use them and do the calculation.
    I hate leaving the user interface looking so shoddy with wrong sized columns!
    It SHOULD have worked in a headless environment according to http://java.sun.com/j2se/1.4.2/docs/guide/awt/AWTChanges.html#headless and we are on version 1.4.2_01. It actually blew up in awt code:
    java.lang.NoClassDefFoundError
         at java.lang.Class.forName0(Native Method)
         at java.lang.Class.forName(Class.java:141)
         at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:62)
         at java.awt.Font.initializeFont(Font.java:308)
         at java.awt.Font.<init>(Font.java:344)That's when I'm trying to instantiate a new Font("Arial", Font.PLAIN, 10);I've looked at the FOP project wondering whether that has a solution but it's a huge, confusing thing. There must be a way. Can anyone help?

    When you say "unix doesn't have Arial" you obviously aren't using Solaris where Arial most certainly
    ships and is in fact the main font used to support dialog & sanserif.
    There are numerous APIs to calculate the width of a string in pixels, depending on whether
    you want the integer metrics, fp metrics , logical bounds, pixel bounds (which guarantees to enclose
    every pixel if you correctly specify the graphics/FRC)
    Every single one of these works in headless mode.
    Even the most simple-minded FontMetrics.stringWidth(String) call should be good enough
    for your requirements.
    The error you show looks like you have a misconfigured environment.. It can't find
    the correct implementation class of GraphicsEnvironment which is nothing to do with
    fonts. Moreover this DOES work for me :
    import java.awt.*;
    public class Arial {
    public static void main(String args[]) {
    Font arial = new Font("Arial", Font.PLAIN, 10);
    System.out.println(arial);
    % java -version
    java version "1.4.2_01"
    Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06)
    Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode)
    % java -Djava.awt.headless=true Arial
    java.awt.Font[family=Arial,name=Arial,style=plain,size=10]
    QED.
    -Phil.

  • TableView auto resize columns based on header text width or cell content

    Is there a method on the tableview or tablecolumn to automatically resize based on the content of the hearder or data?
    If not what approach can used used with JavaFX to calculate the string width based on the current font?

    The table column size is inconsistent, I set the columns in the table view and the items in the initialize method. I execute a service and task from a button action that loads data into the list, if I don't reset the columns in the table view in the succeed method then each column is the same width regardless of the content in the cells. If I do reset the table columns in the succeed method then the columns are resized based on content.
    I don't think it should be a requirement to reset the columns just to get the column widths to set based on the content in the cells. Is there a method on the table column or view that will resize the cells based on the cell content? I would prefer the largest value; column header content or the longest cell content for a column.

Maybe you are looking for

  • Itunes problems with Windows Vista

    itunes is somehow conflicting with new Windows Vista Computer causing it to lose all of my cd/dvd and usb devices and also errors when opening stating registry issues HELP!!!!!

  • How to avoid Flickaring  When Adding data in Addon User Matrix

    Experts, I am  Adding Query Result in User Matrix  one by one. but there is lots of Flicker. how to Avoid this Flickering. Bomiitems = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)                                 If Bomtyp = "U" An

  • Audio oddities on MacBook after sleep

    Here's the deal: I had 4 tracks of dialog I was working on for an animated movie. Each track had different fx settings. After doing some editing and such I saved the project, and put the MacBook to sleep to go on to something else. When I returned la

  • GRC AC 5.3 LDAP issue

    Hi All, Our GRC AC5.3 and EP 7.0 are both existing in the same SID. The EP has the data source as LDAP and the ume is populated with users from ldap. But when the ldap connector and ldap field mapping are done in grc, the user info from ldap is not g

  • Writing a Java Web Browser

    I'm trying to write a simple Java based browser. Can anyone please help me with this code. I can't get it to load the URL please help import java.awt.event.*; import java.awt.*; import java.io.*; import java.net.*; import javax.swing.*; import javax.