How to highlight text in JTextField?

Hi all, I know this is a very simple question but I just couldn't find its solution and I'm rushing for my project.
My question is: how to highlight all the text in JTextField when it gets focus?
Thanks a lot in advance!
Janet

You have to add a FocusListener in the JTextField and override the focusGained() method to select all the text with JTextField.selectAll().
class MyFrame {
  JTextField text = new JTextField();
  // when creating the frame
  text.addFocusListener(new FocusAdapter() {
    public void focusGained(FocusEvent e) {
      doSelectAllText(); 
  void doSelectAllText() {
    text.selectAll();
}Hope this help.

Similar Messages

  • How Do highlight text in the body of an email message in Mac Mail?

    Can anyone tell if IF and HOW I can highlight text in the body of an email message using Mac Mail (in Yosemite).  I do NOT mean MARKUP an attachment.  I want to highlight a word or phrase in the body of my email message.  I know I can change the font color, but can't seem to add a highlight!  Thanks!

    Hi,
    is is possible, - link is below. Works on Yosemite, btw.
    http://www.mihalick.us/how-to-highlight-text-in-yellow-using-apple-mail/

  • How to highlight text in the iCloud web app

    Hi,
    My computer recently broke so I had to use my mom's windows computer to do my homework. I had to use the iCloud web app Pages to do my homework. My assignment requires to be able to highlight stuff so does anyone know how to highlight text in the iCloud web apps?

    You can do this easily by using a "modify class" parameter in your web template.
    Following methods are of your interest to change char/KF headers.
    CAPTION_CELL          changes formats/values of characteristic headers
    STRUCTURE_CELL          changes formats/values of key figure headers
    Hope it helps.
    Hari Immadi
    http://immadi.com
    SEM BW Analyst

  • Does anyone know how to highlight text within a mac mail message?

    Does anyone know how to highlight text within a mac mail message?

    I can't find that option in Mac Mail's editor.  You can use a more feature rich editor like OpenOffice or Pages to create your message.  Then copy/paste into mail.
    Dan

  • How to highlight text with Adobe Reader XI?

    email [email protected]

    Thanks. The PDF file was made from a web site article and I guess this is the same as scanned as I cannot highlight.  The cursor changes but cannot highlight what I want.
    I was able to add text and I did this in Red and will ask the VA to read under the sections marked in Red.
    Thanks,
    Vernon Pobanz
          From: ~graffiti <[email protected]>
    To: vernon pobang <[email protected]>
    Sent: Tuesday, October 7, 2014 11:57 AM
    Subject:  How to highlight text with Adobe Reader XI?
    How to highlight text with Adobe Reader XI?
    created by ~graffiti in Adobe Reader - View the full discussionUse the highlight tool under Comment>Annotations. This will only work if the pdf isn't a scanned image. If that is the case, there is no text to highlight. Please note that the Adobe Forums do not accept email attachments. If you want to embed a screen image in your message please visit the thread in the forum to embed the image at https://forums.adobe.com/message/6800192#6800192 Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page:  To unsubscribe from this thread, please visit the message page at . In the Actions box on the right, click the Stop Email Notifications link.  Start a new discussion in Adobe Reader by email or at Adobe Community For more information about maintaining your forum email notifications please go to http://forums.adobe.com/thread/416458?tstart=0.

  • How to highlight text with a translucent color

    I have to highlight text from a JTextArea, but the color is too dark... So I'd like to highlight with a translucent color. How can I do it ?
    Here is my code :
    JTextArea jt;
    int beginSelect;
    int endSelect;
    Highlighter hl = jt.getHighlighter();
    DefaultHighlighter.DefaultHighlightPainter hld = new DefaultHighlighter.DefaultHighlightPainter(Color.BLUE);
    try {
    hl.addHighlight(beginSelect, endSelect, hld);
    catch (BadLocationException e) {}
    Thank you.

    import javax.swing.plaf.*;
            Color color = new Color(220, 200, 240, 150);
            ColorUIResource colorResource = new ColorUIResource(color);
            UIManager.put("TextArea.selectionBackground", colorResource);Default for windows is [r=49, g=106, b=197]
    and for metal is [r=204, g=204, b=255].

  • How to highlight text in JLabel????

    I m writing code for find functionality(similar to ctrl+f )..
    I have a JTable with some of its cell contains JLabel...
    I want to highlight some part of text from JLabel using using tableCellRenderer
    (eg. text on JLabel is "India" & my search keyword is "In", then only first two letters of JLabel should get highlighted)..
    It works, if Jtable contains string but not for any JComponent(like JLabel, JPanel, JCheckBox etc..) ..
    Please help me out for this....
    NOte: ---
    I m posting some part of code that i have used to highlight string in a JTable cell..
    public Component getTableCellRendererComponent(JTable table, Object value,
                                                         boolean isSelected, boolean hasFocus, int row, int column) {
                 // method to highlight WORD depending upon condition..
                           try {
                              high.addHighlight( i, j, highlight_painter );          // method to highlight word
                         catch (Exception e) {
                              e.printStackTrace();
                return this;
            }thanks in advance
    suyog

    I am posting my code that i am using for highlighting text in JTable...
    But this code is not working, if cell contains JLabel...
    Can you please suggest me any solution to work this code for JLabel with plain text content & with hyperlink (formatted using HTML tags), with out affecting to its original functionality
    (I am not getting what cramick want to suggest... )
    public class TableCellRendererBug{
         // code to highlight the specific WORD in JTable
         Vector vrecord;          // vector used in condition to highlight
         JTable tab;
         public  DefaultHighlighter high ;
             public void highlightWord(JTable table,Vector record){
                  tab=table;
                  vrecord =new Vector(1);
                  vrecord=record;
                  tab.setDefaultRenderer(Object.class, new CellHighlightRenderer());
        class CellHighlightRenderer extends JTextField implements TableCellRenderer {
              DefaultHighlighter.DefaultHighlightPainter highlight_painter =
                        new DefaultHighlighter.DefaultHighlightPainter(new Color(198,198,250));
             public  DefaultHighlighter high ;
            public CellHighlightRenderer() {
                 high = new DefaultHighlighter();       
                 setBorder( BorderFactory.createEmptyBorder() );
                setHighlighter(high);
                  tab.updateUI();
            public Component getTableCellRendererComponent(JTable table, Object value,
                                                         boolean isSelected, boolean hasFocus, int row, int column) {
                 // method to highlight WORD depending upon condition..
                    setFont(table.getFont());
                setValue(value);                    // intialize object
               *    condition to execute addHighlight..
               *    Here i am using  above mentioned Vector & all the things
               if(condition){
                          try {
                              high.addHighlight( start, end, highlight_painter );          // method to highlight word
                         catch (Exception e) {
                              e.printStackTrace();
                     }//if
                return this;
            protected void setValue(Object value) {
                 // method to initialize value of object
                 setText((value == null) ? "" : value.toString());
    }Thanks In advance..
    Suyog

  • How to highlight text in a text box

    In Acrobat 5 Pro you could highlight text created with the "FREE TEXT TOOL", I understand this has been renamed the "TEXT BOX TOOL" in Adobe 9 Pro. I can not highlight text created with the text box tool, can anyone help.
    Thanks,
    Jim E.

    Have you tried the text touchup tool, select the text you want, and right click for the properties. I do not think you can highlight in a text box (the form tool for text).

  • How to Highlight text in DW?

    I've been trying to find an easy way to highlight my text
    with yellow or some other colors. It looks like in DW you need to
    go through 1.5 Mil steps and maybe and hopefully this thing could
    get done. I appreciate if any of you know an easy way to
    highlight/shade the text in DW.
    Thanks.

    <p>This is an <span
    style="background-color:yellow;">example</span> of
    highlighted text.</p>
    Murray --- ICQ 71997575
    Adobe Community Expert
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    http://www.dreamweavermx-templates.com
    - Template Triage!
    http://www.projectseven.com/go
    - DW FAQs, Tutorials & Resources
    http://www.dwfaq.com - DW FAQs,
    Tutorials & Resources
    http://www.macromedia.com/support/search/
    - Macromedia (MM) Technotes
    ==================
    "Alex2378999" <[email protected]> wrote in
    message
    news:f8g0kc$dhk$[email protected]..
    > I've been trying to find an easy way to highlight my
    text with yellow or
    > some
    > other colors. It looks like in DW you need to go through
    1.5 Mil steps and
    > maybe and hopefully this thing could get done. I
    appreciate if any of you
    > know
    > an easy way to highlight/shade the text in DW.
    >
    > Thanks.
    >

  • How to highlight text in OA page

    I am adding some javascript logic in my OAF page and would like to be able to highlight words in the oamessagetextinput bean. Is this possible?

    Its not recommended to use JavaScript to set the focus and cause the highlight. Firstly, its against the consistent behaviour across browsers and secondly its against useability issues.
    Please use Formattedtext bean to show highlighted text, readonly.
    Thanks

  • How to highlight text in pdf file programmatically

    I am using below mentioned code to highlight text programmaticaly using VB.net But required text is getting selected but doen't get permanently highlighted. Can anybody help me out.
    Dim gAvDoc As
    Acrobat.CAcroAVDoc 
    Dim myhitlist As
    Acrobat.CAcroHiliteList 
    Dim mypdpage As
    Acrobat.CAcroPDPage 
    Dim acroPageView As
    Acrobat.CAcroAVPageView 
    Dim textSelect As
    Acrobat.CAcroPDTextSelect 
    Dim gPDFPath As
    String
    Dim gApp AsAcrobat.AcroApp 
    gPDFPath =
    "C:\Test.pdf"
    gApp = CreateObject("AcroExch.App") 
    gApp.Show()
    gAvDoc = CreateObject("AcroExch.AVDoc") 
    gAvDoc.Open(gPDFPath,
    "")acroPageView = gAvDoc.GetAVPageView()
    acroPageView.GoTo(1)
    myhitlist = CreateObject(
    "AcroExch.HiliteList")myhitlist.Add(50, 10)
    mypdpage = acroPageView.GetPage()
    textSelect = mypdpage.CreateWordHilite(myhitlist)
    gAvDoc.SetTextSelection(textSelect) 
    gAvDoc.ShowTextSelect()
    gAvDoc.Close(True) 

    Patrick on writting saving code also its not hightlighting the text. Text gets selected but it doen't get highlighted with yellow color...
    Dim gAvDoc As
    Acrobat.CAcroAVDoc 
    Dim myhitlist As
    Acrobat.CAcroHiliteList 
    Dim mypdpage As
    Acrobat.CAcroPDPage 
    Dim acroPageView As
    Acrobat.CAcroAVPageView 
    Dim textSelect As
    Acrobat.CAcroPDTextSelect 
    Dim gPDFPath As String 
    Dim gApp As Acrobat.AcroApp 
    Dim mypddoc As Object
    gPDFPath ="C:\Test.pdf"
    'Initialize Acrobat by creating App object
    gApp = CreateObject("AcroExch.App")mypddoc = CreateObject(
    "AcroExch.PDDoc") 
    gApp.Show()
    mypddoc.Open(gPDFPath)
    gAvDoc = CreateObject("AcroExch.AVDoc") 
    gAvDoc = mypddoc.OpenAVDoc("testing")acroPageView = gAvDoc.GetAVPageView()
    acroPageView.GoTo(1)
    myhitlist = CreateObject(
    "AcroExch.HiliteList")myhitlist.Add(50, 10)
    mypdpage = acroPageView.GetPage() 
    textSelect = mypdpage.CreateWordHilite(myhitlist)
    gAvDoc.SetTextSelection(textSelect)
    gAvDoc.ShowTextSelect()
    mypddoc.Save(PDSaveFull, gPDFPath)
    gAvDoc.Close(True)

  • How to highlight text in a screen grab?

    I did a screen grab from imdb (Internet Movie DataBase) off the Internet.  It's currently in .png format.
    I want to highlight part of the text in the text in this picture as if I were using a yellow highlighter marker.  I've tried everything I can think of but so far no dice.
    It seems that the thing to do is to choose Tools > Mark Up, but Mark Up is grayed out.
    I know this is possible because a guy I work with does it all the time.  But it's too late to call him, and he's fairly irrascible anyway.  And I know I did it once a while ago.
    Can someone help?  Thanks.

    I'd never used Grab before, so just did so. It's an awfully simple app, it seems - offers some capture controls the keyboard commands don't (such as timed and full window), but doesn't seem to be able to do anything other than capture an image. Its Preferences are bare-bones.
    I had to open my test image in Preview to make any annotations. That was easy - save the image in Grab to the desktop and name it, then a double-click of the file opened it in Preview.
    So, we're back to Preview.
    Don't understand why the annotation tools aren't available to you in Preview.
    Edit - -
    Just rebooted into Snow Leopard to do some testing. No matter what I tried, new screenshot using keyboard or Grab, fiddling with settings, I could not get Preview to not allow selecting the Rectangle tool.
    Only other thing I can think of - do a Get Info on the screenshot file, check the permsissions at the bottom of the Get Info window.

  • How do I highlight text in Macromedia Dreamweaver MX 2004

    HI to all Forum Participants:
    HI to anyone:
    I posted a question on how do I highlight text in Dreamweaver MX 2004, to both the Dreamweaver Development Toolbox General Discussion Forum and the Dreamweaver Extension Forum on Tuesday, 6/16/2009 or Wednesday, 6/17/2009, saying this:
    HI Anyone:
    I have looked under Help and Tutorials in Dreamweaver MX 2004, and I am having a heck of a time finding out how to highlight text in Dreamweaver MX 2004.
    Do any of you know how to do this actually in Dreamweaver MX 2004?  Say I wanted to highlight this text, all in Yellow:
    This is sample highlighted text.
    How would I do it?
    Thank you,
    Jon Lutz
    Promoter Power LLC
    Email: [email protected]
    And I got this response from pziecana, in the Dreamweaver Development Toolbox General Discussion:
    Re: How do I highlight text in Dreamweaver MX 2004
    The simplest way is to use a span and set a background-color for the text you wish to highlight.
    e.g.
    <span class="graybg">This is some text</span>
    css for above -
    .graybg{
       backgroung- color: #666666;
    This would give you a gray background.
    HTH
    PZ
    I tried both, and neither worked.  Any other ideas on how to do this?  I cannot believe it is so hard to do this in Dreamweaver MX 2004, highlighting text.  I'm even enclosing an attachment showing how I did this in the <span class="graybg">This is some text</span> above.
    Thank you,
    Jon Lutz
    Promoter Power LLC

    Hi,
    Looking at your screen shot, you didn't add the css.
    <!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>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    <style type="text/css">
    .greybg {
        background-color:#999999;
    </style>
    </head>
    <body>
    <span class="greybg">This is my text</span>
    </body>
    </html>

  • How do I highlight text in Dreamweaver MX 2004

    HI to all Dreamweaver extension Forum Participants:
    HI to anyone:
    I posted a question on how do I highlight text in Dreamweaver MX 2004, to both the Dreamweaver Development Toolbox General Discussion Forum and the Dreamweaver Extension Forum on Tuesday, 6/16/2009 or Wednesday, 6/17/2009, saying this:
    HI Anyone:
    I have looked under Help and Tutorials in Dreamweaver MX 2004, and I am having a heck of a time finding out how to highlight text in Dreamweaver MX 2004.
    Do any of you know how to do this actually in Dreamweaver MX 2004?  Say I wanted to highlight this text, all in Yellow:
    This is sample highlighted text.
    How would I do it?
    Thank you,
    Jon Lutz
    Promoter Power LLC
    Email: [email protected]
    And I got this response from pziecana, in the Dreamweaver Development Toolbox General Discussion:
    Re: How do I highlight text in Dreamweaver MX 2004
    The simplest way is to use a span and set a background-color for the text you wish to highlight.
    e.g.
    <span class="graybg">This is some text</span>
    css for above -
    .graybg{
       backgroung- color: #666666;
    This would give you a gray background.
    HTH
    PZ
    I tried both, and neither worked.  Any other ideas on how to do this?  I cannot believe it is so hard to do this in Dreamweaver MX 2004, highlighting text.  I'm even enclosing an attachment showing how I did this in the <span class="graybg">This is some text</span> above.
    Thank you,
    Jon Lutz
    Promoter Power LLC

    HI PZ:
    Here is the new Code:
    This is some text .
    I'm trying to highlight this text in yellow or gray.
    Can anyone help me with this?
    Thank you,
    Jon Lutz
    Promoter Power LLC
    This is some highlighted text
    But I still don't see any of the text higlighted in gray in the browser?
    What's up with that?  Man, Dreamweaver is so hard to get to highlight text -
    GOOD GRIEF, Why can't Adobe make it easy?  What a Pain!!!
    Go to http://promoterpower.com/test.html, and you will see what I mean about
    any of the text being highlighted.
    Thank you,
    Jon Lutz
    Promoter Power LLC

  • How to highlight All text in Control / Indicator?

    I need a  VI, that pressing a button I could select all text in control or indicator to be able to copy it then by pressing CTRL + C.
     I tried playing with Property node with select-start, select-end, but no results.
    Also didn't find any documentation or examples on how to highlight text in indicator.
    Could anyone help with this?
    Any advice/tip much appreciated. Thanks in advance.
    Solved!
    Go to Solution.

    The help for 'Selection' mentions that you need to set Key Focus to the control first.
    Also there is a system method to copy a string to the system clipboard.
    Ton
    Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
    Nederlandse LabVIEW user groep www.lvug.nl
    My LabVIEW Ideas
    LabVIEW, programming like it should be!

Maybe you are looking for

  • Converting DVD Files to DV with Toast and Storage Issues

    Hello all. In regard to my previous posting of converting to DV in Toast, I have started this new thread because I can't seem to reply to the other posting. When I originally dragged the Video TS folder from the DVD into the Toast window, it somehow

  • Entire Table not visible/ transferred to a file on application server

    HI Experts, My req is to pass an entire internal table to a file on the application server. How ever some of the fields in the table are not shown / transferred when i check that file. The fields are not visible when i try to scroll side wise. When I

  • Massive memory consumption resulting in massive page file

    Platform: Windows XP on Dell precision M60. I GByte RAM, Oracle 10g (10.0.2), Oracle Http Server, APEX 3.1.1 Have a page which runs sql query .. select AS_SEEN_ON_ACW(:P51_MESSAGE, :P51_text_col, :P52_backgnd_col) AS "TEXT" from DUAL The functions in

  • Oracle 10G forms not running.......very urgent

    Hi all, shayan here...... i have just installed oracle databse 10g and oracle 10G developer........i have done it first time....the forms is not running even the test form is not running....i have start the OCJ4 but still the same result.............

  • Problem in storing korean Characters in Oracle 10g

    Hi All, Below are the current setup. OS : Windows Oracle Version : 10G Database Character Set : AL32UTF8 NLS_LANG = KOREAN_KOREA.KO16MSWIN949 (in windows) I can able to see Korean characters in MS Word & MS Excel. I copied some of the korean characte