TitledBorder Text is Truncated

Hello all,
This must be a common problem.
Here's a simple version of the problem: I have a JPanel using a FlowLayout. Within the JPanel I have a JLabel whose text is a single character in length. When I place a TitledBorder around the JPanel, the border's text is truncated because the FlowLayout layout manager does not consider the border text when it gets the size of the JPanel. Please see the sample code below.
Is there a way to make sure the border's title is taken into account by the layout manager?
Yes, I know I can get the size of the border's text, convert it to pixels, override the panel's getPreferredSize() method, etc. but that's so ugly.
import java.awt.*;
import javax.swing.*;
public class Tester2 {
  public static void main(String[] args) {
      JFrame f = new JFrame();
      f.getContentPane().setLayout(new FlowLayout());
      JPanel panel = new JPanel();
      panel.setBackground(Color.pink);
      panel.add(new JLabel("X"));
      panel.setBorder(BorderFactory.createTitledBorder("Long TitledBorder Text"));
      f.getContentPane().add(panel);
      f.pack();
      f.setVisible(true);
}

I think I know the answer to my own question....
First, let me say I think this is a Swing bug (perhaps a FlowLayout bug) because the preferred size of the panel does take into account the border's height when using a TitledBorder but not the width. The preferred size of a component should take into account both the height and width of a border (if one is in use). If you run the sample program you'll see the preferred height certainly does take the border's height into account but not the width.
Second, there is a method in javax.swing.border.TitledBorder:
getMinimumSize(Component c)
This method allows a workaround for the truncation of the border's text. I simple set the panel's preferred width to that returned by getMinimumSize() and I'm good to go.
I'm not 100% sure about all this, I'll investigate more tomorrow and post a bug w/Sun if warranted.
Any comments or suggestions are still very welcome, of course.
Hello all,
This must be a common problem.
Here's a simple version of the problem: I have a
JPanel using a FlowLayout. Within the JPanel I have a
JLabel whose text is a single character in length.
When I place a TitledBorder around the JPanel, the
border's text is truncated because the FlowLayout
layout manager does not consider the border text when
it gets the size of the JPanel. Please see the sample
code below.
Is there a way to make sure the border's title is
taken into account by the layout manager?
Yes, I know I can get the size of the border's text,
convert it to pixels, override the panel's
getPreferredSize() method, etc. but that's so ugly.
import java.awt.*;
import javax.swing.*;
public class Tester2 {
public static void main(String[] args) {
JFrame f = new JFrame();
f.getContentPane().setLayout(new FlowLayout());
JPanel panel = new JPanel();
panel.setBackground(Color.pink);
panel.add(new JLabel("X"));
panel.setBorder(BorderFactory.createTitledBorder("Long
TitledBorder Text"));
f.getContentPane().add(panel);
f.pack();
f.setVisible(true);

Similar Messages

  • SSIS Error Text was truncated or one or more characters had no match in the target code page

    I the same issue or something close.
    Except I have one Field (27) that get a trunacation error
    Error:
    Data conversion failed. The data conversion for column "Column 27" returned status value 4 and status text "Text was truncated or one or more characters had no match in the target code page.".
    The "output column "Column 27" (91)" failed because truncation occurred, and the truncation row disposition on "output column "Column 27" (91)" specifies failure on truncation. A truncation error occurred on the specified object of the specified component.
    Data looks like:Red Text is the field that is throwing the error!
    00000412,
    0000000011411001,
    0273508793,
    01,
    "RUTH           ",
    "EDWARDS             ",
    19500415,20080401,
    "N",
    04488013,
    "1",
    "F",
    365094,
    20080401,
    000472162716,
    "1447203880    ",
    43995202341210,
    00120.000,
    0010,
    00008.26,
    00004.96,
    000.00,
    00002.70,
    00007.66,
    0,
    "PROMETH/COD  SYP 6.25-10 ",
    "Y",
    "Promethazine w/ Codeine Syrup 6.25-10 MG/5ML               ",
    0000,
    "001C",
    610020,"WELLP1537",
    "O",
    "N",
    00,
    "D",
    "S",
    "G",
    "ID01V012008782",
    "TOM AHL CHRYSLER              ",
    "M",
    "M",
    "PBD $20/10+40%/20%            ",
    00008.26,
    "1184641367"

    I have found four things that I always check when I run into this problem.  I have yet to find a time when one of these didn't work (specifically helps when reading data from flat files but I suppose most of the four would apply to any source).  Check out my blog post, content repeated below:
    1.  Make sure to properly configure the "Flat File Source".  When setting the connection properties to the flat file, take time to click on the advanced tab and ensure that the" Name", "DataType", and "OutputColumnWidth" properties are set properly.  I have found that if this is setup correctly when the initial connection is created, some if not all of the data type issues and errors can be alleviated.  The "Flat File Connection Manager Editor" can be accessed while initially creating the connection or by double clicking on a flat file connection within the "Connection Managers" for connections that have previously been created. 
    2.  Depending on the order and steps that were used to create the connection to the flat file, sometimes the data types need to be updated in an additional area.  This can be found by right clicking on the "Flat File Source" and selecting "Show Advanced Editor...".  Once in the advanced editor, click on the "Input and Output Properties" tab.  Expand the "External Columns" folder.  For each field being loaded from the flat file there are some configurable properties.  Make sure that the "DataType" field is properly set for each field.
    3.  Something else that can be done if you are sure that the data type is set correctly in both of the two previously mentioned locations is to set the "Flat File Source" to essentially ignore those annoying truncation errors.  On the same "Input and Output Properties" tab, expand the "Output Columns" folder.  For those fields listed, there is a "TruncationRowDisposition" property.  By default this is set to "RD_FailComponent".  This can be switched to "RD_IgnoreFailure" in order to allow the data to successfully pass through the "Flat File Source" even if SSIS believes that truncation is going to occur.  Along with making this change, you can also check the "DataType" in the "Output Columns" as well.
    Caution: If you do set the "Flat File Source" to "RD_IgnoreFailure" as mentioned above, always take time to review the data loaded in the target table to ensure that the integrity of the data was not jeopardized.
    Note:  I have found that when the "DataType" for both the "External Columns" and "Output Columns" is manually updated that it does not remain the same when the advanced editor is reopened.  For this reason, try Steps 1 and 2 before setting the "Output Columns" manually.
    4.  The last thing to try, and this applies specifically to loading data from Excel files as opposed to text or CSV is to set the package to run in 32-bit mode.  Click on "Project" on the top menu and select "Data Imports Properties...".  Click on "Debugging" under the "Configuration Properties" and set the "Run64BitRuntime" to "False".
    Working with data from flat files can sometimes be difficult in SSIS.  By using one or many of the approaches I have listed above you should be able to create a repeatable process that is frequently needed within most SSIS packages.  Be very careful when setting data types within SSIS and make sure to do it upfront when necessary because it can be harder to debug later in the development process.  If the proper changes are made it should not be a surprise to feel a big SSIS developer sense of relief when the screen shows all green.
    Let me know if this works!
    Check out my blog!

  • Text is truncated on the right side of a text field. How to solve?

    Hi group,
    I use CR for the .NET Platform 10.2 (VS 2005/.net2.0). In several cases the texts in my crystal reports are truncated on the right side of the text fields (which can show more than one line and which are set in the way that it increases if more than one line is needed).
    I created the CRs with CR in VS 2003. Then I migrated the VB.net project from VS 2003 to VS 2005. Then, when I opened a CR in VS 2005 and saved it again I got the message that it will be changed to the newer version if I click "yes" (or perhaps it was the "ok" button). I guess that was the moment the CR was migrated to the newer CR version.
    Because of the truncation problem I created one of the CRs completely new with exactly the same settings (i.e. the heigths of the sections, the widths of the text fields, and all the other setting are completely identical to the CR created in VS 2003). Interestingly, the texts are truncated in none of the text fields any more.
    Have I done the migration correcty? (Is it really opening the CR and saving it an saying "yes" or should I rather have done it in another way?)
    Does somebody of you already have had this kind of problem? How could it be solved without creating all CRs anew?
    Does recreating a CR which shows truncation of texts really solve it, or is truncation caused by something else, perhaps a certain property of a CR etc?
    The "printer" is set to "no printer" in all CRs. The truncation does show independent of whether the registry entry "HKEY_CURRENT_USER\Software\Crystal Decisions\10.2\Crystal Reports\Export\PDF\ForceLargerFonts" is set to 1 or to 0.
    Thanks for help in advance
    Kind regards
    Michael

    >
    Ludek Uher wrote:
    > There is a fair number of kbases in the kbase search (https://www.sdn.sap.com/irj/sdn/businessobjects-notes). Most of these refer to fixes. It may be a good idea to get the latest SP for your version of CR - CR 10.2?) and see if that helps. The latest SP for CR 10.2 is here:
    >
    > https://smpdl.sap-ag.de/~sapidp/012002523100006007872008E/crvs05sp1.exe
    >
    >
    > Ludek
    Hi Ludek,
    I already installed crvs05sp1 a few months ago (still traceable by the dir "C:Program FilesCommon FilesBusiness ObjectsPatchesCrystal Reports for Visual Studio .NET 2005 Service Pack 1" on my computer).
    Unfortunately, I cannot find any fitting entry in the kbase. If I search for "text truncation" or "text truncated" i get results but they are about pdf or word or fixed truncation problems in older CR versions.
    It seems as if I am the only one who has to face this problem :-).
    Best,
    Michael

  • More than one colour in titledborder text

    Hi,
    Can we have more than one colour in titledborder text at the same time.
    I have tried using html like you can in labels etc but no good.
    Cheers,
    Jim

    sorry about posting in wrong forum, just realised!

  • Long Text getting truncated in IW32

    We are using BAPI_ALM_ORDER_MAINTAIN to createa orders with long text.
    When reviewing the long text in the Office integration screen, We can see that all text is there.
    If, a user modifies the long text in the long text window of IW32, any text that does not display is lost when the order is saved
    If a user modifies teh long text in the office integartion screen, no text is lost.
    Any help on the cause and how to prevent this would be appreciated.
    Scott

    hi ,
    thanx for the reply,
    text gets truncated in print preview itself.
    i put breakpoint in  se38  and in sapscript.
    in se38 the variable shows full text, but in sapscript, it gets truncated.
    coding in sapscript
    /:           POSITION WINDOW
    /:           POSITION XORIGIN '-0.5' CH YORIGIN '-0.10' LN
    /:           SIZE WIDTH '+0.3' CH HEIGHT +0.85 LN
    /:           BOX HEIGHT '9.0' LN FRAME 10 TW
    /:           PERFORM PO_TEXT_DISP IN PROGRAM ZTEST_DRIVER
    /:           USING  &EKKO-EBELN&
    /:           CHANGING &PO_TEXT&
    /:           ENDPERFORM
    /:           IF &PO_TEXT& NE ''
    S7           &PO_TEXT&
    /:           ELSE
    /:           ENDIF
    regards
    senthil

  • Inbox: WorkItem text get truncated

    Hi,
    The work item text of a standard task created by me is of 110 character. The work item text can hold upto 120 characters.
    When a workflow was created, the last few characters in the workitem text was truncated.
    Is it SAP limitation or is there any way to get the full text.
    Note: I used variable to display the doucment number in the work item text.
    Thanks
    Suresh Kumar

    hi Suresh,
    based on my experience, the work item text is limited to 50 characters only.
    so if text for work item is longer than that it will be truncated
    hopes it helps
    cheers

  • Text was truncated

    Hello,
    I trying to import data from Oracle to SQL Server , and I have an issue with decimal places.
    In Oracle I have a number with 36 decimal places, when I trying to bring it to SQL(load to the table) , SQL thinks that it's a nvarchar(38) and still have an error:
    Text was truncated or one or more characters had no match in the target code page.
    Number looks like that:
    73.865092402464065708418891170431211499
    Please advise , what I should do in SSIS so it going to work
    Thanks

    With the . the number of chars is 39 not 38 so it breaks.
    You have to make it longer the NVARCHAR, but ideally why not it could be numeric
    Arthur
    MyBlog
    Twitter

  • SSIS - "Text was truncated or one or more characters had no match in the target code page"

    Hello everyone,
    SQL server 2012, SSIS package, we are getting the following error for some of the mapped columns,
    "Text was truncated or one or more characters had no match in the target code page."
    We're fetching the data from CSV file and dumping that to staging table i.e. SQL server 2012.
    Can anybody please advise how to resolve this error/problem? It's urgent.
    Any help would be much appreciated.
    Thanks, <b>Ankit Shah</b> <hr> Inkey Solutions, India. <hr> Microsoft Certified Business Management Solutions Professionals <hr> http://ankit.inkeysolutions.com

    You can enable data viewer (Right click on data flow connector --> Enable Data Viewer) before loading records to find out what's going on. Also, Configure error output to re-direct rows, so you can analyse data type and length.
    Also, try this: 
    Ultimately, in the Advanced Editor of the source datafile, on the Input and Output Properties tab, under External Columns, there is a
    Length property that defaults to 50. Changing that to match the Target Database File did the trick. [Source]
    Check this links: Add a Data Viewer to a Data Flow
    web: www.ronnierahman.com

  • Container Element Text Being Truncated in Email

    Hello,
    If a user rejects a Purchase Requision, I have added a Hard Check (BADI)  that requires the user to enter a "Reason for Rejection."
    In my BOR (ZBUS2105) GET_DATA method, I retrieve the "Reason for Rejection" text and add it to the Container.
    In my "Send Rejection Email" step, I set the "Reason for Rejection" text in the email body.
    When the email is sent, only 76 chars of the "Reason for Rejection" text is transferred from the Container to the email, however, in SWIA (Workflow logs), I can clearly see that my Container element contains about 210 chars of text.
    Also, the "Reason for Rejection" Container element is defined as CHAR255 (max value size allowed by the Container).
    Does anyone know why the "Reason for Rejeciton" text would be getting truncated in the email?
    Thanks!

    Hi Matthew
    Try to have a look at oss notes 975947, 808259, they might help you solve this issue
    Regards
    Morten Nielsen

  • Struts dynamic html:text property truncated

    hello!
    I am tring to dynamically generate the property of an indexed property in struts, my property name seems to get truncated after submission. What am I doing wrong?
    <html:text property="quantity('quantity(0)')" styleId="quantity" styleClass="text" size="15" value=""/>
    The value comes out like this and the key is truncated (it doesn't have a
    close bracket)
    quantity(QUANTITY-0 = 10 piecesThanks

    The key:value comes out like this:
    quantity(0 = 10 pieces

  • Text messages truncated

    please help: here in the philippines text messaging is used very frequently. but with treo 680 the text messages i get is truncated - it can't seem to receive long messages. funny because i did not have this problem in the beginning. what can i do to get the full messages again?
    thank you!
    Post relates to: Treo 680 (Unlocked GSM)

    The best way is to do another hard reset then go to your backup folder and rename it. The folder contains third party software and settings which seems to be causing this issue once you sync. Go to C:\program files\palm\your user folder name and look for back up. All you have to do is rename it. Once you finished this process go to the hotsync application - select customs - set all the conduits to do nothing except contacts, calendar, task and memos; set these to desktop overrides handheld. Once you finish this process then all you have to do is sync.
    Post relates to: Centro (Sprint)

  • IOS7 - Select list text being truncated

    Hi,
    Can anyone tell me why long options in a select list (drop down) are being truncated?  Is there a way to force such options to be all visible without truncating the text? 
    I have a responsive site, however on iPhones this text is being truncated while on Android and Windows Phone this works fine...
    Thanks

    I also faced the similar issue. But putting the empty <optgroup> after the last <option will do the trick . Thanks to the question on stackoverflow http://stackoverflow.com/questions/19398154/how-to-fix-truncated-text-on-select- element-on-ios7
    <select>
                  <option selected="">This is a very very very long option that would truncate in iOS7!</option>
                   <option>This is a very very very even longer option that would truncate in iOS7!</option>
                   <option>This is the longest option that would very very very very sure truncate in iOS7!</option>
    <optgroup label=""></optgroup>
                </select>

  • Form text item truncate

    Hi,
    My form emp has to show the employee names in a single text field, using this
    select query
    SELECT dept,
    RTRIM
    (XMLAGG (XMLELEMENT (e, emp_name || ',')).EXTRACT ('//text()'),
    ) emp_name
    FROM emp
    GROUP BY dept;
    multiple records are now coming in single text field but my "emp_name" data type is varchar2(150) so in form
    in getting emp_name text field have records in this format
    " Andrew "Big gap",roger"Big gap" ,John"Big Gap",fletcher
    i guess this problem becoz of the data type length, how to truncate this length in forms text field?
    Edited by: Veekay on 07/02/2011 09:41 م

    Hi
    i believe u r using the right function as u can see here
    http://techonthenet.com/oracle/functions/rtrim.php
    rtrim('tech '); would return 'tech' if i got ur problem then may be ur data length property of ur the text item if u minimize the spaces of displasying ur data
    guess this problem becoz of the data type lengthyesss, i guess this too :)
    Hope this helps
    Regards,
    Abdetu...

  • Text display, truncate with "...", how to?

    I would like to display long text fields in a truncated format, limited to a certain length. If the length is within the limit, display normally. If the length is > limit, cut it off and append "..." .
    This is the way the Feedback field is displayed in Apex Team Development, on pls/apex/f?p=4800:8000. It looks like they set the limit at 100 characters. For example:
    Normal:
    Are the menu paths what's configured in EBS, or paths where there are violations?
    Truncated:
    Reconcile the counts to p.6 Violations' reconcile counts report. Should work at the summary level b...
    When I inspect that display element, here's what I find.
    The unexpanded version is: <td align="left" headers="FEEDBACK_COMMENT">...</td>
    When I expand the element I see the full text: <td align="left" headers="FEEDBACK_COMMENT">Reconcile the counts to p.6 Violations' reconcile counts report. Should work at the summary level b...</td>
    Any help or pointers would be appreciated.

    Andy,
    Thanks for the pointer. The discussion included the REGEXP_SUBSTR function. Which suggested the SUBSTR function to truncate the field, which is all I need.
    So my simple solution can be to select the long text field twice in the interactive report, once full length, and once truncated by SUBSTR concatenated with '...'. Then the user can make reports with either, and the single full record view will have both.
    Skip

  • Text is truncating because of big font in BO 4.0

    Hi,
    I am using BO 4.0 o generate reports and export into PDF. When we generate reports the test statements are expanded till the right end corner, because of big size font. So when we print the reports it is going till the end and it is getting truncated.
    I have used ' TruncationAdjustment' & 'UsePrecisePositioningFortext' eventhough the font is coming bigger.
    The same report is coming fine from BOXI R2.
    Please advise.
    Thanks,

    Hello,
    can you please provide a detailed workflow we can follow to reproduce the problem?
    Thanks!

Maybe you are looking for