MouseEvent on non-editable JTextArea

Hi folks,
I try to add a cut&paste popup menu to JTextArea. What I am doing is to add a mouseListener to it. The problem is that when the JTextArea is non-editable, i.e. setEditable(false), the right mouse click event cannot be trapped and thus the popup menu cannot be displayed. From GUI point of view, I think it is quite common to cut (or copy) text from non-editable JTextArea, but just have no idea how they can be done. Any help will be greatly appreicated. Thanks in advance.
CK

My non-editable JTextArea responses to all mousePressed, mouseEntered, mouseClicked, mouseExited, mouseReleased
Why not yours?

Similar Messages

  • Selecting in Non-Editable JTextField in JDK 1.4

    Hi.
    Posting as new thread - maybe somebody can help.
    I want a formatted non-editable (!) display component (for incoming Instant Messages, if anyone cares), which allows selecting with the mouse (including selection highlighting) and then copying FROM it into another application or window. Currently (starting from JDK 1.4), this does not appear to be possible with a JTextArea. It works absolutely fine in all 1.3 JDKs, so It appears it was broken starting with JDK 1.4.
    Imagine not being able to copy FROM your Web browser (which is non-editable) INTO another application. That's what the situation is currently like.
    So - maybe I'm missing the obvious (well, a setSelectable(true) method would probably be TOO obvious), but can anyone help me as to how I can achieve the desired effect.
    From how I understood the workarounds in another thread, they would mean actually making the TextPane editable, but preventing all edits. Oh, and manually making its appearance resemble a non-editable Pane, so that the GUI doesn't appear inconsistent. SURELY this cannot be reasonable.
    Thanks,
    Daniel.

    Hi!
    I managed to boil the problem down to a simple test case (and, in doing so, actually found a fix for our problem). It seems that JTextPane does not allow selection if the method isFocusTraversable (which, by the way, is deprecated in JDK 1.4) is overridden:
    import java.awt.*;
    import javax.swing.*;
    public class test
    extends JDialog
         public test()
              super((JFrame)null, "JTextPane Test");
              getContentPane().setLayout(new BorderLayout());
              JTextPane pane = new JTextPane()
    // public boolean isFocusTraversable()
    // return false;
              String s1 = "01234567890123456789012345678901234567890123456789";
              String s2 = "";
              for (int i=0;i<50;i++)
              s2 = s2+s1+"\n";
              pane.setText (s2);
              pane.setEditable(false);
              getContentPane().add(new JScrollPane(pane), BorderLayout.CENTER);
              pack();
         public static void main(String argv[])
              (new test()).show();
    If you remove the comment lines around the inner class method, selection stops working. If you leave the comments in, selection and copy/paste do indeed work.
    Now why, one wonders, does a method which is deprecated in JDK 1.4 actually cause a PROBLEM in JDK 1.4 that wasn't there before?
    Daniel.

  • Make quantity field of Free goods as non-editable.

    Hie!
    I have free goods scheme of 9 + 1 .If quantity of main material is 10 then it will split into 9 + 1 where 1 is free of cost.
    While making the sales order the free goods quantity field is editable. So the users are able to change the free goods quantity. I want to make this field as non-editable.
    Please suggest how to do this.
    Thankyou.

    Hi Pallavi
    If you change the manual qty which is automatically determined by the system then there will be a message thrown by the system
    Suppse in your case if 9+1 you change the qty manually to 2 from 1 there is a message V1 no 737 thrown by the system
    You need to change the message class thro ABAP development only not possible thro customization
    Not only this in delivery also it is possible to change the free qty and this also has to be controlled by the ABAPer only
    Regards
    Raja

  • FBL5N - Feild selection non editable mode

    Hi All,
    When i execute FBL5N transaction,i am not able to select the feilds as per my desire bcoz the feild display ICON is in non editable mode.
    The only option i have is layout selection and not the feilds selection.
    Can you let me know how to change it to editable mode.
    regards

    Hello,
    You don't have authorization for maintain ALV layouts. Please contact to your Basis department for authorization.
    ALV layout authorization object is S_ALV_LAYO. Please tell your Basis departman to give this object value for '23'.
    Regards,
    Burak

  • Keyevent used for setMnemonic show in editable jtextarea

    I don't know if this has been fix. I notice that if I used the setMnemonic to access a editable jtextarea, that the key I used is inserted into the jtextarea. After searching the web, I found nothing about this problem.
    So, I took the program from the java tutorial, MenuDemo.java and reproduct the same problem but setting the jtextarea to editable (output.setEditable(true). It happens everytime. Below is the MenuDemo.java with the change. By selecting t or b in the A Menu menu,then which ever t or b used will show up in the text area after the expected line displays. I am using 1.5 so this problem may have been fix.
    If anyone knows if it has or a work around, please let me know.
    Thanks
    Kevin
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.JMenu;
    import javax.swing.JMenuItem;
    import javax.swing.JCheckBoxMenuItem;
    import javax.swing.JRadioButtonMenuItem;
    import javax.swing.ButtonGroup;
    import javax.swing.JMenuBar;
    import javax.swing.KeyStroke;
    import javax.swing.ImageIcon;
    import javax.swing.JTextArea;
    import javax.swing.JScrollPane;
    import javax.swing.JFrame;
    * This class adds event handling to MenuLookDemo.
    public class MenuDemo extends JFrame
    implements ActionListener, ItemListener {
    JTextArea output;
    JScrollPane scrollPane;
    String newline = "\n";
    public MenuDemo() {
    JMenuBar menuBar;
    JMenu menu, submenu;
    JMenuItem menuItem;
    JRadioButtonMenuItem rbMenuItem;
    JCheckBoxMenuItem cbMenuItem;
    addWindowListener(new WindowAdapter() {
    public void windowClosing(WindowEvent e) {
    System.exit(0);
    //Add regular components to the window, using the default BorderLayout.
    Container contentPane = getContentPane();
    output = new JTextArea(5, 30);
    output.setEditable(true);
    scrollPane = new JScrollPane(output);
    contentPane.add(scrollPane, BorderLayout.CENTER);
    //Create the menu bar.
    menuBar = new JMenuBar();
    setJMenuBar(menuBar);
    //Build the first menu.
    menu = new JMenu("A Menu");
    menu.setMnemonic(KeyEvent.VK_A);
    menu.getAccessibleContext().setAccessibleDescription(
    "The only menu in this program that has menu items");
    menuBar.add(menu);
    //a group of JMenuItems
    menuItem = new JMenuItem("A text-only menu item",
    KeyEvent.VK_T);
    //menuItem.setMnemonic(KeyEvent.VK_T); //used constructor instead
    menuItem.setAccelerator(KeyStroke.getKeyStroke(
    KeyEvent.VK_1, ActionEvent.ALT_MASK));
    menuItem.getAccessibleContext().setAccessibleDescription(
    "This doesn't really do anything");
    menuItem.addActionListener(this);
    menu.add(menuItem);
    menuItem = new JMenuItem("Both text and icon",
    new ImageIcon("images/middle.gif"));
    menuItem.setMnemonic(KeyEvent.VK_B);
    menuItem.addActionListener(this);
    menu.add(menuItem);
    menuItem = new JMenuItem(new ImageIcon("images/middle.gif"));
    menuItem.setMnemonic(KeyEvent.VK_D);
    menuItem.addActionListener(this);
    menu.add(menuItem);
    //a group of radio button menu items
    menu.addSeparator();
    ButtonGroup group = new ButtonGroup();
    rbMenuItem = new JRadioButtonMenuItem("A radio button menu item");
    rbMenuItem.setSelected(true);
    rbMenuItem.setMnemonic(KeyEvent.VK_R);
    group.add(rbMenuItem);
    rbMenuItem.addActionListener(this);
    menu.add(rbMenuItem);
    rbMenuItem = new JRadioButtonMenuItem("Another one");
    rbMenuItem.setMnemonic(KeyEvent.VK_O);
    group.add(rbMenuItem);
    rbMenuItem.addActionListener(this);
    menu.add(rbMenuItem);
    //a group of check box menu items
    menu.addSeparator();
    cbMenuItem = new JCheckBoxMenuItem("A check box menu item");
    cbMenuItem.setMnemonic(KeyEvent.VK_C);
    cbMenuItem.addItemListener(this);
    menu.add(cbMenuItem);
    cbMenuItem = new JCheckBoxMenuItem("Another one");
    cbMenuItem.setMnemonic(KeyEvent.VK_H);
    cbMenuItem.addItemListener(this);
    menu.add(cbMenuItem);
    //a submenu
    menu.addSeparator();
    submenu = new JMenu("A submenu");
    submenu.setMnemonic(KeyEvent.VK_S);
    menuItem = new JMenuItem("An item in the submenu");
    menuItem.setAccelerator(KeyStroke.getKeyStroke(
    KeyEvent.VK_2, ActionEvent.ALT_MASK));
    menuItem.addActionListener(this);
    submenu.add(menuItem);
    menuItem = new JMenuItem("Another item");
    menuItem.addActionListener(this);
    submenu.add(menuItem);
    menu.add(submenu);
    //Build second menu in the menu bar.
    menu = new JMenu("Another Menu");
    menu.setMnemonic(KeyEvent.VK_N);
    menu.getAccessibleContext().setAccessibleDescription(
    "This menu does nothing");
    menuBar.add(menu);
    public void actionPerformed(ActionEvent e) {
    JMenuItem source = (JMenuItem)(e.getSource());
    String s = "Action event detected."
    + newline
    + " Event source: " + source.getText()
    + " (an instance of " + getClassName(source) + ")";
    output.append(s + newline);
    public void itemStateChanged(ItemEvent e) {
    JMenuItem source = (JMenuItem)(e.getSource());
    String s = "Item event detected."
    + newline
    + " Event source: " + source.getText()
    + " (an instance of " + getClassName(source) + ")"
    + newline
    + " New state: "
    + ((e.getStateChange() == ItemEvent.SELECTED) ?
    "selected":"unselected");
    output.append(s + newline);
    // Returns just the class name -- no package info.
    protected String getClassName(Object o) {
    String classString = o.getClass().getName();
    int dotIndex = classString.lastIndexOf(".");
    return classString.substring(dotIndex+1);
    public static void main(String[] args) {
    MenuDemo window = new MenuDemo();
    window.setTitle("MenuDemo");
    window.setSize(450, 260);
    window.setVisible(true);

    Yes your are correct. I forgot why I went to 1.5 but until better time come along and I can get a new computer, I will have to live with 1.4.2._06. But, it did fit my problem.

  • Error message from user exit - current screen becomes grayed(non-editable)

    I am working on a Sales Order (VA01/VA02) user exit(USEREXIT_SAVE_DOCUMENT_PREPARE) in MV45AFZZ program. I am validating certain values entered by user in this exit. Based on a condition, I issue a error message e.g. "message e001(ZV) with .....". I expect the processing to interrupt and the system control  returns to the current screen. When there is an error, error message shows up on the status bar, but the current screen is completely grayed out(non-editable), not able to modify the incorrect entries. I keep hitting ENTER but no change to the grayed screen. Is there anything wrong in the way I issue error message?
    I am on ECC6.
    Thanks.

    could you please help me if possible in my senario :-
    I am validating a field(serial number while creating delivery) in standard exit ZXQSMU04 and written a code to display an error message. The functionality is working correctly on validation and displaying the error message. But once the error is getting trigger the serial number field is becoming in gray mode i.e non editable.
    I tried a lot to overcome this issue but not getting success could anyone help me to make the field editable while triggering the error message.
    Please note : Its an exit and not having any message field in export or return table. Also tried with warning and information message.
    Thanks in advance.
    Regards,
    Gautam Kumar

  • How do I save a PDF as non-editable?

    I have a form that I filled out with Adobe Professional 7.0. What options do I select to make sure it saves as non-editable? Thanks for any help.

    Hey David, add some security to it. You can even keep people from printing it if you want to, or even need a password to open it.
    J.R.

  • PO Price - Non Editable {capture from Info record only}

    Hi Experts,
    My client want - PO Price always populated via info record & its in non editable mode.
    What the config required to achieve it.
    Please guide.
    Regards,
    Jackie

    Hi Piyush & Seesen,
    Thanks for your reply.
    Now system doesn't allow user to maintain price manually in PO, it captures it from Info record. But still  i am able to modify inforecord price.
    How can i grey out PO Price {non editable mode in PO}
    Please suggest.
    Regards,
    Jackie

  • Make Non-editable Column in Table Control of ME21N and ME22N

    Hi Experts,
    I was trying to look for a solution to make the columns for field MEPO1320-SLFDT(Stat Deliv. Date), MEPO1320-EEIND (Deliv. Date) and MEPO1211-NETPR (Net Price) from transaction ME21N and ME22N to be non-editable ONLY when Qty Received (MEPO1320-WEMNG) > 0.
    I'd found that the modify screen codes were located at Class CL_TABLE_VIEW_MM, Method MODIFY_SCREEN_TC_LINE but there were no enhancement spots available to add my code. Is there any other method i can use to make those fields non-editable?
    Thanks in advance!
    Cheers,
    Cheng
    Edited by: Cheng Mei Tan on Jun 4, 2009 9:31 AM

    Hi Cheng,
    I think you can use this BAdi: ME_PROCESS_PO_CUST - Enhance Processing of Enjoy Purchase Order.
    Use the method PROCESS_ITEM to control the fields at the item level.
    I think is not possible to make the fields non-editable, however, you can put an error message whenever your condition is verified, and the user won't be able to change the fields.
    Cheers,
    Pedro

  • Field disable or non editable -- goods movements

    Hi team
    your assistace will be highly appreciated.
    I´m working with tx CO11N and after completion of  the requiere data we click on goods movements button and the next  screen  is : "Enter production order confirmation: goods movements" and this shows some fields and what I need is to disable some of them or make them non editable : quantity, storage location and movement type.
    Is it posible through Spro? if yes could you please tell the where.
    I don´t want to create a variant.
    thanks

    I guess Variant is the only option here, atleast thats what my PP consultant had done in my last project.
    There didnt seem to be any other alternative then.

  • Make non-editable sections of webpage?

    I'm designing a site using contribute. I'm wondering if I can
    take a webpage that is already completed and make certain sections
    of it uneditable.... such as the main links, or certain divs... Is
    there a way to do this? Or can this only be accomplished with
    templates?
    Thanks so much for all and any help!

    This is possible to create by handcoding, but you have to
    create editable regions and not non-editable regions.
    Contribute understands the editable region code, also when
    it's not a dreamweaver template (using dreamweaver templates of
    course has a lot of other advantages).
    The code you need looks like this:
    <!-- TemplateBeginEditable name="content"
    -->content<!-- TemplateEndEditable -->
    Place it like this in your page and the lorem ipsum p's are
    non editable, the sentence 'This content is editable...' is
    editable. The head section and title are also editable (convenient
    to adjust meta-tags through contribute):
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
    Transitional//EN" "
    http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="
    http://www.w3.org/1999/xhtml">
    <head>
    <!-- TemplateBeginEditable name="doctitle" -->
    <title>Untitled Document</title>
    <!-- TemplateEndEditable -->
    <!-- TemplateBeginEditable name="head" -->
    <meta name="Keywords" content="keywords" />
    <meta name="Description" content="description" />
    <!-- TemplateEndEditable -->
    <meta http-equiv="Content-Type" content="text/html;
    charset=utf-8" />
    </head>
    <body>
    <p>"Lorem ipsum dolor sit amet, consectetur adipisicing
    elit, sed do eiusmod tempor incididunt ut labore et dolore magna
    aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco
    laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure
    dolor in reprehenderit in voluptate velit esse cillum dolore eu
    fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
    proident, sunt in culpa qui officia deserunt mollit anim id est
    laborum."</p>
    <!-- TemplateBeginEditable name="content" -->This content
    is editable...<!-- TemplateEndEditable -->
    <p>"Lorem ipsum dolor sit amet, consectetur adipisicing
    elit, sed do eiusmod tempor incididunt ut labore et dolore magna
    aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco
    laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure
    dolor in reprehenderit in voluptate velit esse cillum dolore eu
    fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
    proident, sunt in culpa qui officia deserunt mollit anim id est
    laborum."</p>
    </body>
    </html>

  • Make 1 field non-editable while using transaction VA02.

    Hi,
    I want make a field non-editable under tab 'shipping' for transaction VA02. I know one way of doing it by adding code to  MV45AFZZ -> USEREXIT_FIELD_MODIFICATION. is there any other way ( other user-exit / BADI) to achieve the same.

    Hi,
    Please go through this link... It tells you the step to follow....
    http://www.sap-basis-abap.com/sapbs010.htm
    Also please refer these posts..
    Re: Transaction Variants & Variant Transactions
    Re: Transaction Variants

  • Make the 'ASSIGNMENT FIELD' of particular financial Doc type non-editable

    Hi Experts,
    We have an done an Z development, where we are populating critical data in the 'ASSIGNMENT FIELD OF gl account' of a newly created  financial document type (ZD).This document is created through BAPI.
    Now our requirment is to make this 'Assignment field' non-editable .
    Thanks & Regards,
    Vishal

    Go to OB32
    Select Account type and select table with field name ZUONR and double click
    Uncheck the check box Field can be changed
    Srinivas

  • One row as editable and other row as non-editable in table control

    Hi Experts,
               Is this possible to make one row as editable and another row is non editable in table control?
    My Requirement is
    1st row non editable field
    Customer code, description,amount will come from the previous screen this will be non editable for user.
    2nd row editable
    User has to enter the amount in 2nd row here the customer code description will be empty.
    If 4 customer are there
    1,3,5,7 should be non editable and 2,4,6,8 should be editable..
    Pls help me in this issue..
    Thanks in Advance!

    hI
    This is a simple Module POOL program with only Table control and nothing else
    " This is Tested to Enable one row and disabling the next row
    in TOP Include
    controls : tc type tableview using screen 100.
    DATA : OK TYPE SY-UCOMM.
    DATA : ITAB TYPE TABLE OF SPFLI WITH HEADER LINE.
    in PBO
    PROCESS BEFORE OUTPUT.
      MODULE status_0100.
      LOOP AT itab WITH CONTROL tc.
       MODULE TC_MOD.
      ENDLOOP.
    in PAI
    PROCESS AFTER INPUT.
    MODULE USER_COMMAND_0100.
      LOOP AT itab.
      ENDLOOP.
    MODULE status_0100 OUTPUT.
      SET PF-STATUS 'TEST'.
      SET TITLEBAR 'TEST'.
      DESCRIBE TABLE itab LINES tc-lines.
      IF tc-lines = 0.
        tc-lines = 20.
      ENDIF.
    ENDMODULE.                 " STATUS_0100  OUTPUT
    MODULE tc_mod OUTPUT.
      DATA : mod TYPE i.
      LOOP AT SCREEN.
        mod =  tc-CURRENT_LINE MOD 2  .
        IF mod = 1.
          IF screen-name = 'SPFLI-CARRID'.
            screen-input = 0.
            MODIFY SCREEN.
          ENDIF.
        ENDIF.
      ENDLOOP.
    ENDMODULE.                 " TC_MOD  OUTPUT
    Edited by: Ramchander Krishnamraju on Jan 25, 2011 7:17 AM

  • Making particular rows as non editable before displaying the TABLE

    Hi everyone,
                               I would like to know how to make a particular rows as non editable in UI element "TABLE" before it is displayed . The scenario is :
    On entering the Personnel number, I am getting family dependants in the table. Then, I am selecting any of the family members on some condition and saving each member with the request.
    Next time when i enter the same personnel number, I would like to show the table with already saved request for the family members rows as non editable & other members row as editable.????
    Please provide a feasible solution.

    Hi Pradeep,
    follow as per suggested. if not work use cell variants concept. it will work.
    Please check this wiki...
    http://wiki.sdn.sap.com/wiki/display/WDABAP/WebDynproforABAPCellVariants
    Cheers,
    Kris.

Maybe you are looking for

  • Moving files from PC to MAC - what goes wrong?

    And how can i get access to these files? Had to return my laptop at work (PC) and backed everything up to my external HD...brought it home, plug it in to my MAC, and all the important documents will not open. Some word documents that were in zip file

  • Installed New HD - Trying to reinstall OS X - Complicated!!!

    hi thanks for reading in advance... i have an old MBP (late 2008) which started to go wonky on me.  not sure what was wrong, took it to a Mac repair place, they said maybe it's the HD... it kept freezing up on the grey boot screen, or when it was run

  • Elements Organizer and Photoshop Elements Editor

    This question was posted in response to the following article: http://help.adobe.com/en_US/photoshopelements/using/WS287f927bd30d4b1f-7f40da1412e28ac0819 -7fec.html

  • Add AAA Client Errors,Shared Secret value must not be blank.

    hello, When i add the AAA client to the ACS 4.2 90 eveluation software installed on win2003 std OS with SPk 1 gives the below error when entered the shared secret value then submitting it. "Shared Secret value must not be blank" what could br the cau

  • Recon Account Posting

    Hi We have a customer requirement where customer wants to post the the recon account through condition type while billing. These recon accounts are made assigned in VKOA. While billing it is giving error that recon account can't be directly posted to