To select all the checkbox using valuechangelistner

Hi ,
I have a jsp where the check boxes are populated dynamically.
i have one more check box to select all the check boxes. (like Select all)
i have written a method in a bean and i have bound that as value changelistner. when i check values in console the check box value is true but the same is not reflected in UI and also when i click delete button the value of the checkbox will be false..
The value change listner methid is "toggleCheck"
Please do needfull in this regard..
here is my code....
Bean code :
package com.dyna;
import java.util.ArrayList;
import java.util.List;
import javax.faces.component.UIData;
import javax.faces.component.UISelectBoolean;
import javax.faces.event.ValueChangeEvent;
* @author Bharathk
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
public class Output {
     static ArrayList list = new ArrayList();
     private UIData table;
     private UISelectBoolean sb=null     ;
     private UISelectBoolean sbAll=null;
     static int count = 0;
     * @return Returns the list.
     public ArrayList getList() {
          return list;
     * @param list The list to set.
     public void setList(ArrayList list) {
          Output.list = list;
     * @return Returns the sb.
     public UISelectBoolean getSb() {
          return sb;
     * @param sb The sb to set.
     public void setSb(UISelectBoolean sb) {
          this.sb = sb;
     * @return Returns the sbAll.
     public UISelectBoolean getSbAll() {
          return sbAll;
     * @param sbAll The sbAll to set.
     public void setSbAll(UISelectBoolean sbAll) {
          this.sbAll = sbAll;
     * @return Returns the table.
     public UIData getTable() {
          return table;
     * @param table The table to set.
     public void setTable(UIData table) {
          this.table = table;
public List add(Input obj) {
Input in = new Input();
in.setId(obj.getId());
in.setName(obj.getName());
list.add(in);      
return list;
public List add(Input obj, int index) {
Input in = (Input)list.get(index);
in.setId(obj.getId());
in.setName(obj.getName());
list.set(index, in);      
return list;
public void deleteobj(Output obj){
     int Rc = table.getRowCount();     
     System.out.println("THIS IS IN DELETE");
     for (int i=0; i<Rc; i++) {
          table.setRowIndex(i);
          System.out.println("FROM DELETE------" +obj.sb.isSelected());
          if(obj.sb.isSelected()) {
               System.out.println("FROM DELETE");
               list.remove(i);
public void toggleCheck(ValueChangeEvent event){
     int rc = table.getRowCount();
     System.out.println("THIS IS IN TOGGLE");
     if (sbAll.isSelected()){
     System.out.println("THIS IS IN TOGGLE--IN IF");
               for (int i = 0; i< rc;i++) {
               table.setRowIndex(i);
// table.setRows(rc);                     
sb.setSelected(true);
                    System.out.println("THIS IS IN TOGGLE--CHECK--- "+this.sb.isSelected());
     else {
          System.out.println("THIS IS IN TOGGLE--In ELSE");
          for (int i = 0; i< rc;i++) {
                    table.setRowIndex(i);
                    sb.setSelected(false);
     /*for (int i = 0; i< rc;i++) {
          table.setRowIndex(i);
          System.out.println("THIS IS IN TOGGLE--CHECK--- "+this.sb.isSelected());
// FacesContext.getCurrentInstance( ).renderResponse( );
"Here is my jsp code........."
<%@taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@taglib uri="http://java.sun.com/portlet" prefix="portlet"%>
<%@taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@taglib uri="http://www.ibm.com/jsf/html_extended" prefix="hx"%>
<%@page language="java" contentType="text/html; charset=ISO-8859-1"
     pageEncoding="ISO-8859-1" session="false"%>
<portlet:defineObjects />
<LINK rel="stylesheet" type="text/css"
     href='<%= renderResponse.encodeURL(renderRequest.getContextPath() + "/theme/stylesheet.css") %>'
     title="Style">
<f:view>
     <hx:scriptCollector id="scriptCollector1">
          <%-- jsf:pagecode language="java" location="/JavaSource/pagecode/Sample.java" --%><%-- /jsf:pagecode --%>
          <P>Place content here.</P>
          <h:form styleClass="form" id="form1">
               <TABLE>
                    <TBODY>
                         <TR>
                              <TD align="left">Id:</TD>
                              <TD style="width:5px"> </TD>
                              <TD><h:inputText id="text1" value="#{inp.id}"
                                   styleClass="inputText">
                              </h:inputText></TD>
                         </TR>
                         <TR>
                              <TD align="left">Name:</TD>
                              <TD style="width:5px"> </TD>
                              <TD><h:inputText id="text2" value="#{inp.name}"
                                   styleClass="inputText">
                              </h:inputText></TD>
                         </TR>
                    </TBODY>
               </TABLE>
               <h:messages styleClass="messages" id="messages1"></h:messages>
               <BR>
               <hx:commandExButton id="button1" styleClass="commandExButton"
                    type="submit" value="Submit" action="#{pc_Sample.doButton1Action}">
               </hx:commandExButton>
               <h:selectBooleanCheckbox styleClass="selectBooleanCheckbox"
                                             id="checkbox1" binding="#{op.sbAll}"
valueChangeListner="#{pc_Sample.op.toggleCheck}" onCleck="this.form.submit();"></h:selectBooleanCheckbox>
               <BR>
               <hx:commandExButton type="submit" value="Delete"
                    styleClass="commandExButton" id="button2" action="#{pc_Sample.doButton2Action}"></hx:commandExButton>
               <BR>
               <BR>
          <h:dataTable id="table1" value="#{op.list}" binding="#{op.table}" var="varlist" styleClass="dataTable" headerClass="headerClass"
               footerClass="footerClass" rowClasses="rowClass1"
               columnClasses="columnClass1" border="0" cellpadding="2"
               cellspacing="0">
               <h:column id="column4">
               <f:facet name="header">
                         <h:outputText styleClass="outputText" value="Select" id="text13"></h:outputText>
                    </f:facet>
                                        <h:selectBooleanCheckbox styleClass="selectBooleanCheckbox"
                                             id="checkbox12" binding="#{op.sb}" ></h:selectBooleanCheckbox>
                                   </h:column>
               <h:column id="column3">
                                        <f:facet name="header">
                                             <h:outputText styleClass="outputText" value="SlNo" id="text10"></h:outputText>
                                        </f:facet>
                                        <h:commandLink styleClass="commandLink" id="link1" action="#{pc_Sample.doLink1Action}">
                                        <h:outputText id="text20"
                                             value="#{op.table.rowIndex+1}"
                                             styleClass="outputText">
                                        </h:outputText>
                              <f:param name="Id" value="#{varlist.id}"></f:param>
                              <f:param name="Name" value="#{varlist.name}"></f:param>
                         </h:commandLink>
                                   </h:column>
               <h:column id="column1">
                    <f:facet name="header">
                         <h:outputText styleClass="outputText" value="Id" id="text31"></h:outputText>
                    </f:facet>
                    <h:outputText id="text4" value="#{varlist.id}"
                         styleClass="outputText">
                    </h:outputText>
               </h:column>
               <h:column id="column2">
                    <f:facet name="header">
                         <h:outputText styleClass="outputText" value="Name" id="text5"></h:outputText>
                    </f:facet>
                    <h:outputText id="text6" value="#{varlist.name}"
                         styleClass="outputText">
                    </h:outputText>
               </h:column>
          </h:dataTable>
     </h:form>
     </hx:scriptCollector>
</f:view>

http://forums.ni.com/ni/board/message?board.id=60&message.id=8565&query.id=128811#M8565

Similar Messages

  • ALV GRID-how to select all the check boxes using push button

    Hai All,
    I displayed ALV grid & every record contains one check box as first column.
    If user clicks on one push button all the check boxes needs to selected.
    Could any one tell me how to do this?
    Regards,
    Bhaskar

    Hi Bhaskar,
       Try this code :
    *" Table declarations...................................................
    TABLES :
      spfli.                              " Flight Schedule
    *" Data declarations...................................................
    Work variables                                                      *
    DATA :
      w_checkbox  TYPE c,                  " Check Box
      w_checkbox1 TYPE c,                  " Check Box
      w_lineno    LIKE sy-lilli,           " Current Line No
      w_lines     TYPE i.                  " No. Of Records in Int.Table
    Internal table to hold Flight Schedule data                         *
    DATA :
       t_spfli LIKE
      STANDARD TABLE
            OF spfli.
    Structure to hold Function Codes                                    *
    DATA :
      fs_fcode LIKE LINE OF t_fcode.
                          TOP-OF-PAGE EVENT                             *
    TOP-OF-PAGE.
      PERFORM top_of_page.
                       START-OF-SELECTION EVENT                         *
    START-OF-SELECTION.
      PERFORM fetch_spfli_data.
      SET PF-STATUS 'YMENU1'.
      DESCRIBE TABLE t_spfli LINES w_lines.
      fs_fcode = 'EXIT'.
      APPEND fs_fcode TO t_fcode.
      fs_fcode = 'SELECT'.
      APPEND fs_fcode TO t_fcode.
      fs_fcode = 'DESELECT'.
      APPEND fs_fcode TO t_fcode.
      fs_fcode = 'RETRIEVE'.
      APPEND fs_fcode TO t_fcode.
                        AT USER-COMMAND EVENT                           *
    AT USER-COMMAND.
      PERFORM user_command.
    FORM top_of_page .
      WRITE :/50 'Flight Schedule Information'(008).
      ULINE.
      FORMAT COLOR 1.
      WRITE :/10 'Carrier ID'(001),
              25 'Connection ID'(002) ,
              43 'Airport From'(003),
              59 'Airport To'(004),
              74 'Departure Time'(007),
              93 'Arrival Time'(011),
             106 space.
    ENDFORM.                               " FORM TOP_OF_PAGE
    FORM fetch_spfli_data .
      SELECT carrid                        " Carrier ID
             connid                        " Connection ID
             airpfrom                      " Airport From
             airpto                        " Airport To
             deptime                       " Departure Time
             arrtime                       " Arrival Time
        FROM spfli
        INTO CORRESPONDING FIELDS OF
       TABLE t_spfli.
      IF sy-subrc EQ 0.
        PERFORM display_spfli_data.
      ENDIF.                               " IF SY-SUBRC EQ 0
    ENDFORM.                               " FORM FETCH_SPFLI_DATA
    FORM display_spfli_data .
      SORT t_spfli BY carrid ASCENDING.
      LOOP AT t_spfli INTO spfli.
        FORMAT COLOR 2.
        WRITE :/2 w_checkbox AS CHECKBOX,
                  spfli-carrid   UNDER text-001,
                  spfli-connid   UNDER text-002,
                  spfli-airpfrom UNDER text-003,
                  spfli-airpto   UNDER text-004,
                  spfli-deptime  UNDER text-007,
                  spfli-arrtime  UNDER text-011.
      ENDLOOP.                             " LOOP AT T_SPFLI...
    ENDFORM.                               " FORM DISPLAY_SPFLI_DATA
    FORM user_command .
      CASE sy-ucomm.
        WHEN 'SELECT'.
          w_checkbox1 = 'X'.
          DO w_lines TIMES.
            w_lineno = sy-index + 3.
            READ LINE w_lineno FIELD VALUE w_checkbox.
            IF w_checkbox = '*'.
              CONTINUE.
            ELSE.
              MODIFY LINE w_lineno FIELD VALUE w_checkbox FROM w_checkbox1.
            ENDIF.                         " IF W_CHECKBOX = '*'
          ENDDO.                           " DO W_LINES TIMES.
        WHEN 'DESELECT'.
          w_checkbox1 = ' '.
          DO w_lines TIMES.
            w_lineno = sy-index + 3.
            READ LINE w_lineno.
            IF w_checkbox = '*'.
              CONTINUE.
            ELSE.
              MODIFY LINE w_lineno FIELD VALUE w_checkbox FROM w_checkbox1.
            ENDIF.                         " IF W_CHECKBOX = '*'
          ENDDO.                           " DO W_LINES TIMES.
        WHEN 'RETRIEVE'.
          w_checkbox = ' '.
          DO w_lines TIMES.
            w_lineno = sy-index + 3.
            READ LINE w_lineno FIELD VALUE w_checkbox INTO w_checkbox.
            IF w_checkbox = 'X'.
              PERFORM fetch_sflight_data.
              PERFORM display_sflight_data.
            ENDIF.                         " IF W_CHECKBOX = 'X'
          ENDDO.                           " DO W_LINES TIMES.
      ENDCASE.                             " CASE SY-UCOMM
    ENDFORM.                               " FORM USER_COMMAND
    This report gives you the SPFLI Data and places a check box in front of each record. When u click on select all button it will select all the records. And if you click on deselect all it will deselect all the records. When you are trying this maintain the pf-status 'YMENU1' and give the function codes as in the code.
    Regards,
    Swapna.

  • What are all the tables used?

    hai,
    what r all the tables used for this report .
    <b>Created an interactive report in which sales orders were listed against different customers within the range selected. Selection of multiple sales orders were allowed for which checkboxes are provided.</b>
    Any help will be much appreciated.
    thanks

    hi
    Sales order related tables are:
    hi ashok,
    u can use from the following tables:
    VBAK -Header data(sales document).
    VBAP -Item data(sales document).
    VBUK -Header Status.
    VBAK -Item status.
    VBEE -Sales requirements (individual records)
    VBFA - Sales document flow
    Customer data related tables-
    KNA1- Customer master
    KNVV-Customer master sales data.
    KNVP-Customer master partner functions.
    Reward points if helpful.
    Naveen

  • How to select all the colomns_names from a table, with their datatypes ..

    hi :)
    i would like to know, how to select in SQL all the columns names from a table with their datatypes so that i get something like this :
    Table 1 : table_name
    the column ID has the Datatype NUMBER
    the column name has the Datatype Varchar2
    Table 2 : table_name
    the column check has the Datatype NUMBER
    the column air has the Datatype Varchar2
    and that has to be for all the tables that i own ! ..
    P. S : i m trying to do this with java, so it s would be enough if you just tell me how to select all the tables_names with all their colums_names and with all their datatypes ! ..
    thank you :)
    i ve heard it can be done with USER_TABLES .. but i have no idea how :( ..
    Edited by: user8865125 on 17.05.2011 12:22

    Hi,
    The data dictionary view USER_TAB_COLUMNS has one row for every column in every table in your schema. The columns TABLE_NAME, COLUMN_NAME and DATA_TYPE have all the information you need.
    Another data dictionary view, USER_TABLES, may be useful, too. It has one row pre table.

  • What is the keyboard shortcut to select all the white in a layer

    What is the keyboard shortcut to select all the white in a layer, I'm on windows and use to do it all the time but forgot!

    Do you mean ctrl-clicking the Composite Channel icon in the Channels Panel?

  • How to select all the frames in a document?

    i did select only particular active session.is it possible to select all the frames in a document?

    Hi vinothvijay,
    You can use below interface to select all the frames in the document.
    ISelectionManager* selMgr = Utils<ISelectionUtils>()->GetActiveSelection();
    if(selMgr)
       selMgr->SelectAll(ac,nil);
    Regards,
    Santosh K.

  • How to fetch what are all the tables used in this TR no and Package name of

    Hi Friends,
    I have input of Transport Request no (E070-TRKORR).
    How to fetch what are all the tables used in this TR no and Package name of this Table.

    HI,
    FYI
    SELECT E071OBJECT_NAME, E070MDEVCLASS
    FROM E071, E070M
    WHERE TRKORR = YOU REQUEST NO.

  • Logic to check all the checkboxes in the o/p screen

    Hi,
    In the o/p screen there are about 20 records.Besides each record there is a checkbox.There are 2 pushbuttons on the top of the screen(checkall and uncheckall).When the user clicks on the checkall pushbutton,all the checkboxes should be checked.Similarly when the uncheckall push button is clicked,all the check boxes should be unchecked.Can anyone tell me how to do this?

    Hi,
    Maybe you try the following:
    types: begin of ty_checkboxref,
            ref type ref to checkbox,
            end of ty_checkboxref.
    TABLES: sscrfields.
    data: gs_checkbox type ty_checkboxref,
            gt_checkbox type table of ty_checkboxref.
    parameters: cbox1 as checkbox,
                      cbox2 as checkbox,
                       rbut01 RADIOBUTTON GROUP grp1 USER-COMMAND fcode,
                rbut02 RADIOBUTTON GROUP grp1 ,
                rbut03 RADIOBUTTON GROUP grp1 .
    initialization.
    get REFERENCE of cbox1 into gs_checkbox-ref.
      append gs_checkbox to gt_checkbox.
      get REFERENCE of cbox2 into gs_checkbox-ref.
      append gs_checkbox to gt_checkbox.
    at selection screen.
      IF sscrfields-ucomm = 'FCODE'.
    TO CLEAR ALL CHECKBOXES:
    loop at gt_checkbox into gs_checkbox.
        gs_checkbox-ref->* = ' '.
        MODIFY gt_checkbox from gs_checkbox.
    endloop.
        IF rbut01 = 'X'.
          SPACE FOR ANY FUNCTIONALITY
        ELSEIF rbut02 = 'X'.
          SPACE FOR ANY FUNCTIONALITY
        ELSEIF rbut03 = 'X'.
          SPACE FOR ANY FUNCTIONALITY
        ENDIF.
      ENDIF.
    Of course you have to fill the table with the references to the checkboxes once, but than you can loop over the table and handle any amount of checkboxes simultaniously.
    Regards,
    Dave

  • How to select all the rows of table control in BDC

    Hi All,
    While I am doing BDC for Transaction Code MC88, After the first screen I will get another screen with tabble control, Here I need to select all the rows of table control, I am assignng the 'X' to the first field of Table Control which is the indicator for selection.
    Here I am getting message called Indicator field is not in program and screen.
    While doing Recording I am not able to record the indicator, Please any one let me know how to record the Entire table control selection.
    Thanks in advance..

    Sorry about that lakshmi. Here is my code.
        PERFORM dynpro USING : 'X'   'SAPMMCP6'          '0105',
                               ' '   'RMCP2-MATNR'       t_matnr,
                               ' '   'RMCP2-WERKS'       t_werks,
                               ' '   'BDC_OKCODE'        '=AKTV'.
        PERFORM dynpro USING : 'X'   'SAPLMCPA'          '0707',
                               ' '   'BDC_OKCODE'        '=MRKE'.
        PERFORM dynpro USING : 'X'   'SAPLMCPA'          '0707',
                               ' '   'BDC_OKCODE'        '=GRAO

  • How to select all the people that are not in any equipe  ?

    Hi,
    I have a nice SQL expression that gives me as a result all the "AGENTS" (people) that are working in an EQUIPE (a team)
    select a."AGENT_ID",
    a."NOM" || ' ' || a."PRENOM" "Nom",
    c.libelle "Equipe",
    a."DATE_EMBAUCHE" "Date embauche",
    a."DATE_DEBAUCHE" "Date débauche"
    from OBSERVATOIRE."AGENT" a,
    observatoire.equipe_agents b,
    observatoire.equipe c
    where a.agent_id = b.agent_id
    and b.equipe_id = c.equipe_id
    order by nom
    Now, how to select all the agents that are NOT working in any "EQUIPE" (team) ?
    I have tried but could not succeed !
    Thank you for your kind help.
    Christian

    Christian from France wrote:
    It is not working because the table EQUIPE_AGENTS does not contains a row if the agent is not into any equipe.
    CREATE TABLE "OBSERVATOIRE"."EQUIPE_AGENTS"
    (     "EQUIPE_AGENTS_ID" NUMBER NOT NULL ENABLE,
         "EQUIPE_ID" NUMBER NOT NULL ENABLE,
         "AGENT_ID" NUMBER NOT NULL ENABLE)
    CREATE TABLE "OBSERVATOIRE"."AGENT"
    (     "AGENT_ID" NUMBER NOT NULL ENABLE,
         "GRADES_ID" NUMBER NOT NULL ENABLE,
         "NOM" VARCHAR2(50 BYTE) NOT NULL ENABLE,
         "PRENOM" VARCHAR2(50 BYTE),
         "DATE_EMBAUCHE" DATE NOT NULL ENABLE,
         "DATE_DEBAUCHE" DATE)
    The only way to "know" if an agent is not into any equipe (team) is to search into the EQUIPE_AGENTS table, and if we do not find the ID of the agent into this table, then we know that this agent is not into any EQUIPE (team).
    I don't know ho to translate this into SQL.And that's what my query does. It uses an OUTER JOIN so that a result record is returned whether or not there is a record in EQUIPE_AGENTS. And the check for EQUIPE_ID is NULL restricts the result set to those where there IS NOT a record in EQUIPE_AGENTS.
    A more traditional way would be to use NOT IN or NOT EXISTS clauses, but they can prove inefficient.

  • Quick selection tool selecting all the image

    Hi
    I'm trying to get use to this quick selection tool , i have an image i need in the middle of the photo and all round the sides i want to whiten, the tool once draggin down either side selections all the picture no mater what setting i use, this is really annoying

    corky49 wrote:
    draggin down either side selections all the picture
    With the quick selection tool you need to drag INSIDE the object you are trying to select. So, say the image you are trying to isolate is a building, drag inside the picture of the building. The selection will expand looking for similar contrast pixels and will hopefully stop at the building edges. If it selects too much or too little you can zoom in and use the add to selection / subtract from selection options and Refine Edges until you get a satisfactory selection.
    From what you say you may be trying to select everything except the object in the centre  (so that you can whiten around the edges). If this is so then first select the object (building in my example) then invert the selection using Select> Inverse (or Ctrl+Shift+I).
    Cheers,
    Neale
    Insanity is hereditary, you get it from your children

  • How to display all the surveys using content query web part

    Can you please tell me how to display all the surveys using content query web part in more details? I also created a subsite and multiple surveys in that site. Then, I inserted a Content Query Web Part and select the List Type to be "Survey",
    however, it returned nothing. Did I miss anything?

    Hi,
    OOTB Survey List does not contain any
    Content Types and it has the following structure:
    Response entry is represented by
    List Item
    Response entry consist of questions and answers, where Question correspond to
    Field and Answer to Item value respectively.
    For querying Survey List via CQWP  the following properties could be used
    BaseType 
    <Lists BaseType="4">
    ServerTemplate
    <Lists ServerTemplate="102">
    Example
    To retrieve all the responses from Survey lists, specify List Type property as shown on picture
    Reference:
    http://stackoverflow.com/questions/17280778/display-all-surveys-using-content-query-web-part
    Best Regards,
    Eric
    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
    [email protected]

  • I'm trying to make a AUTO slide show. I can select all the other actions like mouse clicks etc. but

    I'm trying to make a AUTO slide show. I can select all the other actions like mouse clicks etc. but ON load will not work.
    PLEASE HELP>
    I do not know how to reload/reinstall "ADOBE" golive default actions. I'm using golive cs mac version and "ON LOAD" action. I can't select it when creating a golive action.....It converts it or something to a rollover..
    How can I reistall basic adobe actions???
    Is it a bug???
    Is it a known issue???
    Do I need something??
    Am I missing something???
    Thanks a bunch..
    Kev

    In article <[email protected]>,
    [email protected] wrote:
    > I do not know how to insert the auto slideshowaction as a head action item.
    > The steps.
    > Can you explain how to do it?
    I just remembered I have a couple of screen snaps online to explain how
    it's done:
    1. place your base image and name it in the inspector
    2. from the smart objects palette grab the head action item, the one
    with a question mark in its upper, green half - the 2nd one from the
    left. Drop that into the pages head section.
    3. in the inspector set the action to run OnLoad and select the base
    image that you named in the first step and set the other parameters.
    This was done in the days of GL6, but not much had changed in GL CS.
    Anyway you might also refer to GL's online help. It describes how to set
    up all the actions that ship with GL.
    Cheers Martin

  • Is there any way to select all the songs in a category?

    Is there any way to quickly select all the songs in a category quickly instead of holding Ctrl and clicking on all the songs?

    Shift key can be used also. click on file at top of list. Go to bottom item you want, while holding down shift key click on bottom item in list. All files between the ones you clicked on will be selected now.
    Ctrl-a selects all in current view.
    Select a file in library ctrl-a will select all files in library.
    Turn on browser view in iTunes. Select an artist. ctrl-a will select all songs by artist
    In browser, select an album from list and ctrl-a will select all files in album.

  • How to select all the text in a JTextArea??

    any1 know how to select all the text in a textarea?? just like when we press ctrl+a?? i use JTextAreaName.selectAll();doesnt work
    helt..

    worked OK for me
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    class Myprogram extends JFrame
      JTextArea TArea = new JTextArea(10,10);
      public Myprogram()
        JMenu JMenuName= new JMenu("JMenuName");
        JMenuItem  JMenuItemName=new JMenuItem("Select all");
        JMenuName.add(JMenuItemName);
        JMenuItemName.addActionListener(new SelectAllAction());
        getContentPane().add(new JScrollPane(TArea));
        JMenuBar mb = new JMenuBar();
        mb.add(JMenuName);
        setJMenuBar(mb);
        pack();
        setLocationRelativeTo(null);
        setVisible(true);
      class SelectAllAction implements ActionListener
        public void actionPerformed(ActionEvent e)
          TArea.requestFocusInWindow();
          TArea.selectAll();
      public static void main(String[] args){new Myprogram();}
    }

Maybe you are looking for