JTextArea text deselection event

I am doing some custom drawing of Swing components so that I can draw them over a heavyweight component and still support transparency correctly. Now, when using some swing components, not all of the expected action occur. For example, in a JTextArea, after selecting text, clicking inside the text area does not deselect the text (my RenderManager is not being asked to mark it dirty) or with JInternalFrames, hovering over the edges of a resizable frame does not update the mouse cursor like it would do in a normal JFrame.
Are there a set of events I need to listen to that I'm unaware of? I am at a loss as to why it's not asking to mark itself dirty through the RenderManager
Thank you in advance for any help given.
Stephen

Note: When I say "RenderManager", I meant "RepaintManager"
Also, if I add a mouse listener to my JTextArea and have it repaint on a click, the selection gets cleared as expected. So, it seems that the selection is getting cleared but the component isn't marking itself dirty with the RepaintManager.
And thanks for moving my topic; assumed Java programming was as good a location as any, but GUI is probably a better fit.

Similar Messages

  • Setting JTextArea text within a JScrollPane

    Hey all. I'm attempting to use the setText() method of JTextArea to set the text of various areas located in various scroll panes. The general procedure I'm following is to initialize a new JTextArea and JScrollPane within an initializeGui function, set the properties of the JTextArea, then add it to the scroll pane using .getViewport().add(). After that, a separate function goes through all my form fields loading them with whatever data type is appropriate, in the case of the text areas I'm trying to use setText() to set a string. However, after using setText() the text area is displaying nothing. Here's some code for example (workerPane is using a layout manager exclusive to the environment I'm working in, but I don't believe it's the problem).
    workerLabel = new JLabel("Customer Address:");
              JScrollPane sp = new JScrollPane();          
              JTextArea ta = new JTextArea();          
              //set ta's properties to whatever is needed
              ta.addKeyListener(new java.awt.event.KeyAdapter(){
                   public void keyTyped(KeyEvent e){
                        JTextArea text = (JTextArea)e.getSource();                    
                        String txt = text.getText();                    
                        int nameLength = 240;
                        if ( txt.length() >= nameLength ){
                             text.setText ( txt.substring( 0, nameLength-1 ) );                         
                             Toolkit.getDefaultToolkit().beep();                    
              sp.getViewport().add(ta);          
              workerPane.add("3.1.right.top",workerLabel);
              workerPane.add("3.2.left.center",custAddScrollPane);After each area has been initialized, another function is called to load the data into it. Here are some methods I've tried that haven't worked.
    //basic, but leaves an empty field.
    ta.setText(formProperties[2].getStringValue());
    //this results in two NullPointerException warning windows popping
    ta=(JTextArea)sp.getViewport().getView();
    if(formProperties[2].getStringValue() != null)         ta.setText(formProperties[2].getStringValue());
    sp.getViewport().removeAll();
    sp.getViewport().add(ta);Can anyone point me in the right direction as to how to set my textarea's text?

    I usually use the approach given above. The other option is:
    scrollPane.setViewportView( textArea );

  • Captivate 6 Text Entry Events Do Not Pass

    I am a long-time user of Captivate going back to version 2. I've created a simulation course with numerous text entry events that do not validate correctly. I am typically using the TAB key to validate the text entered. I have several lessons where everything works fine, but many that have problems.
    Typically when TAB is used at the end of a key press, you will see focus shift to the first button on the Play bar - and this does not cause any problems. I see this behavior on the events in my course that work. However, for the ones that do not work, I see the focus shifting to the Address Bar and the event will not pass.
    The only workaround I have employed is to use On Focus Lost: Go to Next. This is not a great solution because the text no longer validates with this setting. These events will pass no matter what is entered.
    I would really appreciate your help with this! My course is due soon. I would be happy to provide more information or upload my file for your inspection. Thank you!

    For anyone who might be experiencing the same problem and looking for an answer - this is still 100% broken in Captivate version 6. None of the fixes discussed in the above referenced thread work. I tried playbar widgets, editing the playbars in Flash. No luck.
    Adobe just moves forward from version to version not fixing the bugs they create in prior versions. That's your incentive to upgrade, folks.
    Best workaround I can offer is Use ENTER as your validation keystroke. It doesn't have the same problems associated with TAB. Good luck!

  • How to handle Text  change event in text box in SAP B1

    Hello Expert...
    How to handle Text  change event in source.
    Please define the Event when i change the text in textbox..
    currently i am using the Lost focus event but it is only occur when tab focus lost from that text box.
    So please required solution ASAP..
    Regards,
    Abhinav Lalpurwala
    Edited by: Abhinav Lalpurwala on Aug 5, 2011 3:19 PM

    Hi,
    Catch the et_VALIDATE event, when InnerEvent = False and ItemChanged = True.
                If pVal.EventType = BoEventTypes.et_VALIDATE Then
                    If pVal.InnerEvent = False And pVal.ItemChanged Then
                        'TODO Your code here...
                    End If
                End If
    Regards,
    Vítor Vieira

  • Filling binding bean on text changed event

    I have a form with binding to POJO
    I handle text changed event on one text field.
    When user changes this text, I want binding to push variables to my POJO, so that i could invoke some pojo methods on current data.
    BR

    Hi
    You can use EL for binding
    <af:inputText value="#{bindings.Id.inputValue}" id="it1" autoSubmit="true"/>
    <af:outputText value="#{bindings.Id.inputValue eq test ? bindings.Id.inputValue :null}" id="ot1" partialTriggers="it1"></af:outputText>
    Abhilash S

  • IPhoto "changing text of Events problem"

    All of a sudden I can't edit my texts in events. I tried to reinstall twice but it doesn't work...
    Does anyone has the same problem.
    Please help...
    Thanks.

    lz75
    Welcome to the Apple Discussions.
    http://docs.info.apple.com/article.html?artnum=306305
    Regards
    TD

  • Text deletion events

    hi,
    i am extending the TextInput control, i have managed to catch
    the text typing events...
    my question is:
    how can i catch the text deletion (delete and backspace
    keys) events ??
    thanks,
    jaimon

    Listen for the "keyDown" event, and the examine the
    event.charCode for a value of 8 or 127 respectively.
    If you want to prevent the backspace/delete, it's not so easy
    - you cannot prevent propagation of the keyDown event. Here's what
    I do (not pretty, but it works):
    var caretOffset:uint = textField.selectionEndIndex;
    textField.setSelection(caretOffset, caretOffset);
    textField.replaceSelectedText(' ');
    if (event.charCode == 127)
    textField.setSelection(caretOffset, caretOffset);
    This works by putting a space in the position that's about to
    be deleted or backspaced over, so the end effect after the deletion
    is unchanged. Because backspace also moves us back, we move the
    cursor to after the inserted space.
    Tim

  • Extract text of JTextArea in WindowClosing event()...

    I downloaded the Framework.Java sample code, which creates a new instance of a window. I want to be able to retrieve the text from the JTextArea of a JFrame when the user closes the window.
    I am using this code:
            frame.addWindowListener
           (new WindowAdapter() {
             public void windowClosing(WindowEvent e)
                System.out.println("pane.getText()=" + frame.pane.getText());
              System.exit(0);
            });Unfortunately, I am getting this error:
        "Error: variable pane not found in class.javax.swing.JFrame"How do I get at this text? How do I get the content pane in general? Full source code below:
    import  java.net.*;
    import  javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class Framework extends WindowAdapter {
        public int numWindows = 0;
        private Point lastLocation = null;
        private int maxX = 500;
        private int maxY = 500;
        public Framework() {
            Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
            maxX = screenSize.width - 50;
            maxY = screenSize.height - 50;
            makeNewWindow();
        public void makeNewWindow() {
            final JFrame frame = new MyFrame(this);  //*
            numWindows++;
            System.out.println("Number of windows: " + numWindows);
            if (lastLocation != null) {
                //Move the window over and down 40 pixels.
                lastLocation.translate(40, 40);
                if ((lastLocation.x > maxX) || (lastLocation.y > maxY)) {
                    lastLocation.setLocation(0, 0);
                frame.setLocation(lastLocation);
            } else {
                lastLocation = frame.getLocation();
            System.out.println("Frame location: " + lastLocation);
            frame.setVisible(true);
            frame.addWindowListener
           (new WindowAdapter() {
             public void windowClosing(WindowEvent e)
              System.out.println("pane.getText()=" + frame.Container.getContentPane.getText());
              System.exit(0);
        public static void main(String[] args) {
            Framework framework = new Framework();
    class MyFrame extends JFrame {
        protected Dimension defaultSize = new Dimension(200, 200);
        protected Framework framework = null;
        private Color color = Color.yellow;
        private Container c;
        public MyFrame(Framework controller) {
            super("New Frame");
            framework = controller;
            setDefaultCloseOperation(DISPOSE_ON_CLOSE);
            setSize(defaultSize);
            //Create a text area.
            JTextArea textArea = new JTextArea(
                    "This is an editable JTextArea " +
                    "that has been initialized with the setText method. " +
                    "A text area is a \"plain\" text component, " +
                    "which means that although it can display text " +
                    "in any font, all of the text is in the same font."
            textArea.setFont(new Font("Serif", Font.ITALIC, 16));
            textArea.setLineWrap(true);
            textArea.setWrapStyleWord(true);
            textArea.setBackground ( Color.yellow );
            JScrollPane areaScrollPane = new JScrollPane(textArea);
            //Create the status area.
            JPanel statusPane = new JPanel(new GridLayout(1, 1));
            ImageIcon icoOpen = null;
            URL url = null;
            try
                icoOpen = new ImageIcon("post_it0a.gif"); //("doc04d.gif");
            catch(Exception ex)
                ex.printStackTrace();
                System.exit(1);
            setIconImage(icoOpen.getImage());
            c = getContentPane();
            c.setBackground ( Color.yellow );
            c.add ( areaScrollPane, BorderLayout.CENTER )  ;
            c.add ( statusPane, BorderLayout.SOUTH );
            c.repaint ();
    }

    Hi,
    you get the error-message because pane is not declared in your program anywhere. The JTextArea holds the text - it is declared in the constructor of class MyFrame. The variable textarea holds the reference to this JTextArea - the JTextArea is put in a JScrollPane and the JScrollPane added to the ContentPane of the Frame. After that all is done - at the end of the constructor of class MyFrame - the variable textarea is no longer accessible, because it is declared in the constructor itself and is local to the constructor - which means, it "lives" as long as the constructor is executed.
    One way to let the variable textarea live longer is to declare it outside the constructor - for example in the body of the class where the Container c is declared.Add simply "JTextArea textarea;" there. In the constructor you only use then
    textarea = new JTextArea(....) instead of JTextArea textarea = new JTextArea(...)
    Now the textarea-variable will "live" as long as the instance of the MyFrame-class will be there. If you would be able to access the instance of the MyFrame-class from the windowClosing-method, you would be able to access the textarea too - but you can't in the moment.
    This instance of the MyFrame-class ist constructed in the makeNewWindow-method - here is the same problem as above with the textarea-variable. The variable frame holds the reference to the newly created frame but it is declared inside the method and will not be accessible, when the method has come to an end. So you should declare it outside in the body of class Framework - for example in the place where maxY is declare. Add simply "JFrame frame;" behind the declaration of maxY.
    In the makeNewWindow-method you use
    frame = new MyFrame(this) instead of final JFrame frame = new MyFrame(this)
    Now we are near the solution - the JTextArea is now accessible by frame.textarea - to get the text in the windowClosing-method you now can use frame.textarea.getText().
    There are some other syntax-errors in your text too - your compiler will show them.
    Hope this will help you - I have tried, to explain why it should be done this way - I don't want to post only a few lines of code - sorry, when it is now much to read.
    greetings Marsian

  • Display more than one line of text for events?

    I couldn't find this in the forum... I just recently updated to Leopard. Now when I put events in iCal, it only displays one line of text in the month calendar view. I'd really like to see the whole description of the event, even if it's two or three lines. I can't find anything in preferences that addresses this, and various searches are not yielding anything. Help?
    -mel

    Hi there.
    Usually in iCal if you want more than one line of text for timed events, resizing the window will help. Under all-day events, iCal will always show you one line of text, but if there is more space it will show you more text. So, also resizing the window for this will help to see the text.
    Take care.

  • How to return the month view format on IPhone to show text of events and not dots?

    The month view in my IPhone ICal is now filled with dots to let me know I have an event as opposed to the former view where I could see text at a glance and know what I had to do on certain days.  The month view of days with dots is now worthless to me unless i can change it back to see text.  Also, you have to scroll through to see all the hours in a day.  Is this really necessary?  Who has time to enter in so much activity on their daily calendar that is reqires scrolling through the hours?  Can I make the entire day appear on one screen if I'm in day view?
    Thanks for your help.

    You can see what is similar to the List view by tapping on the magnifying glass. The former Month view with a couple of lines ot text under it no longer exists.
    Feedback to Apple can be made at www.apple.com/feedback and click on the appropriate link.

  • Wrap Text of Event in Month View

    I am unable to find where I can set the display setting for the month view in iCal. My problem is that I have events that are too long to fit in 1 line. Currently, the settings truncate the event to fit in one line on the month view. I'd like to be able to wrap the text so I can read the entire event description.
    How can I adjust the settings to get this right?
    Thank you!

    Ko be,
    Application UI issues are in many cases, caused by a corrupt plist file.
    Quit iCal, and try removing the com.apple.iCal.plist file from your Macintosh HD/Users/yourusername/Library/Preferences Folder. Since that Library is now hidden, you have to use the Finder>Go Menu>Depress the "Option" key>Library. Drag the .plist file to your desktop, and log out/in or restart and check iCal for functionality.
    Also read Apple iCal 5 Office Software Review | Macworld for a description of Lion iCal.

  • JTextArea  -- text growing problem, need scrollbar

    thanks again to DrClap's help!! thank you for your hard work of looking up the API document to get the right parameter for me!! thanks.
    i got one more problem... :(
    it is about the appearance of the output text in the JTextArea.
    with my following code, i could not see the scroll bar of the JTextArea and thus some output text can not be seen:
    class aFrame extends JFrame{
    public aFrame(){
    super(s); setSize(400, 300);
    Container c = getContentPane();
    JTextArea ta = new JTextArea();
    ta.setFont(new Font("Monospaced",Font.PLAIN,12));
    c.add(ta);
    for(int i=0; i<1000; i++) ta.append(i+" ");// some output
    // from this for loop can't be seen in the text area of
    // the frame
    // if i declare "ta" as TextArea ta, then scroll bar is
    // automatically set and thus all the output can be
    // seen. but it is not faithful to JFrame if i do so.
    // how to adjust the code in order to show the full
    // set of output?
    // thanks a lot!!!

    You can also download the Java Swing tutorial free. It should be mandatory reading before posting a question on this form.
    http://java.sun.com/docs/books/tutorial/

  • Two JTextArea text input

    Hi,
    Here is a tough one, if all you gurus would like to give it a try.
    There are two JTextArea components. I would like users to be able to input text in the first JTextarea. When the text reaches the maximum on the line, it should go to the second JTextarea and continue inputting text.
    I need to create an application where the output should be a document with alternating lines of images and text.
    Any thoughts? Thanks alot.

    There are two JTextArea components. I would like
    users to be able to input text in the first
    JTextarea. When the text reaches the maximum on the
    line, it should go to the second JTextarea and
    continue inputting text. You could try calling component.requestFocus() when you want to switch areas but it's kind of a kludge solution.
    I need to create an application where the output
    should be a document with alternating lines of images
    and text.Then don't use JTextArea. Use JTextPane.
    It sounds like your answer could be either JTextPane or a custom solution.

  • Formatting JTextArea text

    I want to take the text of a JTextField and save it on the file system formatting with character length limited to a certain amount per line (say 77) and save any blank lines the user enters. Each line is prefixed with "//$" which I look for when I read it back in. The problem I am running into is when I encounter a blank line. My code looks like this (str is the string from the JTextField.getText() method):
              if(!str.trim().equals(""))
                   try
                        for(x = 0; x < str.length(); x++)
                             while(count != 76 && x < str.length() && !endOfLine)
                                  count++;
                                  if(str.charAt(x) == '\n')
                                       endOfLine = true;
                                  x++;
                             if(x == str.length())
                                  tmpStr+="//$ " + str.substring(start, x) + "\n";
                                  count = 0;
                             else if(endOfLine)
                                  tmpStr+="//$ " + str.substring(start, x);     
                                  start = x;
                                  count = 0;
                                  endOfLine = false;
                             else if(str.substring(start, x).equals(null))
                                  tmpStr+="//$$";
                                  start = x;
                                  count = 0;
                             else                         
                                  tmpStr+="//$ " + str.substring(start, x) + "\n";
                                  start = x;
                                  count = 0;

    Refer to the Java Tutorial at http://java.sun.com/docs/books/tutorial/uiswing/components/textarea.html for more info on how to use the JTextArea. JTextArea only allow you to display plain text, so if you want the selected text to change color, you will have to use the JEditorPane (or its subclass JTextPane). Refer to http://java.sun.com/docs/books/tutorial/uiswing/components/editorpane.html for more info.

  • Print Preview texts from event handler of a web UI component enhancement

    Hello,
    I've enhanced View GSTEXT/List to add Print Preview button. What I've done in the event handler is to read the text with  function module READ_TEXT and I have all my text in the lt_lines internal table. Now I want to View this text in PDF format. I just realized I can't call a smartform directly from my event handler and I also can't call an adobe form to do this for me. Can anyone help me on how to resolve this?

    Hi Khaya,
    I see two things you might have done not quite right:
    Why do you use "READ_TEXT" when all the data is already there in the BOL? Did you ever have a look at the logic the WebClient uses to display the text? Go check it now!
    Of course you can call an Adobe or Smart Form in an event handler. The bigger problem might be getting the response to the user.
    Not knowing your exact logic I would recommend:
    Use the BOL to retrieve all data.
    In the method where you create the button use CL_CRM_WEB_UTILITY to create the JavaScript code for a client callback handler. Then in the handler create the PDF and return it to the user. You can just set the XSTRING to the response.
    cheers Carsten

Maybe you are looking for

  • How do I get removed from garage band community?

    When I started using garage band I signed up for the Apple Community. My mailbox is full of hundreds of posts from the community. The more I delete the more come in. I have rechecked all the settings for privacy. Can anyone help me stop the influx of

  • ABAP Dictionary Search Help

    Hi, after upgrading to Adobe Reader 9.1.0 my interactive forms have started acting strange. For example, when pressing search helps the "wait" pop-up appears but never reaches the search help. Anyone who has any idea what I should do? By the way, eve

  • Which Hardware shud i go? For this requirement.

    Hello all, As per requirement, In Oracle 9i, 1000 tps(transaction per sec) requirement ( 60% insert update and 40 % search operations). Dose oracle 9i ( standard ed.) with 2 CPU machine will handle this requirement ? What will be performance figure o

  • Best way to set up iPhoto; external drive

    HI! I want to set up iphoto in a way that steals less of my ssd drive space. I will buy a usb 3 harddrive, where I store my pictures. In iphoto I just want a reference to the picture on my external harddrive. But when working, some times I want to de

  • Hiding a subform based on field value.

    Dear Friends!   I am trying to hide one subform when I have certain value in text field. I tried following code but it didnt help me at-all. will it be possible for you to show my my mistake. the business case is I am not supposed to display Form 16