How to display String/text in a JFrame ?

Hi,
I set up a simple browser and pinging a server (say localhost). Then under that server directory, I am looking for a file. Then, I use input or output stream to bounce the text back to browser to display out on the screen. It was successful.
But, just can't display out in a text area (say a frame or something).
The string coming back from server say called s (one line at a time using buffer).
public class VerySimpleBrowser extends JFrame {
public JTextArea t;
public VerySimpleBrowser() {
super ("VerySimpleBrowser");
Box b = Box.createHorizontalBox();
b.add(new JScrollPane(t));
Container c = getContentPane();
c.add(b);
setSize(850,600);
show();
void static main ...
while ((s=fromServer.readLine()) != null)
//System.out.println(s);
t.setText(s);
Then, I got NullpointException error ?! The frame poped out ok, but nothing was written to it.
Thanks for help.
Philip

To save you from pulling all your hair out, here is what you've to do:
String out=""
while ((s=fromServer.readLine()) != null) {
   out+=s;
   t.setText(out);
.....V.V.

Similar Messages

  • HOW TO DISPLAY THE TEXT ON A PARTICULAR PAGE IN SAPSCRIPTS

    HI,
       HOW TO DISPLAY THE TEXT ON A PARTICULAR PAGE IN SAPSCRIPTS?

    in ur script main window
    /: IF &TTXSY-PAGE& = 15.              
    ur text or standard text           
    /: ENDIF.                             
    use this.
    hope it helps if any issues revert back

  • How to display string with XML content in 4.6?

    Hi,
    I`d like to know how to display string with XML content in it for 4.6.
    4.6 has not method parse_string.
    And example like this is not helpful:
      DATA: lo_mxml    TYPE REF TO cl_xml_document.
      CREATE OBJECT lo_mxml.
      CALL METHOD lo_mxml->parse_string
        EXPORTING
          stream = gv_xml_string.
      CALL METHOD lo_mxml->display.
    Thank you.

    Hi,
    May be you can use fm SAP_CONVERT_TO_XML_FORMAT. But it have some issues with memory usage, the program consumed tons of memory during convert.

  • How to display  LONG TEXT STRING in Module Pool Screen ?

    Hi Experts,
    I want to display long text string, on screen designed through module pool(SE51). I tried to display through input/output field , but it displays it in SINGLE LINE and i have to scroll all through to view all string.
    I want to display it in rectangular format . It doesnt allow me to set HEIGHT of component.
    Please provide solution.
    Thanks in advance.
    Regards
    Deepak

    This is the program where u can get the WA_THEAD from other program like report and trying to display and modifying that text. U can do instead of WA_THEAD u can generate here itself and use also
    *& Module pool       ZMP_LTEXT                                         *
    PROGRAM  ZMP_LTEXT                               .
    TABLES: STXL.
    *&      Module  STATUS_9000  OUTPUT
    MODULE STATUS_9000 OUTPUT.
    CONSTANTS:line_length type i value 132.
    DATA:g_editor type ref to cl_gui_textedit,
         g_editor_container type ref to cl_gui_custom_container,
         CONT1 type scrfname value 'CONT1',
         g_repid like sy-repid,
         g_ok_code like sy-ucomm,
         g_mytable(132) type c occurs 0,
         g_mycontainer(30) type c ,
         v_result(256) type c,
         g_head like thead,
         it_line type table of tline with header line,
         wa_stxl type stxl.
    DATA : BEGIN OF IT_THEAD1,
           ICON TYPE ICON-ID.
           INCLUDE STRUCTURE STXL.
    DATA : END OF IT_THEAD1.
    DATA : IT_THEAD LIKE TABLE OF IT_THEAD1,
           WA_THEAD LIKE LINE OF IT_THEAD.
    IMPORT WA_THEAD FROM MEMORY ID 'ABCD'.
    select SINGLE * from STXL into wa_stxl
                     where tdname = '00006000156500000002'.
    SELECT SINGLE * from STXL into wa_stxl
                      where tdname = WA_THEAD-TDNAME
                      AND TDID = WA_THEAD-TDID
                      AND TDOBJECT = WA_THEAD-TDOBJECT
                      AND TDSPRAS = WA_THEAD-TDSPRAS.
    IF SY-SUBRC NE 0.
    MESSAGE 'NO RECORD EXIST' TYPE 'E'.
    ENDIF.
    MOVE-CORRESPONDING WA_STXL TO G_HEAD.
    SET PF-STATUS 'STATUS'.
    SET TITLEBAR '001'.
      if g_editor is initial.
         CREATE OBJECT G_EDITOR_CONTAINER
           EXPORTING
            PARENT                      =
             CONTAINER_NAME              = CONT1
            STYLE                       =
            LIFETIME                    = lifetime_default
            REPID                       =
            DYNNR                       =
            NO_AUTODEF_PROGID_DYNNR     =
           EXCEPTIONS
            CNTL_ERROR                  = 1
            CNTL_SYSTEM_ERROR           = 2
            CREATE_ERROR                = 3
            LIFETIME_ERROR              = 4
            LIFETIME_DYNPRO_DYNPRO_LINK = 5
             others                      = 6.
         IF SY-SUBRC <> 0.
         MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
         ENDIF.
         CREATE OBJECT G_EDITOR
           EXPORTING
            MAX_NUMBER_CHARS       =
            STYLE                  = 0
       WORDWRAP_MODE          = cl_gui_textedit=>wordwrap_at_fixed_position
    for to fix number of characters in row to 132 characers
             WORDWRAP_POSITION      = line_length
             WORDWRAP_TO_LINEBREAK_MODE = cl_gui_textedit=>true
    for the word to break to next line if it don’t fit in line
            FILEDROP_MODE          = DROPFILE_EVENT_OFF
             PARENT                 = G_EDITOR_CONTAINER
            LIFETIME               =
            NAME                   =
           EXCEPTIONS
            ERROR_CNTL_CREATE      = 1
            ERROR_CNTL_INIT        = 2
            ERROR_CNTL_LINK        = 3
            ERROR_DP_CREATE        = 4
            GUI_TYPE_NOT_SUPPORTED = 5
             others                 = 6  .
         IF SY-SUBRC <> 0.
         MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
         ENDIF.
      REFRESH g_mytable.
         MOVE: WA_THEAD-TDNAME TO STXL-TDNAME,
               WA_THEAD-TDID TO STXL-TDID,
               WA_THEAD-TDOBJECT TO STXL-TDOBJECT,
               WA_THEAD-TDSPRAS TO STXL-TDSPRAS.
        CALL FUNCTION 'READ_TEXT'
        EXPORTING
        CLIENT                        = SY-MANDT
          ID                            = wa_stxl-tdid
          LANGUAGE                      = wa_stxl-tdspras
          NAME                          = wa_stxl-tdname
          OBJECT                        = wa_stxl-tdobject
        ARCHIVE_HANDLE                = 0
        LOCAL_CAT                     = ' '
      IMPORTING
        HEADER                        =
        TABLES
          LINES                         = it_line
      EXCEPTIONS
        ID                            = 1
        LANGUAGE                      = 2
        NAME                          = 3
        NOT_FOUND                     = 4
        OBJECT                        = 5
        REFERENCE_CHECK               = 6
        WRONG_ACCESS_TO_ARCHIVE       = 7
        OTHERS                        = 8
      IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    LOOP AT IT_LINE INTO V_RESULT.
       APPEND V_RESULT TO G_MYTABLE.
    ENDLOOP.
    CALL METHOD G_EDITOR->SET_TEXT_AS_R3TABLE
       EXPORTING
         TABLE           = G_MYTABLE
       EXCEPTIONS
         ERROR_DP        = 1
         ERROR_DP_CREATE = 2
         others          = 3.
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
       endif.
    ENDMODULE.                 " STATUS_9000  OUTPUT
    *&      Module  USER_COMMAND_9000  INPUT
    MODULE USER_COMMAND_9000 INPUT.
    CASE SY-UCOMM.
    REFRESH G_MYTABLE[].
    REFRESH IT_LINE[].
    CLEAR V_RESULT.
      WHEN 'SAVE'.
         CALL METHOD G_EDITOR->GET_TEXT_AS_R3TABLE
          EXPORTING
            ONLY_WHEN_MODIFIED     = FALSE
            IMPORTING
              TABLE                  = G_MYTABLE
            IS_MODIFIED            =
          EXCEPTIONS
            ERROR_DP               = 1
            ERROR_CNTL_CALL_METHOD = 2
            ERROR_DP_CREATE        = 3
            POTENTIAL_DATA_LOSS    = 4
            others                 = 5
         IF SY-SUBRC <> 0.
         MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
         ENDIF.
    LOOP AT G_MYTABLE INTO V_RESULT.
       APPEND V_RESULT TO IT_LINE.
    ENDLOOP.
    CLEAR V_RESULT.
        CALL FUNCTION 'SAVE_TEXT'
          EXPORTING
            CLIENT                = SY-MANDT
            HEADER                = G_HEAD
            INSERT                = ' '
            SAVEMODE_DIRECT       = 'X'
          OWNER_SPECIFIED       = ' '
          LOCAL_CAT             = ' '
        IMPORTING
          FUNCTION              =
          NEWHEADER             =
          TABLES
            LINES                 = IT_LINE
        EXCEPTIONS
          ID                    = 1
          LANGUAGE              = 2
          NAME                  = 3
          OBJECT                = 4
          OTHERS                = 5
       IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
       ENDIF.
    REFRESH G_MYTABLE[].
    REFRESH IT_LINE[].
    CLEAR V_RESULT.
    WHEN 'BACK' OR 'CANCEL' OR 'EXIT'.
    LEAVE TO SCREEN '0'.
    *CALL SCREEN '0'.
    WHEN OTHERS.
    ENDCASE.
    *G_OK_CODE = SY-UCOMM.
    *CLEAR SY-UCOMM.
    ENDMODULE.                 " USER_COMMAND_9000  INPUT

  • How to display Long text in a JLabel with multiline??

    Hi,
    Suppose I have a label that displays a long text....
    ""This is an example label that displays long text, how to break the line????.........""
    how to display it like below with one label?
    ""This is an example label
    that displays long text, how
    to break the line????.........""
    Thanks

    so basically do this
    JLabel myLabel = new JLabel();
    String theText = "<html>This is an example label<br>
                                  that displays long text, how<br>
                                  to break the line????.........</html>";
    myLabel.setText(theText);Obivously, u dont have to use a separate string, u could just call setText or pass it into the JLabel constructor, i just separated it to make it easier to see what your supposed to do.
    GOod Luck

  • How to display string message real time in a string area?

    I want to display string message on String indicator in screen real time, message is updating realtime when test application runing, i want to see the newest message display on screen real time instead of by drag down the vertical scroll bar manually.
    please give me an idea how to set the attribute of string indicator?thanks

    You can use Text.ScrollPosition property node for autoscrolling.
    Andrey.

  • How to Display Html Text with Image

    HI Frens,
    I am getting some html text from a source, Later i want to
    display that data, but it may happened that it has some images in
    it. Currently I am using text area to display it.
    Now My question is if there is any image will it show, as we
    can see it in our mails? if Not, Which component I should use for
    this?
    I also want that I need to select some file from, How can i
    get open dialog box here?
    Thks in Advance for replies frens:
    Ashish Mishra

    Hi Ashish,
    If I have understood your requirement properly, u want to
    display html text on a flex application.
    I think there its better if you use the html component to
    display the text. I have a sample code which will give you a
    direction to think on.
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application
    xmlns:mx="
    http://www.adobe.com/2006/mxml"
    layout="vertical"
    creationComplete="initApp( )">
    <mx:Script>
    <![CDATA[
    public function initApp( ):void
    var initHtml:String = "<html><head> \
    <title='Page Example'/> \
    <body bgcolor='#ccddee'><h1>Page
    Example</h1> \
    <p>This is a complete <b>HTML</b> \
    page as a
    <em>string</em>.</p></html></body>";
    this.html.htmlText = initHtml;
    ]]>
    </mx:Script>
    <mx:HTML id="html" width="100%" height="100%" />
    </mx:Application>
    Also do you want a file open dialog box??

  • How to display Formatted text view in adobe forms

    Hi Folks,
    We have a element formatted text edit/view in webdynpro so it is easy to make the text formates(Bullets, font sizes, etc..) in webdynpro, but the same feature is not available in Adobe forms designer...I don't find any element in the Adobe Library...
    If any body have an idea how to display the formatted text in adobe, please let me know the procedure.
    I have a html tag related data in my Ztable..I want to display this converted string from HTML Tab on adobe, please explain me how to fix this issue.
    Thanks,
    Naresh.

    Hi Juergen,
    I found Your blog and found it  really interesting... though I was not able to use it: I (like Jun Li is asking, I guess) need to use a dynamic text, containing formatting informations (according the xhtml syntax).
    I tried to pass it to the form by an ABAP-dictionary based interface and by means of the context (in a webdynpro page), but both tries failed.
    Some suggestion will be greatly appreciated.
    Thankyou
    Simone

  • How to display long text in smartforms

    Hi experts,
    Iam trying to display long text into smartforms.I got the long text into ITAB frm database
    in the abap program.In the form interface how to define the variable?In the long text i have 6 lines.
    points guaranteed
    cheers
    kaki

    Kaki,
    Delcare a table and getting the LONG TEXT is not the right way of doing this.
    You create a TEXT object and change the TYPE to INCLUDE TEXT. Once that is done all you have to do specify the parameters of your long text - TEXT ID, TEXT OBJECT and TEXT NAME. These are the same parameters that you use for READ_TEXT funciton. You don't have to fetch the text manually, it happens automatically.
    Make sure this is a part of the main window as this might run into multiple pages.
    Regards,
    Ravi
    Note : Please reward the posts that help you.

  • How to display Long text in alv output

    Hi,
    I have developed an ALV report.It is displaying the output.
    There is another requirment for alv output text field as below
    From the long text fields show only the first 20 characters and afterwards the long text icon. If the icon is clicked open the long text display screen.
    Please give your suggestion how to work on this requirement.
    Thanks in advance

    Hi,
    Create a hotspot for the long text column of ALV.
    When user clicks on the hotspot, handle the event to display long text screen.
    You may refer sample program of hotspot ALV :
    Goto SE38
    Type BCALV*
    Click F4
    search for HOTSPOT or EVENTS & you will get a sample program.
    Best regards,
    Prashant

  • How to display Formatted text in adobe form

    In adobe form, I want to display the text which is inputed by formatted text edit in WD ABAP application.
    It is always displayed as plain text like '<p>this is test text.</p>'. I have set the attribute Data Format to XHTML, Field Format to Rich Text for the Text Field in adobe form. But it doesn't work.
    How to display these formatted text?
    Thanks and Best Regards,
    Jun

    Hi Juergen,
    I found Your blog and found it  really interesting... though I was not able to use it: I (like Jun Li is asking, I guess) need to use a dynamic text, containing formatting informations (according the xhtml syntax).
    I tried to pass it to the form by an ABAP-dictionary based interface and by means of the context (in a webdynpro page), but both tries failed.
    Some suggestion will be greatly appreciated.
    Thankyou
    Simone

  • How to display the text as a Bold in the Text Element of a Smart Form

    Hi,
    I created one Smart Form.
    In that i created the Text element.
    I provide some data also in that.
    It is coming as a MS WORD.
    I executed my smart form.
    Customer Number:  &WA_KNA1-KUNNR&
    it display the data of the particular customer.
    But i need to display the Customer Number as BOLD or else Increase the Size.
    For this also I created one SMARTSTYLE.
    In that I created the Paragraph and Character Formats also.
    Now i assignee that SMARTSTYLE in the Output Option Tab of the Text Element also.
    But i unable to get the CUSTOMER NUMBER in Bold.
    In MS WORD we have BOLD button.
    I selected the Text and Press the BOLD button. At that time it is Highlighted.
    Whenever i press the SAVE Button.
    Then it is not saved with BOLD.
    It is coming in Normal Format.
    In the ECC 6.0.  I am unable to get the Text as a BOLD.
    This text Element is like a MS WORD.
    Can you please tell me how to display the Data with BOLD. please tell me. I am unable to get that one.
    Thank You.
    Regards,
    B. Krishna.

    Hi,
    Check where u have given BOLD. In character Format or in Paragraph format.
    In SMART FORM,
    1. Change to OLD EDITOR if u are confused with the new one.
            (This can be done by clicking the button left to new editor ).
    2. If it is PARAGRAPH FORMAT,
               Give the name of paragraph format in the editor.
                P1         &WA_KNA1-KUNNR&
        If it is CHARACTER FORMAT,
                             <C1> &WA_KNA1-KUNNR&
    Thanks,
    Nithya.

  • How to change string text in xaml

    I have string text in ListPickerItem like this
    <toolkit:ListPicker x:Name="items" FullModeHeader="Items" Background="White" Margin="10,280,14,0" VerticalAlignment="Top" Foreground="Black" FontSize="25.333">
    <toolkit:ListPicker.Header>
    <TextBlock x:Name="Choose_Items" Opacity="0.8" Text="Choose Items" Foreground="White"/>
    </toolkit:ListPicker.Header>
    <corelib:String>item1</corelib:String>
    <corelib:String>item2</corelib:String>
    <corelib:String>item3</corelib:String>
    <corelib:String>item4</corelib:String>
    <corelib:String>item5</corelib:String>
    <corelib:String>item6</corelib:String>
    <corelib:String>item7</corelib:String>
    <corelib:String>item8</corelib:String>
    </toolkit:ListPicker>
    So in code I want to change this text by the resource each string have another value like this
    And the code is
    Public Shared Iterator Function FindVisualChildren(ByVal obj As DependencyObject) As IEnumerable(Of DependencyObject)
    If obj IsNot Nothing Then
    For i As Integer = 0 To VisualTreeHelper.GetChildrenCount(obj) - 1
    Dim child As DependencyObject = VisualTreeHelper.GetChild(obj, i)
    If child IsNot Nothing Then
    Yield child
    End If
    For Each subChild In FindVisualChildren(child)
    Yield subChild
    Next
    Next
    End If
    End Function
    Private Sub Change()
    Dim rm As New ResourceManager("App.Resource1", GetType(MainPage).Assembly)
    Dim main As Grid = ContentPanel
    Dim result = FindVisualChildren(main)
    Dim ST = result.OfType(Of String)()
    For Each item In ST
    item = rm.GetString(item.Text)
    Next
    End Sub
    So How I can make right code to run like this problem ??
    Thanks :)

    Hi Shay Boshra,
    Based on your description, it seems that you want to change the ListPickerItem content based on the resource file, if I do not misunderstand you, an easy way to implement it is that first you can define the ListPicker as following:
    In the MainPage.xaml:
    <toolkit:ListPicker x:Name="items" Background="White" Margin="0,-11,24,0" VerticalAlignment="Top" Foreground="Black" FontSize="25.333">
    <toolkit:ListPicker.Header>
    <TextBlock x:Name="Choose_Items" Opacity="0.8" Text="Choose Items" Foreground="White"/>
    </toolkit:ListPicker.Header>
    <toolkit:ListPickerItem Content="item1"></toolkit:ListPickerItem>
    <toolkit:ListPickerItem Content="item2"></toolkit:ListPickerItem>
    <toolkit:ListPickerItem Content="item3"></toolkit:ListPickerItem>
    <toolkit:ListPickerItem Content="item4"></toolkit:ListPickerItem>
    <toolkit:ListPickerItem Content="item5"></toolkit:ListPickerItem>
    </toolkit:ListPicker>
    <Button Content="Change Text" HorizontalAlignment="Left" Margin="20,446,0,0" VerticalAlignment="Top" Click="Button_Click" Width="299"/>
    In the MainPage.xaml.cs:
    Private Sub Button_Click(sender As Object, e As RoutedEventArgs)
    Dim ResourceManager As New ResourceManager("App.Resource1", GetType(MainPage).Assembly)
    For Each listpickitem As ListPickerItem In items.Items
    listpickitem.Content = ResourceManager.GetString(listpickitem.Content.ToString())
    Next
    End Sub
    The result:
    Best Regards,
    Amy Peng
    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.

  • How to display sample text using dynpage ?

    Hi All,
             I am developing the portal using dynpage technology.  I do not know whether I am posting this thread in the right place.
    How to display a sample text in the portal using dynpage?
    I have written it using HTMLFragment.  But it could not recognise the <> tags it seems.
    I am getting error in < and in \.  Can anyone pls help to resolve this?
    I tried with normal html tags.  It could not recognise the tags.
    Pls suggest.
    Regards,
    Subashini.
    Edited by: Subashini on Sep 16, 2008 7:48 AM

    Do read through this tutorial.
    http://help.sap.com/saphelp_nw70/helpdata/EN/95/cfa441cd47a209e10000000a155106/frameset.htm
    Thanks,
    GLM

  • How to display korean text in file name

    Hi, I want to know how to make my system recognize and display Korean text in file names and such. My mp3 files are all a bunch of gibberish and they display that way in the itunes as well; the title, artist, and everything else.
    How can I fix this?

    Thanks. I tried that but the application wouldn't save any of the files for some reason.
    But it made me look for something else. In iTunes, I selected the song and right clicked, selected Convert ID3 Tags-->Reverse Unicode. Then it went to Chinese I think. I did the same thing again and it finally went to Korean.

Maybe you are looking for

  • Calling web service from applet

    Hi, I am trying to consume a .NET web service from a java applet. I use JDev9i and I generated a clientside-stub... It works fine in the development environnement, but I get this exception when executing from browser: java.lang.ExceptionInInitializer

  • No valuation variant found for valuation area

    Dear Experts When i m clearing or puting the LOt in quality through MB31 with 101 Movment for Production Order Following Error has occured No valuation variant found for valuation area xxxx. Rgds Pankaj Agarwal

  • Rosetta vs Photoshop v.7  Intel iMac running Snow Leopard.

    Dear Photoshoppers, I have Adobe Design Collection (before it became CS this and that...) eg Photoshop 7 Illustrator 10 InDesign 2 Acrobat 5. I've installed Illustrator 10.  Fine.  It recognised the lack of Classic environment and installed.  It runs

  • Non Order Items in MIGO Transaction

    Hi Experts, From starting to till now my client maintaining Non Order Items through MIGO Transaction. Now he wants stop that process. In MIGO Transaction he wants default gray mood the Non Order Items field. If that field is there in gray mood the us

  • What happen to Lightroom being apart of Creative Cloud?

    I am a photographer and I'm very dissapointed that I can't use lightroom to edit my photos.