How to refresh a JPanel/JTextArea

My main problem is that I don't know how to correctly refresh a JTextArea in an Applet. I have an Applet with 2 internal frames. Each frame is comprised of a JPanel.
The first internal frame calls the second one as shown below:
// Set an internal frame for Confirmation and import the Confirm class into it//
Container CF = nextFrame.getContentPane();
//<Jpanel>
confirmation = new Confirmation( );
CF.add ( confirmation, BorderLayout.CENTER );
mFrameRef.jDesktopPane1.add(nextFrame,JLayeredPane.MODAL_LAYER);
currentFrame.setVisible(false); // Hide this Frame
nextFrame.setVisible(true); // Show Next Frame/Screen of Program
confirmation (Jpanel) has a JTextArea in it. When it's called the first time it displays the correct information (based on choices from the first frame). If a user presses the back button (to return to first frame) and changes something, it doesn't refresh in the JTextArea when they call the confirmation(Jpanel) again. I used System.out.println (called right after jtextareas code), and it shows the info has indeed changed...I guess I don't know how to correctly refresh a JTextArea in an Applet. Here is the relevent code for the 2nd Internal Frame (confirmation jpanel):
// Gather Info to display to user for confirmation //
final JTextArea log = new JTextArea(10,35);
log.setMargin(new Insets(5,5,5,5));
log.setEditable(false);
log.append("Name: " storeInfoRef.getFirstName() " "
+storeInfoRef.getLastName() );
log.append("\nTest Project: " +storeInfoRef.getTestProject() );
JScrollPane logScrollPane = new JScrollPane(log);

