Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: Problem of not displaying text which is initiated with "" in JTextPlane

  1. #1
    Junior Member
    Join Date
    Apr 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Problem of not displaying text which is initiated with "" in JTextPlane

    Lads,
    We have migrated a swing application from Java 1.4.2 (IBM) to 1.5 (IBM).
    In this application I have a Panel to display “account” information that contains two components (mine ones) that are subclasses of JTextPane. These components represents possible status of an account (an account can have status 1 and substatus 2 for example).
    When this panel is accessed it always trigger a method called populated fields that in turns populate these specific components (see pseudo code below):
    // initialize the texts with “” .
    Comp1.setText(“”);
    Comp2setText(“”);
    // then populate them with data if the data is available. An account can have only status 1 or only status 2 or both.
    If (there is data for Comp1)
    Comp1.setText(data);
    If(there is data for Comp2);
    Comp2.setText(data);

    My problem happens when I access this panel and there is data just for Comp1 then it displays it OK. (Account with only status 1)
    Then I access another account that has data just for status 2 (Account with only status 2) In this case depending on the size of the Window it does not display . I have to resize the Window (increase it) until it displays.

    If I initialized the Components with “ “ (one whitespace) instead of “” then it also works fine.
    Also After I resize the window to make the status been displayed and then I access another account then this new account will not have any problem regarding to display. Actually the issue will disappear until I restart my swing application.

    So I am trying to understand why resize or initialize the text with “ “ works. My issue here is that my components does other things linke underline text so when I start them as “ “ whenever one has no data to display it still displays a small underline _.
    In order to migrate this application from 1.4.2 to 1.5 (IBM) we did change code but not the ones directly involved here. Could it be an java 1.5 issue?

    Any help is very welcome.

    The layoutmanager used is BorderLayout.
    The Panel is initialized when the application is started.


  2. #2
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 286 Times in 225 Posts
    Blog Entries
    4

    Default Re: JTextPane does not display after text initialized with ""

    Good afternoon orfano and welcome to the Java Programming Forums

    Would it be possible to post all of the code so I can compile it and see the error for myself?
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

    Looking for a Java job? Visit - Java Programming Careers

  3. #3
    Junior Member
    Join Date
    Apr 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: JTextPane does not display after text initialized with ""

    Hello there,

    I am trying to reproduce it in a more short way as the whole code is huge and impossible to run without having the server part as well.
    As soon as I got a short version of the issue I will post the code.


    cheers,

  4. #4
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 286 Times in 225 Posts
    Blog Entries
    4

    Default Re: JTextPane does not display after text initialized with ""

    Quote Originally Posted by orfano View Post
    Hello there,

    I am trying to reproduce it in a more short way as the whole code is huge and impossible to run without having the server part as well.
    As soon as I got a short version of the issue I will post the code.

    cheers,
    It's hard for me to offer a solution without actually seeing the problem for myself.

    What happens when you initialized the Components with null instead of "" or " " ?
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

    Looking for a Java job? Visit - Java Programming Careers

Similar Threads

  1. Replies: 16
    Last Post: August 27th, 2010, 03:30 PM
  2. Replies: 2
    Last Post: March 23rd, 2010, 01:38 AM
  3. Drawing "Hello world" on screen
    By shikh_albelad in forum Java SE APIs
    Replies: 4
    Last Post: June 11th, 2009, 03:21 AM
  4. [SOLVED] "GridLayout" problem in Java program
    By antitru5t in forum AWT / Java Swing
    Replies: 3
    Last Post: April 16th, 2009, 10:26 AM