Standalone multi-line JLabel vertical alignment

I have a JLabel subclass that I am using an a Servlet environment, with iText to create a PDF. When I set the vertical alignment to CENTER, the vertical spacing is not correct and the label runs off the bottom of its allocated area. The JLabel is not attached to any Container, it is simply a standalone JLabel with no parent.
I've done a little digging/debugging and it appears that the View (a javax.swing.plaf.basic.BasicHTML$Renderer) is returning the height of a single line of text from getPreferredSpan(View.Y_AXIS), even though when painted, the label spans several lines. This causes SwingUtilities.layoutCompoundLabel to calculate the wrong starting Y value for the text area.
When I use this JLabel subclass in a GUI/Swing program that I have, added to a JPanel, it works correctly.
Looking for any clues or suggestions.

Partial answer:
I noticed that in the GUI environment, that the paint() method was being called twice. The first time through, the height of the text was calculated as I described above in the standalone environment - for only a single line of text. The second time through, it calculated the height correctly.
I changed my subclass to call super.paint(g) (with a dummy Graphics) if there is no parent. This "fixes" the problem in the standalone environment.
I theorise that it takes 2 passes through the size calculations in the View - once to set the width and again to set the height. Any further insights are welcome.

Similar Messages

  • Solution to JLabel Vertical Alignment Issue

    I spent the last hour messing with all the alignment properties on a JLabel. None seemed to get rid of the small gap above the text in the JLabel. So here is what does work:
    JLabel label = new JLabel();
    label.setBorder(BorderFactory.createEmptyBorder(-2, 0, 0, 0));
    You can make the negative number higher to move the text further up.
    Hopefully this saves someone else some time.
    Dan

    I spent the last hour messing with all the alignment properties on a JLabel. None seemed to get rid of the small gap above the text in the JLabel. So here is what does work:
    JLabel label = new JLabel();
    label.setBorder(BorderFactory.createEmptyBorder(-2, 0, 0, 0));
    You can make the negative number higher to move the text further up.
    Hopefully this saves someone else some time.
    Dan

  • Vertical Alignment in table columns

    Using JHeadstart 10.1.3.4.
    Different display types are differently positioned in table columns. Single text seems vertically centered; text fields with multiple lines are vertically aligned at the top of a table column; vertical radio buttons are vertically aligned at the bottom of a table column. The resulting display is quite messy.
    I have not found any formating option in JHeadStart that allows for controlling vertical alignment. Am I a missing something?
    If JHeadStart 10g does not support controlling vertical alignment directly, how should this be handled? Does JHeadStart 11g add such vertical alignment support?

    Hello,
    If you need anything special considering vertical alignment in tables, you can simply perform that in the resulting JSPX page. In other words, just alter the JSPX file to whatever you need.
    Save your customizations in JHeadstart using velocity templates, so your page is regenerateable while keeping your changes. See the JHeadstart Developers Guide on how to change such customizations in the templates.
    Also in release 11 there is no vertical alignment (yet); I suppose because for most tables, each row just has a single line and vertical alignment is therefore not needed. However, I have put it on the wish-list, so we will check on it later. Thanks!
    Regards,
    Evert-Jan de Bruin
    JHeadstart Team

  • How to vertically align Prompts on the same line in OBIEE

    Can we vertically align "Product Line (Owned)" and "Product Line(Not Owned)" in this Prompt on same vertical line?
    so that "Product Line(Owned)" can start from the same vertical line where "Product Line(Not Owned)" starts
    we tried few options by adding a text element in dashboard and playing with td.GFPFilter
    but couldn't find a solution to it.
    we were looking into this thread
    Dashboard Prompt Alignment
    Currently we have it like this, alignment is not same due to "Not Owned" text being longer than "Owned" text
    "Product Pillar (Owned)"--------------"Product Line (Owned)"---------------------"Product (Owned)"
    "Product Pillar (Not Owned)"--------------"Product Line (Not Owned)"---------------"Product (Not Owned)"
    we want to have it like this,
    "Product Pillar (Owned)"--------------"Product Line (Owned)"-------------"Product (Owned)"
    "Product Pillar (Not Owned)"---------"Product Line (Not Owned)"--------"Product (Not Owned)"

    Hi Rupak,
    I just tried it and it the solution is pretty easy. Just add a text-box to your dashboard holding the following:
    <style>td.GFPFilter {width: 200px}</style>You need to check "Contains HTML markup"
    Regards,
    Stijn

  • Alignment of multi-line text field in PDF form

    I am trying to create a simple form with text fields and check boxes. In several of my text fields I would like the user to enter multiple lines of text aligned at the top-left of the textbox. Everything appears proper until I check the "Multi-line" option within the properties menu. The text then jumps down the textbox several lines. In the attached image I have selected multi-line for the "Responsibilities:" and "Objectives:" fields but not the three following. I am using Acrobat Pro 9 to develop the form. Any help is greatly appreciated.

    Thanks for your reply. The entered text then shifts down the textbox (as shown).

  • How do I center a text field when input can be single or multi-line?

    I'm creating a form in Adobe Acrobat Pro XI and have almost everything the way I want it.  One of my last problems is trying to get a text in a text field centered.  The input is sometimes a single line and sometimes multi-line.  If I set it up so the multi-line entries are centered, then the single line looks off ... and vice versa.  Is there any way to have the text automatically centered in the text field regardless of whether it's single or multi-line?

    Unfortunately, there's no way to set up a field so that the text is guaranteed to be vertically centered in both cases. If you set it up so that rich text formatting is enabled, it's possible for a user to vertically center, but it's not something you can preconfigure so that it will remain in effect when the field is cleared. For a user to do this, with the focus set to the field they'd have to display the Properties toolbar (Ctrl+E), click the "More..." > Paragraph > Alignment > Text Middle [button]

  • Vertical alignment in text form

    Been trying set vertical alignment so that text will align with the top of the form box, and having a frustrating result. It will only align if the box is one line only.
    A multi-line box will not expand vertically to accomodate long text; an expanded (vertically) box will result in text beginning below top alignment. Anyone working on a fix for this? It seems to be a new problem, as I have used this feature with in the past with old versions of Acrobat.

    If I understand your issue correctly, you can achieve this by playing witht the Left and Right values under Layout tab of the object properties.
    Let me know if this is not what youare looking for..
    Thanks
    Srini

  • Vertical alignment is middle regardless of setting

    Running LiveCycle Designer ES 8.2 and Adobe Acrobat Pro 9 on Windows 7.
    I'm designing a form with many text fields.  Most of them work great.  However, I several text fields--some standalone, some table cells--where the vertical alignment of the user-entered value always shows as middle. 
    For example, this text field has the vertical alignment set to bottom, using the paragraph pallette:
    This is the same field with the alignment set to top:
    And this is the same field again, with the alignment set to middle:
    You will notice that they all look the same--always middle.  I'm able to set the caption alignment fine, and I'm aware of the way to distinguish between adjusting the caption and value properties in the paragraph pallette. 
    I can't determine any pattern as to why some of my text fields align fine according to the settings I specify, and some of them are always, always middle-aligned. 
    Are there any other settings or conditions which may be overriding my alignment settings for these specific fields? 
    It first started happening with table cells, so I assumed some table setting was causing the problem (although I never found it). Once standalone text fields started doing it too, though, I was extra stumped. 
    I am able to adjust all the horitzonal alignment settings fine.  I have tried deleting the offending cells and starting from scratch, but it hasn't helped.
    Any suggestions or help would be appreciated!
    Thanks,
    Marybeth

    This seems odd, but you need to also set the property JAVASE_DB_INTERACTION to false.
    <p>
    propertiesMap.put(EntityManagerFactoryProvider.JAVASE_DB_INTERACTION, "false");
    <p>---
    <br>James Sutherland
    <br>Oracle TopLink, EclipseLink
    <br>Wiki: Java Persistence, EclipseLink

  • Vertical align to center in a div

    Hi,
    I'm putting together a css layout in dreamweaver CS3, i have a basic nav bar with a solid black colour with text on top. I'm trying to vertical align the text to the center, currently it's center horizontally, but the text is right at the top of the div. The only way i've been able to change the position is to use "line height"
    Any there any easy way to do this in css?
    Any help is much appreciated, thanks.

    Hi again,
    I'm having a bit of trouble trying to get my main text area vertically center on one of my pages, i have a two column layout(text area on the right). The above methods don't seem to work, they just seem expand my whole bodyArea downwards.
    Currently my codes look like this:
    Layout:
    <style type="text/css">
    <!--
    body {
         background-color: #666666;
    #wrapper #bodyArea #left {
         background-image: url(images/picture.jpg);
         float: left;
         background-repeat: no-repeat
    -->
    </style></head>
    <body>
    <div id="wrapper">
      <div id="logo"></div>
      <div id="nav"><a href= nav text here </a></div>
      <div id="bodyArea">
        <div id="left"></div>
        <div id="shadow"></div>
        <div id="right">text with paragraphs here</div>
        <div id="footer">copyright info here</div>
      </div>
    </div>
    </body>
    </html>
    stylesheet:
    #wrapper {
         width: 781px;
         margin-right: auto;
         margin-left: auto;
            height: 699px;
    #wrapper #logo {
         height: 116px;
            background-image: url(../images/logo.jpg);
    #wrapper #nav {
         height: 38px;
         text-align: center;
         color: #FFFFFF;
         font-family: "Courier New", Courier, monospace;
         font-size: 19px;
         line-height: 38px;
         background-repeat: no-repeat;
         background-color: #000000;
         margin: 0px;
    #wrapper #bodyArea #left {
         width: 341px;
         float: left;
         height: 507px;
    #wrapper #bodyArea #right {
         width: 440px;
         float: right;
         height: 507px;
         text-align: center;
         color: #000000;
         vertical-align: middle;
         font-family: Arial, Helvetica, sans-serif;
         font-size: 16px;
    #wrapper #bodyArea #right #shadow {
         height: 14px;
         background-image: url(../images/shadow.gif);
         background-repeat: repeat-x;
    #wrapper #bodyArea #footer {
         height: 38px;
         clear: both;
         text-align: center;
         color: #FFFFFF;
         background-color: #000000;
         font-family: Arial, Helvetica, sans-serif;
         font-size: 15px;
         line-height: 38px;
         margin: 0px;
    p {
         margin-top: 0px;
         margin-right: 10px;
         margin-bottom: 15px;
         margin-left: 10px;
    I'm fairly new to CSS layouts, if anyone could help me it would be much appreciated, thanks.

  • Vertical alignment off in table columns

    I have a table with 3 columns with one row above and below
    Text in left and right column is aligned to the top but in
    the middle column the text will not align to the top. In IE it is
    correct but in Firefox 1.6 it is down by 1 line
    How to correct?
    David
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01
    Transitional//EN" "
    http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
    <HTML
    xmlns="
    http://www.w3.org/1999/xhtml"><HEAD><TITLE>BustedComputer</TITLE>
    <META http-equiv=Content-Type content="text/html;
    charset=iso-8859-1" />
    <style type="text/css">
    <!--
    body {
    font-family: Verdana, Arial, Helvetica, sans-serif;
    font-size: 11pt;
    color: #000000;
    margin-left: 0px;
    margin-top: 0px;
    table, td
    border-color: #000000;
    border-style: solid;
    table
    border-width: 0 0 1px 1px;
    border-spacing: 0;
    border-collapse: collapse;
    td
    margin: 0;
    padding: 10px;
    border-width: 1px 1px 0 0;
    vertical-align: top;
    a:link { color: blue; text-decoration: none }
    a:active { color: blue; text-decoration: none }
    a:visited { color: #0000FF; text-decoration: none }
    a:hover { color: blue; background-color:#FFFF9D;
    text-decoration: underline }
    -->
    </style>
    </HEAD>
    <BODY>
    <TABLE cellSpacing=0 cellPadding=0 width=800 align=center
    border=0>
    <TBODY>
    <TR>
    <TD colSpan=3 bgcolor="#6699FF">Top</TD>
    </TR>
    <TR>
    <TD width="150" bgcolor="#6699FF"><a
    href="#">leftside</a></TD>
    <TD bgcolor="#FFFFCC"><p>Contrary to popular
    belief, Lorem Ipsum is not simply
    random text. It has roots in a piece of classical Latin
    literature from
    45 BC, making it over 2000 years old.<br>
    <br>
    Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de
    Finibus
    Bonorum et Malorum" (The Extremes of Good and Evil) by
    Cicero, written
    in 45 BC. This book is a treatise on the theory of ethics,
    very popular
    during the Renaissance. The first line of Lorem Ipsum,
    "Lorem ipsum dolor
    sit amet..", comes from a line in section 1.10.32.</p>
    </TD>
    <TD width="150" bgcolor="#FFFFCC">rightside</TD>
    </TR>
    <TR>
    <TD colSpan=3 bgcolor="#6699FF">Bottom</TD>
    </TR></TBODY></TABLE></BODY></HTML>

    Could it be that you are seeing the top margin on the
    <p> tag?
    <TD bgcolor="#FFFFCC"><p>Contrary to popular
    belief
    Murray --- ICQ 71997575
    Adobe Community Expert
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    http://www.dreamweavermx-templates.com
    - Template Triage!
    http://www.projectseven.com/go
    - DW FAQs, Tutorials & Resources
    http://www.dwfaq.com - DW FAQs,
    Tutorials & Resources
    http://www.macromedia.com/support/search/
    - Macromedia (MM) Technotes
    ==================
    "davidhelp" <[email protected]> wrote in
    message
    news:[email protected]...
    >I have a table with 3 columns with one row above and
    below
    > Text in left and right column is aligned to the top but
    in the middle
    > column
    > the text will not align to the top. In IE it is correct
    but in Firefox 1.6
    > it
    > is down by 1 line
    >
    > How to correct?
    >
    > David
    >
    > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01
    Transitional//EN"
    > "
    http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
    > <HTML
    > xmlns="
    http://www.w3.org/1999/xhtml"><HEAD><TITLE>BustedComputer</TITLE>
    > <META http-equiv=Content-Type content="text/html;
    charset=iso-8859-1" />
    > <style type="text/css">
    > <!--
    > body {
    > font-family: Verdana, Arial, Helvetica, sans-serif;
    > font-size: 11pt;
    > color: #000000;
    > margin-left: 0px;
    > margin-top: 0px;
    >
    > }
    > table, td
    > {
    > border-color: #000000;
    > border-style: solid;
    > }
    > table
    > {
    > border-width: 0 0 1px 1px;
    > border-spacing: 0;
    > border-collapse: collapse;
    > }
    > td
    > {
    > margin: 0;
    > padding: 10px;
    > border-width: 1px 1px 0 0;
    > vertical-align: top;
    > }
    > a:link { color: blue; text-decoration: none }
    > a:active { color: blue; text-decoration: none }
    > a:visited { color: #0000FF; text-decoration: none }
    > a:hover { color: blue; background-color:#FFFF9D;
    text-decoration:
    > underline }
    >
    > -->
    > </style>
    > </HEAD>
    > <BODY>
    > <TABLE cellSpacing=0 cellPadding=0 width=800
    align=center border=0>
    > <TBODY>
    > <TR>
    > <TD colSpan=3 bgcolor="#6699FF">Top</TD>
    > </TR>
    > <TR>
    > <TD width="150" bgcolor="#6699FF"><a
    href="#">leftside</a></TD>
    > <TD bgcolor="#FFFFCC"><p>Contrary to popular
    belief, Lorem Ipsum is
    > not
    > simply
    > random text. It has roots in a piece of classical Latin
    literature
    > from
    > 45 BC, making it over 2000 years old.<br>
    > <br>
    > Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of
    "de Finibus
    > Bonorum et Malorum" (The Extremes of Good and Evil) by
    Cicero,
    > written
    > in 45 BC. This book is a treatise on the theory of
    ethics, very
    > popular
    > during the Renaissance. The first line of Lorem Ipsum,
    "Lorem
    > ipsum
    > dolor
    > sit amet..", comes from a line in section
    1.10.32.</p>
    > </TD>
    > <TD width="150"
    bgcolor="#FFFFCC">rightside</TD>
    > </TR>
    > <TR>
    > <TD colSpan=3 bgcolor="#6699FF">Bottom</TD>
    >
    </TR></TBODY></TABLE></BODY></HTML>
    >
    >

  • Vertically align middle input text in a text box

    I'm creating Flash-based software that has text boxes where users write in the answers to questions. I want the text that the user types to be vertically aligned to the middle of the text box, so that even if the response is two or three lines, it is still centered in the box.
    It doesn't appear that I can accomplish this through the properties window in Flash. Am I missing something? Or is it possible to set the properties of the text box with actionscript, and would that allow me to vertically align the text?
    Thanks!

    You're not the first to ask this, but if you got an answer of how to do it, you'd likely be the first.  I don't think it is possible since there doesn't appear to be any sort of top margin property available for TextFields.  You might be able to fake something like that though if you think about it... like using the changed event of a textfield to reposition it vertically in a pseudo border/bkgnd.
    If you do come up with a solution, you should share it here... as I said, you're not the first to ask.

  • Keynote on Ipad warning: custom and mixed lists may look different... bulleted list have bullet vertical alignment "issues" any fixes?

    Help.
    I am working on a high-end Keynote presentation. It was originally a poerpoint file, that I opened in keynote. So far so good. I applied keynote themes, and used bullets etc, looks great on the mac. Move it to the ipad, and the top bullet looks fine, all 1st level bullets below it have a higher vertical alignment, which no longer in alignment with the text. What am I doing to cause this? all spacing etc, is exactly the same.
    anybody know a tip or trick to keep this from happening?

    I answered my own question... with many, many tests.
    I FINALLY figured out what the common feature was, that was causing the misalignment of the bullets.
    Line spacing.
    If you apply line spacing BEFORE a paragraph, it misaligns the bullets... which is WHY it wasn't happening to the 1st bullet in each text box, but only those following....
    In the final test I changed the line spacing attribute to AFTER a paragraph, and VOILA! no more misaligned bullets.
    It's definitely a bug in the software, since either way it looks fine on the mac, and is only a problem on the iPad.
    hope that saves someone else some valuable time!!!

  • Displaying Multi Line Text

    Hi,
    I am having issues in displaying multi line text on a Text Item. Basically there is data in the database column DetailText which is stored like this with carriage returns :
    If I look at the column in Toad it is formatted with all the carriage returns correctly eg.
    Hello
    World
    When I display this in my StaticStyled Item it displays like "Hello World" in one line. I want to be able to display it as it is with the carriage return on 2 seperate lines.
    I have looked in this forum and one search 2 places and one suggestion was to use RawText Item type. I have tried changing the Item Type to Raw Text and FormattedText but it doesn't make any difference. The lines are still displayed horizontally instead of vertically. Another place I saw was to use OAHTMLWebBean but doesn't show how I can do this.
    This should be simple enough but I have searched the DevGuide and this forum and couldn't figure out the solution. Any help would be appreciated.
    Thanks

    Hi,
    I tried to do it in different way. What i did is I have created a item of type formattted text and set its text like:--
    <html>User authentication failed. <br*> Cause: Invalid password.</html> --remove *
    So I am able to see the prompt like :-
    User authentication failed.
    Cause: Invalid password.
    Hope this helps you...
    Thanks
    --Anil                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • BO XIR2 SP3 FP3.3 - vertical alignment of 1st column of 2nd page ignored

    We have webi reports that have all cells set to vertical alignment bottom. If the report spans more than one page, the first column of the second page reverts to vertical alignment center for all cells in the column. All other columns remain with bottom vertical alignment. This problem does not occur in PDF view, only in HTML views. Does anyone know if there is a fix for this? Can I modify a file somewhere in the system to fix a missing vertical alignment tag?
    Joe Gottschall
    Pixstar, Inc.

    Yes, there is "sort-of":
    Object > Text Frame Options ( Ctrl + B )
    Vertical Justification, set Align to "Justify".
    It won't distribute evenly across all three columns though... in other words InDesign doesn't balance the text across the three columns with this feature.
    Instead it pushes space between lines/paragraphs within each column to ensure the top and bottom line of text in each column are lined up with top and bottom of text frame.
    If there is only a little bit of text in the last column, things might not look like you anticipated.

  • Multi-line toggle button bar labels?

    I am trying to do a grid of buttons where only one button in a row can be "pressed".  Seems, based on suggestions here as well, the easiest way is one togglebuttonbar per row of a grid.
    Anyway, I need to have taller buttons with a few lines of text in each label (button).  Think of a table where the cells are selectable.
    I found a way to extend a simple button's label to make it multi-line, but not sure on how to do this for a togglebuttonbar:
    package tools
    import flash.text.TextFieldAutoSize;
    import mx.controls.Button;
    import mx.core.mx_internal;
    use namespace mx_internal;
    public class MultilineButton extends Button {
    public function MultilineButton()
    {super();}
    override protected function createChildren():void
    super.createChildren();
    textField.multiline = true;
    textField.wordWrap = true;
    textField.autoSize = TextFieldAutoSize.LEFT;
    override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void {
    super.updateDisplayList(unscaledWidth, unscaledHeight);
    textField.y = (this.height-textField.height)>>1;
    And then I call it with <t:MultilineButton label="four score and seven years ago" width="150" height="150" textAlign="left"/>
    Should I just use this single button in a Repeater?  Or is there a way to work with the togglebuttonbar?

    I tried that, I guess I am doing it wrong since it is still doing centered
    and bold:
    package tools
    import flash.text.*;
    import mx.core.mx_internal;
    use namespace mx_internal;
    public class MultilineToggleButtonBar extends ToggleButtonBar
    public function MultilineToggleButtonBar()
    super();
    override protected function createChildren():void
    super.createChildren();
    textField.multiline = true;
    textField.wordWrap = true;
    textField.autoSize = TextFieldAutoSize.LEFT;
    var format:TextFormat = new TextFormat();
    format.bold = false;
    format.align = "left";
    textField.defaultTextFormat = format;
    override protected function updateDisplayList(unscaledWidth:Number,
    unscaledHeight:Number):void {
    super.updateDisplayList(unscaledWidth, unscaledHeight);
    textField.y = (this.height-textField.height)>>1;

Maybe you are looking for