Here is the relevant code that I am having the problem with...
import javax.swing.*;
import java.awt.*;
import java.util.*;
public class Confirmation extends JPanel {
// Variables declaration
private StoreInfo storeInfoRef; // Reference to StoreInfo
private MFrame mFrameRef; // Reference to MFrame
private Progress_Monitor pmd; // Ref. to Progress Monitor
private JLabel ConfirmMessage; // Header Message
private JButton PrevButton;                // Navigation Button btwn frames
private JInternalFrame prevFrame, currentFrame; // Ref.to Frames
// End of variables declaration
public Confirmation(MFrame mFrame, StoreInfo storeInfo) {
mFrameRef = mFrame; // Reference to MFrame
storeInfoRef = storeInfo; // Reference to Store Info
prevFrame = mFrameRef.FileChooserFrame; // Ref. to Previous Frame
currentFrame = mFrameRef.ConfirmationFrame; // Ref. to this Frame
initComponents();
// GUI for this class //
private void initComponents() {
ConfirmMessage = new JLabel();
PrevButton = new JButton();
UploadButton = new JButton();
setLayout(new GridBagLayout());
GridBagConstraints gridBagConstraints1;
ConfirmMessage.setText("Please confirm that the information "
+"entered is correct");
add(ConfirmMessage, gridBagConstraints1);
// Gather Info to display to user for confirmation //
final JTextArea log = new JTextArea(10,35);
log.setMargin(new Insets(5,5,5,5));
log.setEditable(false);
log.append("Name: " storeInfoRef.getFirstName() " "
+storeInfoRef.getLastName() );
log.append("\nTest Project: " +storeInfoRef.getTestProject() );
log.append("\nTest Director: " +storeInfoRef.getTestDirector() );
log.append("\nTest Location: " +storeInfoRef.getTestLocation() );
log.append("\nDate: " +storeInfoRef.getDate() );
String fileOutput = "";
Vector temp = new Vector( storeInfoRef.getFiles() );
for ( int v=0; v < temp.size(); v++ )
fileOutput += "\n " +temp.elementAt(v);  // Get File Names
log.append("\nFile: " +fileOutput );
// log.repaint();
// log.validate();
// log.revalidate();
JScrollPane logScrollPane = new JScrollPane(log);
System.out.println("Name: " storeInfoRef.getFirstName() " " +storeInfoRef.getLastName() );
System.out.println("Test Project: " +storeInfoRef.getTestProject() );
System.out.println("Test Director: " +storeInfoRef.getTestDirector() );
System.out.println("Test Location: " +storeInfoRef.getTestLocation() );
System.out.println("Date: " +storeInfoRef.getDate() );
System.out.println("File: " +fileOutput );
// End of Gather Info //
add(logScrollPane, gridBagConstraints1);
PrevButton.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
PrevButtonMouseClicked(evt);
PrevButton.setText("Back");
JPanel Buttons = new JPanel();
Buttons.add(PrevButton);
add(Buttons, gridBagConstraints1);
// If User Presses 'Prev' Button //
private void PrevButtonMouseClicked(java.awt.event.MouseEvent evt) {
try
currentFrame.setVisible(false); // Hide this Frame
prevFrame.setVisible(true); // Show Next Frame/Screen of Program
catch ( Throwable e ) // If A Miscellaneous Error
System.err.println( e.getMessage() );
e.printStackTrace( System.err );
}// End of Confirmation class

Similar Messages

  • JTextArea:  How do I force a JTextArea to refresh?

    Hi All,
    I have a JTextArea that I append data do when I'm in a while loop. The JTextArea displays the text after the loop has finished, not as data is appended to it during the while loop. How can I force the JTextArea to refresh immediately after text is appended to it?
    Thanks,
    Karl

    In case if you want to refresh the text area means to clear all the text then try the below code
    JTextArea jta;
    jta.setText(" ");

  • Refresh a JPanel every time.

    Hi,
    How can you refresh a JPanel every time you invoke this JPanel?
    I have a Swing Application with a JSplitPane: a JTree on the left and a JPanel on the right. The JTree is used as a menu to display the right JPanel on the right. At this moment, the JPanels will only be created when I start the Application, so not on every time when I click on the JTree. Is it possible to get a new instance of the JPanel every time I reach it from the JTree (or at least get a trigger so that the latest information will be shown)?
    I hope someone can help. Thanks!
    Tongue78.
    |JTree                |  Place to show the JPanels  |
    |  ShowJPanel1  |                                           |
    |  ShowJPanel2  |                                           |
    |  ShowJPanel3  |                                           |
    |                        |                                           |
    |                        |                                           |
    --------------------------------------------------------------------

    A problem usually becomes easier when you disregard technical specs for a moment and think about it from a functional standpoint. In this case it would be something like "when I click on a node in the tree, I want to display a specific panel", right?
    For your right panel, check out the CardLayout. It allows you to put multiple panels in the same space, while only one is visible at a time.
    For the JTree, check out the event listeners that are part of Swing. A MouseListener for example will allow you to listen for mouse clicks on a certain component, so the start would be to install a mouselistener in the JTree.
    A google search for something like "java JTree node mouselistener" will probably get you further on this subject, for example to get sample code how to get the currently selected node.

  • How to refresh the client area

    i used javax.swing.JPanel and drawed many shapes with paintComponent method. i wonder how to refresh the client area.
    ps: i first used paint method to draw shapes, but i found a copy of the menu bar appeared. at last i found paintComponent method works, but when i tried to refresh the client area with repaint, the same scene appears.
    could some one help me?
    thanks in advance!

    when i tried to refresh the client area with repaint, the same scene appears. When you invoke repaint() on a component, the paintComponent() method of that component is invoked. So unless your code in that method is different, the image painted will be the same.

  • How to refresh the data in a container and to update the new data

    Hi,
    I have created a Module Pool Program in which i have two containers to display the long text.
    Initially this container is filled and based on some condition i want to update the text in the same conatiner.
    I am using the below two classes to do all this.
    cl_gui_textedit,
    cl_gui_custom_container,
    Could someone help me how to remove the long text in the container and update the new long text.
    I am getting the new long text but not able display it in the same container. Please someone help me how to refresh and update the container.
    Thanks in advance.

    Hi
    Try this.
      IF cl_gui_textedit  IS INITIAL.
      create control container
        CREATE OBJECT cl_gui_custom_container
           EXPORTING
                container_name = 'Container Name''
           EXCEPTIONS
                cntl_error                  = 1
                cntl_system_error           = 2
                create_error                = 3
                lifetime_error              = 4
                lifetime_dynpro_dynpro_link = 5.
    create text_edit control
        CREATE OBJECT cl_gui_textedit
           EXPORTING
                parent = cl_gui_custom_container
                wordwrap_mode = cl_gui_textedit=>wordwrap_at_windowborder
                wordwrap_to_linebreak_mode = cl_gui_textedit=>false
           EXCEPTIONS
                error_cntl_create      = 1
                error_cntl_init        = 2
                error_cntl_link        = 3
                error_dp_create        = 4
                gui_type_not_supported = 5.
      ENDIF.
    *--use method to set the text
      CALL METHOD cl_text_edit->set_text_as_stream
        EXPORTING
          text            =  t_lines ( Internal table with long text).
        EXCEPTIONS
          error_dp        = 1
          error_dp_create = 2
          OTHERS          = 3.
    regards,
    Raghu.

  • How to refresh/initialize sy-tabix in a loop?????

    Dear all,
    Please do let me know how to refresh/initialize 'sy-tabix' for every new document in a loop statement.
    Thanx in advance.
    Alok.

    Never try to refresh or initialize system variable. It shall always lead to errors in the programs. For this I have an alternative way below.
    Please declare a variable for e.g
    data: <b>l_count</b> type sy-tabix.
    Inside loop you can write the code like this:
    say for eg. you need to refresh l_count for every new material.
    Loop at itab.
    on change of itab-material.
    clear : l_count.
    endon.
    l_count = l_count + 1.
    endloop.
    Hope this clarifies your issue.
    Lakshminarayanan

  • How to make a JPanel selectable

    When extending a JPanel and overriding the paintComponent() method the custom JPanel can not be selected so that it gets for example KeyEvents.
    But if I make the new Class extend a JButton it gets of course selected and able to receive for example KeyEvents.
    My question is therefore; what does the JButton implement that a JPanel doesn&#8217;t so that a JButton gets selectable? Or in other words; how to make a JPanel selectable?
    Aleksander.

    Try this extended code. Only the first panel added can get the Focus.
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    class Test extends JFrame
      public Test()
        setLocation(400,300);
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        JPanel panel1 = new JPanel(new BorderLayout());
        JPanel panel2 = new JPanel(new BorderLayout());
        ImagePanel imgPanel = new ImagePanel();
        panel1.setFocusable(true);
        panel2.setFocusable(true);
        panel1.setPreferredSize(new Dimension(0, 50));
        panel2.setPreferredSize(new Dimension(0, 50));
        panel1.setBorder(BorderFactory.createLineBorder(Color.RED,     4));
        panel2.setBorder(BorderFactory.createLineBorder(Color.CYAN,    4));
        imgPanel.setBorder(BorderFactory.createLineBorder(Color.BLACK, 4));
        panel1.add(new JLabel("Panel 1"), BorderLayout.CENTER);
        panel2.add(new JLabel("Panel 2"), BorderLayout.CENTER);
        getContentPane().add(panel1, BorderLayout.NORTH);
        getContentPane().add(panel2, BorderLayout.SOUTH);
        getContentPane().add(imgPanel, BorderLayout.CENTER);   
        pack();
        panel1.addKeyListener(new KeyAdapter(){
            public void keyPressed(KeyEvent ke){
                System.out.println("Panel1");}});
        panel2.addKeyListener(new KeyAdapter(){
            public void keyPressed(KeyEvent ke){
                System.out.println("Panel2");}});
      public static void main(String[] args){new Test().setVisible(true);}
    class ImagePanel extends JPanel
      Image img;
      public ImagePanel()
        setFocusable(true);
        setPreferredSize(new Dimension(400,300));
        try{img = javax.imageio.ImageIO.read(new java.net.URL(getClass().getResource("Test.gif"), "Test.gif"));}
        catch(Exception e){/*handled in paintComponent()*/}
        addKeyListener(new KeyAdapter(){
          public void keyPressed(KeyEvent ke){
            System.out.println("ImagePanel");}});
      public void paintComponent(Graphics g)
        if(img != null)
          g.drawImage(img, 0,0,this.getWidth(),this.getHeight(),this);
        else
          g.drawString("This space for rent",50,50);
    }

  • How to refresh XML file  from my client machine

    Hai All
    I have temp.XML and temp.XSL template in our server machine.
    when i give a print from client machine first time it gives the record,and next time it did not get refresh.Always it shows the previous records in the browser.But when i go into the server machine and click on temp.xml,it shows the current record(correct records)
    How to refresh XML file  from my client machine?
    Regards
    Dhina

    You never delete a Time Machine backup by dragging it to the Trash. You are supposed to use the TM application to manage the backups. What you will need to do now is to simply erase the drive using Disk Utility.

  • How to Refresh a WAD Template

    Hi...i have a WAD template wih 6 queries on it....i want to know how to refresh all the template ...or i have to refresh every query one by one...i try to put a command button but it appears inactive and i dont konw how to actiavte it...
    Regards

    Hi,
    Please try with CMD: REFRESH_DATA. You can find this under 'Commands for Planning Application'.
    Otherwise, you can take Action as : SCRIPT_FUNCTION and give "javascript:location.reload(true)" under Script Function.
    Regards,
    -Vj

  • How to Refresh a Page once saved to database in ADF.

    Hi,
    I created a JSF page using project template as "JSF,ADF,business components".
    There is a List of values displayed in a dropdown list,
    User can create new value and once it is saved to the database it should reflect in the list of values.But it is not displaying in the LOV and it is happening only when i close that page and open a new one.
    Can u please tell me how to refresh a page without closing the current page once save button is clicked.
    Thank you,
    Harika.

    Mini wrote:
    Hi Hari,
    Yes i have a apex page redirects from the ebs menu like you said. But for the refresh issue instead of modifying in the jsp i thought of bringing the automatic refresh for that apex page once it is loaded within apex.
    However these type of issues are sometimes get fixed by clearing browser cache or just by restarting your browser. Have you tried it?Yes i have tried, by clearing the browser cache and also by restarting the browser then too it still persist.
    Any DA action will be helpful for refreshing that page for 1sec once it is loaded. Since i dont want it to be loaded multiple times often once it is loaded.
    The refresh has to be only once if the page is loaded.
    or is it possible to Refresh the page based on the application page item through DA
    Thanks
    Brgds,
    MiniTechnically Yes, you can create a D.A. that will fire only once based on some apex page item or application item value. However this is NOT the correct solution.
    <li> When you see apex page (after clicking menu in EBS), do you see apex url in browser address bar? Can you post the URL here?
    <li> If you directly log-in to APEX (not via EBS), do you still face this issue?
    Regards,
    Hari

  • How to refresh after delete the records in ALV report ?

    Hi Friends,
    How to refresh after delete the records in ALV report.
    I am deleting records in ALV report .
    After successful delete the screen should refresh.
    u201C Deleted records should not appear in the screen u201C.
    Please guide me.
    Regards,
    Subash

    Hi subhash,
    FORM user_command USING r_ucomm LIKE sy-ucomm      rs_selfield TYPE slis_selfield.
    WHEN 'BACK'.
    Refresh the internal table from the ALV grid
          PERFORM update_alv_tab.
    ENDFORM.                    "user_command
    FORM update_alv_tab .
      DATA :  e_grid TYPE REF TO cl_gui_alv_grid.
      CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
        IMPORTING
          e_grid = e_grid.
      CALL METHOD e_grid->check_changed_data.
      "update_alv_tab
      CALL METHOD e_grid->refresh_table_display.
    ENDFORM.                    " UPDATE_ALV_TAB
    Then see in Debug mode is it updating or not..
    Please confirm .
    And please paste the code if you can.
    Regards.

  • How to Refresh System Form in Run Time

    Dear All,
    Please give me idea for Refresh System Document in Run Time using DI,basically I am using  system columns for update for some scenarios.
    So please give solution that how should refresh system form.
    Thanks a lot.
    Ashish Singh.

    Hi,
    Please post above discussion in SDK forum.
    Thanks & Regards,
    Nagarajan

  • How-To "Refresh a table of data after inserting or deleting"

    I'd like to say a word on the how-to article "How to refresh a table of data after inserting or deleting a row using ADF".
    (http://www.oracle.com/technology/products/jdev/howtos/1013/updtable/index.html?_template=/ocom/technology/content/print)
    I spent a lot of time on it because I needed help in implementing simple CRUD functionality on a table, using JSF-ADF-TopLink technologies.
    While the the article does provide correct steps, it is in one important place not specific enough, so the reader may easily get stuck. In section "Refresh the data table", point 1: when you double click on the removeEntity() button, in Structure window, then you do not get the required dialog. You get CommandButton Properties dialog.
    You must click on the removeEntity() button in Editor's Design view. But even there you may get the CommandButton Properties dialog, not managed beans dialog.
    You may resolve that by going to JSF configuration file, faces-config.xml, and switch to Overview view. This will show you the managed beans that you have.
    Then, you may already have a backing bean for the page. You can use that and avoid creating a new managed bean.
    I could understand what the operations mean only after very careful reading of "Creating More Complex Pages", section "Overriding Declarative Methods" in JDeveloper Help (or in ADF Developer's Guide PDF document).
    In general: I believe that "ADF bindings" need more conceptual explanation, maybe in form of an article. Grammatical form "bindings" may create a false understanding that "bindings" are just references. But they are not -- ADF bindings are active objects that handle traffic between UI components and Data Controls. It seems that "bindings" even communicate among themselves. Maybe it would be more understandable to differentiate strictly between "binding objects" (or "binders"?), binding object definitions and binding object references.
    It would be very helpful to have a diagram showing grahically what specific binder objects are created in a small apllication (2-3 pages using 1-2 tables), with whom they communicate and what type of data is passed on.
    Priit

    Hi
    Thanks for your infos.
    Yes exactly I use almost the same code you have post here.
    Could You answer to my next questions?
    First - >what do you mean by saying that "it's not good idea using refreshing in IE?" Of course I use refreshing in backing_bean for my button "remove" that removes row, commit changes to database and refresh table, almost the same as You said in your post:
    Code in backing_bean is and comments on difference to Your code is below:
    public commandButton2_action1(){
    BindingContainer bindings = getBindings();
    OperationBinding operationBinding =
    bindings.getOperationBinding("removeEntity");
    Object result = operationBinding.execute();
    if (!operationBinding.getErrors().isEmpty()) {
    return null;
    //above remove entity, but I dont now if it do commit to database? So i do it below
    OperationBinding commit1 = bindings.getOperationBinding("Commit");
    commit1.execute();
    //and at the end I refresh my table, "findAllRezerwacja1 - it is an id of the methodAction, not the iterator -> is it ok? or should I change to Iterator id?
    OperationBinding requery = bindings.getOperationBinding("findAllRezerwacja1");
    requery.execute();
    return null;
    Page Definition code for this:
    <methodAction id="findAllRezerwacja1"
    InstanceName="SessionEJBLocal.dataProvider"
    DataControl="SessionEJBLocal" MethodName="findAllRezerwacja"
    RequiresUpdateModel="true" Action="999"
    ReturnName="SessionEJBLocal.methodResults.SessionEJBLocal_dataProvider_findAllRezerwacja_result"/>
    <table id="findAllRezerwacja2" IterBinding="findAllRezerwacja1Iter">
    <AttrNames>
    <Item Value="dataDo"/>
    <Item Value="dataOd"/>
    <Item Value="idRezerwacja"/>
    <Item Value="liczbaUczestnikow"/>
    <Item Value="prowadzacy"/>
    <Item Value="uwagi"/>
    </AttrNames>
    </table>
    <methodAction id="removeEntity" InstanceName="SessionEJBLocal.dataProvider"
    DataControl="SessionEJBLocal" MethodName="removeEntity"
    RequiresUpdateModel="true" Action="999">
    <NamedData NDName="entity"
    NDValue="${bindings.findAllRezerwacja2.currentRow.dataProvider}"
    NDType="java.lang.Object"/>
    </methodAction>
    <action id="Commit" IterBinding="findAllRezerwacja1Iter"
    InstanceName="SessionEJBLocal.dataProvider"
    DataControl="SessionEJBLocal" RequiresUpdateModel="true"
    Action="2"/>
    </bindings>
    //and rest of code for Iterator etc
    My second question is, why when you use refresh button in IE (I know is not recommended as You said, but sometimes user do it, so I want prevent situations that I will describe here) so when I press refresh button in IE exactly after removing one row by clicking my button, refreshing by pressing IE button is doing the same --> is deleting next row. How to stop deleting row, when for example user would press IE refresh button after pressing remove button for table. If I change selection in table after deleting row, and press refresh button in IE, instead of deleting row, I got error message: JBO-29000: JBO-35007: and
    JBO-35007. So where Im doing wrong. Maybe I should do sth with postback ? Could You help me? Thanks in advance
    Last one question: what is the difference between using delete and removeEntity from operations node? Im now reading carefully ADF Dev Guide, so I hope I can find infos there? But if You know, please answer to this question.
    Thanks

  • How to refresh the textedit object in module pool

    Hi All,
    I would appreciate if anybody can solve my problem.
    Problem is i have created one TEXTEDIT and now when user clicks on the cancel button and come back to the screen the data which was previously entered is still coming up.
    Please tell me how to refresh the data in TEXTEDIT.

    actualy it is enough to do the following, assuming you have a container to put the textedit into it:
      DATA:  l_parent_container TYPE REF TO cl_gui_custom_container,
             l_obj_editor TYPE REF TO cl_gui_textedit, "make this a global variable
             l_text_table TYPE re_t_textline,
             l_itftext TYPE STANDARD TABLE OF tline,
             l_thead TYPE thead.
    l_parent_container = ... "your container
    move .... to l_thead...    "your text header to read or reread
    read text from SO10
      CALL FUNCTION 'READ_TEXT'
        EXPORTING
          id                      = l_thead-tdid "Text-ID
          language                = l_thead-tdspras "im_request-language?
          name                    = l_thead-tdname "TDIC Text-Name
          object                  = l_thead-tdobject "Texte: Anwendungsobjekt
        TABLES
          lines                   = l_itftext
        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.
    convert itf text to stream text (SAPSCRIPT_DEMO_NOTE_EDITOR)
      CALL FUNCTION 'CONVERT_ITF_TO_STREAM_TEXT'
        TABLES
          itf_text    = l_itftext
          text_stream = l_text_table.
      IF l_obj_editor IS INITIAL.
        CREATE OBJECT l_obj_editor
            EXPORTING parent = l_parent_container. " Abstract Container for GUI Controls
      ENDIF.
    discard any previous changes
      l_obj_editor->set_textmodified_status( cl_gui_textedit=>false ).
    übertragen text in editor
      CALL METHOD l_obj_editor->set_text_as_stream
        EXPORTING
          text            = l_text_table
        EXCEPTIONS
          error_dp        = 1
          error_dp_create = 2.

  • How to dynamically resize JPanel at runtime??

    Hello Sir:
    I met a problem, I need to resize a small JPanel called panel within a main Control JPanel (with null Layout) if I click the mouse then I can Drag and Resize this small JPanel Border to the size I need at runtime, I know I can use panel.setSize() or panel.setPreferredSize() methods at design time,
    But I have no idea how to do it even I search this famous fourm,
    How to dynamically resize JPanel at runtime??
    Can any guru throw some light or good example??
    Thanks

    Why are you using a null layout? Wouldn't having a layout manager help you in this situation?

Maybe you are looking for