Selecting multiple text in JTextArea

Howdy Java folks! I've been busting my butt trying to select more than one piece of text in a JTextArea. For example, I would like to:
textArea.select(0, 4); // and then select another piece of text
textArea.select(7, 9); // and show both text snippets highlighted
But I would like to keep both and possible more pieces of text highlighted. The 2nd select() will override the first thus only showing the last area selected.
Can anyone point me in the right direction? Thanks a mucho.

Try this. It selects vertical block of text.
best regards
Stas
import java.awt.*;
import java.awt.event.*;
import java.awt.datatransfer.*;
import javax.swing.*;
import javax.swing.text.*;
import javax.swing.plaf.*;
import javax.swing.plaf.basic.*;
public class Test
JFrame frame;
JTextArea ta;
public static void main(String args[])
new Test();
public Test()
frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
ta=new JTextArea("test11111\ntest22222\ntest33333\ntest44444\ntest55555\n");
ta.setCaret(new Caret_());
JScrollPane scroll=new JScrollPane(ta);
frame.getContentPane().setLayout(new BorderLayout());
frame.getContentPane().add(scroll,BorderLayout.CENTER);
JButton copy=new JButton("Copy");
ActionListener lst=new ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
Highlighter.Highlight[] selections= ta.getHighlighter().getHighlights();
String text="";
int cnt=selections.length;
for (int i=0; i<cnt; i++) {
int start=selections.getStartOffset();
int end=selections[i].getEndOffset();
String selectedText=ta.getDocument().getText(start,end-start);
text+=selectedText+'\n';
System.err.println(selectedText);
StringSelection ss=new StringSelection(text);
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(ss,ss);
catch (Exception ex) {
ex.printStackTrace();
copy.addActionListener(lst);
frame.getContentPane().add(copy,BorderLayout.SOUTH);
frame.setSize(300,200);
frame.setVisible(true);
class Caret_ extends DefaultCaret {
Point lastPoint=new Point(0,0);
public void mouseMoved(MouseEvent e) {
super.mouseMoved(e);
lastPoint=new Point(e.getX(),e.getY());
public void mouseClicked(MouseEvent e) {
super.mouseClicked(e);
getComponent().getHighlighter().removeAllHighlights();
protected void moveCaret(MouseEvent e) {
Point pt = new Point(e.getX(), e.getY());
Position.Bias[] biasRet = new Position.Bias[1];
int pos = getComponent().getUI().viewToModel(getComponent(), pt, biasRet);
if(biasRet[0] == null)
biasRet[0] = Position.Bias.Forward;
if (pos >= 0) {
setDot(pos);
Point start=new Point(Math.min(lastPoint.x,pt.x),Math.min(lastPoint.y,pt.y));
Point end=new Point(Math.max(lastPoint.x,pt.x),Math.max(lastPoint.y,pt.y));
customHighlight(start,end);
protected void customHighlight(Point start, Point end) {
getComponent().getHighlighter().removeAllHighlights();
int y=start.y;
int firstX=start.x;
int lastX=end.x;
int pos1 = getComponent().getUI().viewToModel(getComponent(), new Point(firstX,y));
int pos2 = getComponent().getUI().viewToModel(getComponent(), new Point(lastX,y));
try {
getComponent().getHighlighter().addHighlight(pos1,pos2,((DefaultHighlighter)getComponent().getHighlighter()).DefaultPainter);
catch (Exception ex) {
ex.printStackTrace();
y++;
while (y<end.y) {
int pos1new = getComponent().getUI().viewToModel(getComponent(), new Point(firstX,y));
int pos2new = getComponent().getUI().viewToModel(getComponent(), new Point(lastX,y));
if (pos1!=pos1new) {
pos1=pos1new;
pos2=pos2new;
try {
getComponent().getHighlighter().addHighlight(pos1,pos2,((DefaultHighlighter)getComponent().getHighlighter()).DefaultPainter);
catch (Exception ex) {
ex.printStackTrace();
y++;

Similar Messages

  • How do I select multiple text in Pages

    I'm using the newest version of pages.
    In MS office WORD, I can hold the Ctrl key and with multiple klick in the text I can select multiple text.
    Does pages has the similar function?

    Not possible in Pages 5.2.2, this has been removed by Apple along with 110 features.
    In Pages '09 you hold down the command key, the exact same equivalent as in Word for Windows.
    Peter

  • Cannot select multiple text items simultaneously

    Since upgrading to the latest Pages, I can no longer select multiple letters/words by holding down command. I used to use this to edit multiple things (titles, for example) all at once (make bold, underlined, italicized, larger font, coloured, etc.). Now, however, I have to select each letter/word one at a time and edit them individually.
    Is this just a bug or is there a new way of selecting multiple text characters simultaneously for editing?
    Thanks!

    There is no fix by any means.
    Switching from Word to Pages v5 (any release) is like giving up oxygen for a vacuum. The time that you will expend searching for feature/functionality omissions in Pages v5 that you had in MS Word will just suck the life out of you.

  • How to select multiple substring in JTextarea at the same time?

    I want to select multiple substring in a jtextarea at the same time by select(start,end) method, turns out only the last substring is highlighted, how to implement my goal?

    jamesybaby wrote:
    What you got so far? A SCCEE would be nice?my aim is to search key words in jtextarea and highlight all matched result.
    package frame;
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.util.regex.Matcher;
    import java.util.regex.Pattern;
    public class FrmSelect extends JFrame {
        public FrmSelect() throws HeadlessException {
            setSize(800, 600);
            final JTextField tfKey = new JTextField();
            tfKey.setPreferredSize(new Dimension(200, 20));
            final JTextArea taContent = new JTextArea();
            JScrollPane jsp = new JScrollPane(taContent);
            tfKey.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    String key = tfKey.getText();
                    String content = taContent.getText();
                    String[] splited = content.split(key);
                    Pattern ptn = Pattern.compile(key, Pattern.CASE_INSENSITIVE + Pattern.MULTILINE);
                    Matcher matcher = ptn.matcher(content);
                    taContent.requestFocusInWindow();
                    while (matcher.find()) {
                        int start = matcher.start();
                        int end = matcher.end();
                        taContent.select(start, end);
            add(tfKey,BorderLayout.SOUTH);
            add(jsp,BorderLayout.CENTER);
            setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            setVisible(true);
        public static void main(String[] args) {
             new FrmSelect();
    }please copy below into the jtextarea and type key 'prop' in the jtextfield, press return.
    prop1adsfasfd
    prop2adsfasdfadsf
    prop3asdfasdfasdf

  • Select Multiple Text Areas

    How can you select multiple (but separate) lines of text? In
    most other programs shift lets you select from one point to
    another, and control lets you pick different points within the text
    body. Is dreamweaver capable of this?

    Matt,
    > How can you select multiple (but separate) lines of
    text? In most other
    > programs shift lets you select from one point to
    another, and control lets you
    > pick different points within the text body. Is
    dreamweaver capable of this?
    DW only allows discontiguous selections for table cells and
    position:absolute elements.
    HTH,
    Randy

  • Using the CTRL button to select multiple text segments in Design Editor

    Hi there,
    This may be a fairly elementary question, however I'm very new to RoboHelp.
    I'm currently building an online help text system, and when formatting my html files in Design Editor, I have to apply styles one at a time. I was hoping RoboHelp would have a function identical to Microsoft Word whereby holding down the CTRL key would allow you to select various segments in the file and apply the style. Eg. selecting only text you want to apply Heading 3 to.
    If RoboHelp does not have this functionality, this project will take me in the vicinity of 7 years to complete. Thanks for your time.
    Regards,
    PK

    No it doesn't work that way. What you need to do is create some character styles in your style sheet and apply those.
    Paragraph styles are defined something like
    P {
        font-size: 10pt;
        margin-top: 0pt;
        margin-bottom: 6pt;
        font-family: Verdana, sans-serif;
        color: #000000;
        font-weight: normal;
    P.Normal-Indent {
        margin-left: 20pt;
    where the second P definition will inherit all that is in P plus add the indent.
    When you select those styles, they will be applied to the whole paragraph.
    You can also create characters classes. If you do it within RoboHelp, RH will write the CSS code for you. If you edit the CSS outside RH, then instead of writing P or some other tag, you would normally start with the full stop so you might have
    .code {
        font-size: xx-small;
        font-family: Courier;
    to apply the Courier font to a selection in any paragraph style.
    In RoboHelp you need to prefix the character code with "span" to make it display in the dropdown, thus you would need:
    span.code {
        font-size: xx-small;
        font-family: Courier;
    See www.grainge.org for RoboHelp and Authoring tips

  • Is command+hold for selecting multiple text gone?

    I recently updated to a laptop with os x version 10.9.5. On my previous laptop I could select multiple, non-consecutive words by holding down the command key, which was extremely useful when re-arranging my notes or creating study guides for myself. However, on my new laptop I can't get this feature to work, and I'm wondering if anyone knows whether it's been disabled in the newer version of pages or if there's a different shortcut now?
    Thank you for any feedback.

    All Pages v5 versions cannot select non-consecutive words. This capability exists in Pages ’09, which is the more functional, and feature-laden word processor.

  • Select higlighted text in JTextArea

    Hello,
    I am developing a swing application and have a JTextArea included. In the JTextArea I highlight one or more words with the addHighlight method. Now the user should also be able to select text, especially the highlighted text. But when I select some highlighted text, it does not change the color, so the user is not aware that he selected text.
    How can I implement the intended behaviour?
    Thanks in advance
    Sandra

    1) Change the style of highlights so that both highlights are painted:
    DefaultHighlighter highlighter =  (DefaultHighlighter)textComponent.getHighlighter();
    highlighter.setDrawsLayeredHighlights(false);2) You need to use a different color highlighter to distinguish the highlighted text from the selected text:
    Highlighter.HighlightPainter cyanPainter =
        new DefaultHighlighter.DefaultHighlightPainter( Color.cyan );
    textComponent.getHighlighter().addHighlight( 8, 15, cyanPainter );

  • CS3, VBS, Selecting multiple text frames in a region is very slow

    Hello,
    I'm writing a script that selects a large crossword grid (19cm x 19cm), and changes the font and alignment before exporting out as an eps.
    When I run the code below, it starts off selecting the frames quickly and then gradually slows to a crawl, before being painfully slow at the end. It takes 35mins to run it on the clues grid and then the solution grid.
    Can anyone think of a way to rewrite the code so it's quicker? Or are there some settings that could be changed so it handles better? I've changed the Display Performance settings to the bare minimum, but it only has a little effect.
    Thanks for any help ... Nigel
    rem Selects grid and fixes text
    Set mySolPage = myDocumentA.Pages.Item(2)
    For myCounter = 1 to mySolPage.TextFrames.Count
    Set myTextFrame = mySolPage.TextFrames(myCounter)
    myBounds = myTextFrame.GeometricBounds
    If myBounds(0) > 35 and myBounds(1) > 5 and myBounds(2) < 240 and myBounds(3) < 210 Then
    myTextFrame.select(idSelectionOptions.idaddTo)
    myTextFrame.Texts.Item(1).AppliedFont = "Tahoma"
    myTextFrame.Texts.Item(1).fontstyle = "Bold"
    myTextFrame.Texts.Item(1).baselineShift = 0
    myTextFrame.textFramePreferences.VerticalJustification = idVerticalJustification.idCenterAlign
    myTextFrame.textFramePreferences.ignoreWrap = 1
    myTextFrame.textFramePreferences.firstBaselineOffset = idFirstBaseline.idAscentOffset
    else
    myTextFrame.select(idSelectionOptions.idremoveFrom)
    End If
    Next

    hi Nigel,
    1) move your TextFrames to separate layer - then you don't need to check Bounds
    2) turn OFF redrawing:
    Property EnableRedraw As Boolean
    Member of InDesign.ScriptPreference
    If true, enables redraw during script execution.
    3) create and use Para or Char Style - then you don't need to apply many times same params
    myTextFrame.ParentStory.Texts.Item(1).AppliedParagraphStyle = myParaStyle
    or
    call myTextFrame.ParentStory.Texts.Item(1).ApplyParagraphStyle(myParaStyle,True)
    and why you have:
    else
    myTextFrame.select(idSelectionOptions.idremoveFrom)
    there is no Select command ...
    but if you have Select command somewhere before - you can iterate .Selection collection - so you don't need to check bounds
    robin
    www.adobescripts.com

  • Selecting multiple text layers bug

    I have found this post from April where the bug was acknowledged in the beta: http://forums.adobe.com/message/4306413#4306413.
    I now have the official release of CS6, and I am still seeing this issue. And for clarification, here's what the issue is:
    - I start off creating a text layer with a font size of 20px.
    - I then transform this layer to make it larger.
    - I copy the layer over so I have identical text layers.
    - When I select each individually, I am shown the new, larger font size, we'll just say 40px. But when I select both together, it shows the original font size of 20px in the character palette. When I increase the font size with both selected to say 30px, it actually makes the text more like 60px.
    Will this bug actually get fixed?
    Thanks for any insight you can give.
    And for more info, I am running CS6 off of OSX Lion.

    I was going to suggest a script, but it seems that there are major bugs in the javascript DOM.
    It will only set the size if the text has not been transformed and then is not acurate (+- .5), this is a bug.
    If the text has been transformed the new text size has to be divided by the transform factor, this is a bug.
    Tested with Windows 7 and Photoshop CS6 version 13.0.1 so don't know what state other versions are in.
    This script will work for the above version and O.S.
    N.B. if Photoshop gets the bugs fixed this script will no longer work correctly!
    #target photoshop
    app.bringToFront();
    if(documents.length) app.activeDocument.suspendHistory('Set Font Size', 'main()');
    function main(){
    var win = new Window('dialog','Set Font Size');
    g = win.graphics;
    var myBrush = g.newBrush(g.BrushType.SOLID_COLOR, [0.99, 0.99, 0.99, 1]);
    g.backgroundColor = myBrush;
    win.p1= win.add("panel", undefined, undefined, {borderStyle:"black"});
    win.g1 = win.p1.add('group');
    win.g1.orientation = "row";
    win.title = win.g1.add('statictext',undefined,'Set Font Size');
    win.title.alignment="fill";
    var g = win.title.graphics;
    g.font = ScriptUI.newFont("Georgia","BOLDITALIC",22);
    win.g5 =win.p1.add('group');
    win.g5.orientation = "row";
    win.g5.alignment='left';
    win.g5.rb1 = win.g5.add('radiobutton',undefined,'All text layers');
    win.g5.rb2 = win.g5.add('radiobutton',undefined,'Selected text layers');
    win.g5.rb1.value=true;
    win.g10 =win.p1.add('group');
    win.g10.orientation = "row";
    win.g10.alignment='left';
    win.g10.st1 = win.g10.add('statictext',undefined,'Please enter text size..');
    win.g10.et1 = win.g10.add('edittext');
    win.g10.et1.preferredSize=[50,20];
    win.g10.et1.onChanging = function() {
      if (this.text.match(/[^\-\.\d]/)) {
        this.text = this.text.replace(/[^\-\.\d]/g, '');
    win.g100 =win.p1.add('group');
    win.g100.orientation = "row";
    win.g100.alignment='fill';
    win.g100.bu1 = win.g100.add('button',undefined,'Set Font Size');
    win.g100.bu1.preferredSize=[130,25];
    win.g100.bu2 = win.g100.add('button',undefined,'Cancel');
    win.g100.bu2.preferredSize=[130,25];
    win.g100.bu1.onClick=function(){
    if(win.g10.et1.text == ''){
        alert("No text size has been entered!");
        return;
    win.close(0);
    var txtList = new Array();
    if(win.g5.rb1.value){
        txtList = getTxtLayers();
        }else{
    var sels = getSelectedLayersIdx();
    for(var z in sels){
    var isTxtArray = isTxtLayer(Number(sels[z]));
    if(isTxtArray == false) continue;
    isTxtArray = String(isTxtArray).split(',');
        txtList.push([[Number(isTxtArray[0])],[String(isTxtArray[1])]]);
    for(var s in txtList){
        selectLayerById(Number(txtList[s][0]));
    if(String(app.version).match(/^\d+/) == 13){
    if(getTextdivideFactor() != 0){
    app.activeDocument.activeLayer.textItem.size= (Number(win.g10.et1.text)/Number(getTextdivideFactor()));
    }else{
        app.activeDocument.activeLayer.textItem.size= (Number(win.g10.et1.text));
    }else{
        app.activeDocument.activeLayer.textItem.size= (Number(win.g10.et1.text));
    win.show();
    function getTextdivideFactor(){
    var ref = new ActionReference();
    ref.putEnumerated( charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
    var desc = executeActionGet(ref).getObjectValue(stringIDToTypeID('textKey'));
    var textSize =  desc.getList(stringIDToTypeID('textStyleRange')).getObjectValue(0).getObjectValue(stringIDToTypeID('textStyle')).getDouble (stringIDToTypeID('size'));
    if (desc.hasKey(stringIDToTypeID('transform'))) {
                var mFactor = desc.getObjectValue(stringIDToTypeID('transform')).getUnitDoubleValue (stringIDToTypeID("yy") );
                return mFactor;
    return 0;
    function selectLayerById(ID, add) {
        add = (add == undefined)  ? add = false : add;
    var ref = new ActionReference();
    ref.putIdentifier(charIDToTypeID('Lyr '), ID);
    var desc = new ActionDescriptor();
    desc.putReference(charIDToTypeID('null'), ref);
    if (add) {
      desc.putEnumerated(stringIDToTypeID('selectionModifier'), stringIDToTypeID('selectionModifierType'), stringIDToTypeID('addToSelection'));
    desc.putBoolean(charIDToTypeID('MkVs'), false);
    executeAction(charIDToTypeID('slct'), desc, DialogModes.NO);
    function isTxtLayer(idx){
    var ref = new ActionReference();
    ref.putIndex( charIDToTypeID('Lyr '), idx );
    var desc = executeActionGet(ref);
    var isTxt = new Array();
    if(desc.hasKey(stringIDToTypeID('textKey'))){
    var Id = desc.getInteger(stringIDToTypeID( 'layerID' ));
    var layerName = desc.getString(charIDToTypeID( 'Nm  ' ));
    isTxt.push([[Id],[layerName]]);
    return isTxt;
    }else{ return false;}
    function getTxtLayers(){
       var ref = new ActionReference();
       ref.putEnumerated( charIDToTypeID('Dcmn'), charIDToTypeID('Ordn'), charIDToTypeID('Trgt') );
       var count = executeActionGet(ref).getInteger(charIDToTypeID('NmbL')) +1;
       var Names=[];
    try{
        activeDocument.backgroundLayer;
    var i = 0; }catch(e){ var i = 1; };
       for(i;i<count;i++){
           if(i == 0) continue;
            ref = new ActionReference();
            ref.putIndex( charIDToTypeID( 'Lyr ' ), i );
            var desc = executeActionGet(ref);
            var layerName = desc.getString(charIDToTypeID( 'Nm  ' ));
            var Id = desc.getInteger(stringIDToTypeID( 'layerID' ));
            if(layerName.match(/^<\/Layer group/) ) continue;
            if(desc.hasKey(stringIDToTypeID("textKey"))) Names.push([[Id],[layerName]]);
    return Names;
    function getSelectedLayersIdx(){
          var selectedLayers = new Array;
          var ref = new ActionReference();
          ref.putEnumerated( charIDToTypeID("Dcmn"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
          var desc = executeActionGet(ref);
          if( desc.hasKey( stringIDToTypeID( 'targetLayers' ) ) ){
             desc = desc.getList( stringIDToTypeID( 'targetLayers' ));
              var c = desc.count
              var selectedLayers = new Array();
              for(var i=0;i<c;i++){
                try{
                   activeDocument.backgroundLayer;
                   selectedLayers.push(  desc.getReference( i ).getIndex() );
                }catch(e){
                   selectedLayers.push(  desc.getReference( i ).getIndex()+1 );
           }else{
             var ref = new ActionReference();
             ref.putProperty( charIDToTypeID("Prpr") , charIDToTypeID( "ItmI" ));
             ref.putEnumerated( charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
             try{
                activeDocument.backgroundLayer;
                selectedLayers.push( executeActionGet(ref).getInteger(charIDToTypeID( "ItmI" ))-1);
             }catch(e){
                selectedLayers.push( executeActionGet(ref).getInteger(charIDToTypeID( "ItmI" )));
         var vis = app.activeDocument.activeLayer.visible;
            if(vis == true) app.activeDocument.activeLayer.visible = false;
            var desc9 = new ActionDescriptor();
        var list9 = new ActionList();
        var ref9 = new ActionReference();
        ref9.putEnumerated( charIDToTypeID('Lyr '), charIDToTypeID('Ordn'), charIDToTypeID('Trgt') );
        list9.putReference( ref9 );
        desc9.putList( charIDToTypeID('null'), list9 );
        executeAction( charIDToTypeID('Shw '), desc9, DialogModes.NO );
        if(app.activeDocument.activeLayer.visible == false) selectedLayers.shift();
            app.activeDocument.activeLayer.visible = vis;
          return selectedLayers;

  • Multiple text selections

    Having made the transition from Word to ID CS4, one of the things I miss most is the ability to select multiple text instances (by holding down Ctrl as you select them with the mouse).
    Or is this possible in ID CS4 via an alternative route?

    Are you telling me it may be time to upgrade my copy of Word?
    Actually, I think you're being mislead somewhat.
    Let's be clear:
    In Word 2003 and 2007, you can "mouse-select" text within multiple text boxes, (holding down Ctrl).
    In Word as far back as I can remember, (and I'm not young), you could always hold down Alt while drag-selecting to make a vertical selection, (described earlier in this thread as selecting bullet characters only). Very handy when cleaning up someone else's tab disaster.
    In Word, you CANNOT select dis-contiguous text that all resides on the same open page. At least I have yet to do it.
    In ID, you indeed CAN Pick-Tool select multiple text frames and apply a single paragraph style to all.

  • Editing Multiple Text layers in Photoshop CC

    Hi,
    I have a problem when tyring ot edit multiple text layers and it's really a big problem as it crops up with virtually every design I do (websites, games apps...)
    In previous versions of PS, you could select multiple text layers and edit them in bulk, so for exmaple, select a number of text layers, then change their font size (to say 20pt)... done.
    However, with CC, there seems to be some odd 'ratio' editing goign on - if  I select multiple text layers of different size and edit them (to all be 20pt, for example), it seems to just 'add' 20pt to what ever font size the individual layers were
    It's a real issue/pain for me (and I suspect many others)
    Please is there a fix or a way to switch off this 'feature'?
    So to clarrify, I want to edit multiple (often different) text layers in one go to be the same font size... like I used to be able to.
    Thanks.

    The last few times we saw this, it was due to a bug in a video card driver.
    Please update your video card driver from the GPU maker's website.

  • Can't delete multiple texts

    Is there any way we can highlight and delete multiple emails on Blend as we can do using 'Select More' option on the device The documentation is particularly poor on this

    Hi 
    Thanks for reaching out! 
    To select multiple text messages, or emails you have two options ; 
    Option 1 (Selecting a lot of messages at once using the Shift key)
    1. While viewing your emails, or text messages click on a message
    2. Holding the Shift key on your computer, click on the last message  
    3, Messages between the first, and last message you selected should be highlighted allowing you delete them en mass
    Option 2 (Selecting specific messages using the Control key) 
    1. While viewing your emails, or text messages click on a message
    2. Hold the Control key (CTRL), and click another message
    3. Repeat as needed 
    4. You can now delete, mark read\unread etc en mass 
    I hope this helps! 
    Ty

  • JTextArea artifacts when selecting/deselecting text

    I just bumped up against a font rendering issue with JTextArea. I have no doubt that it's a bug, but does anyone know of a workaround?
    Run the program below and select/deselect text by double-clicking words. The text is painted in a different location when selected and deselected. Try selecting by dragging the mouse or pressing shift and left/right arrow keys -- same problem, but the actual pixel location of the artifacts sometimes differs depending on the selection start and end, and the way the text was selected (keyboard/mouse drag/double click).
    Now try selecting the last word ("dog") by double clicking.import java.awt.Font;
    import java.awt.font.TextAttribute;
    import java.util.HashMap;
    import java.util.Map;
    import javax.swing.*;
    public class TextAreaProblem {
      public static void main(String[] args) throws Exception {
        SwingUtilities.invokeLater(new Runnable() {
          @Override
          public void run() {
            new TextAreaProblem().makeUI();
      public void makeUI() {
        Map<TextAttribute, Object> attributes = new HashMap<TextAttribute, Object>();
        attributes.put(TextAttribute.FAMILY, "Arial");
        attributes.put(TextAttribute.SIZE, 36.0);
        attributes.put(TextAttribute.POSTURE, TextAttribute.POSTURE_OBLIQUE);
        attributes.put(TextAttribute.TRACKING, TextAttribute.TRACKING_LOOSE);
        Font font = Font.getFont(attributes);
        font = font.deriveFont(attributes);
        final JTextArea textArea = new JTextArea("The quick brown fox jumps over the lazy dog.");
        textArea.setFont(font);
        textArea.setLineWrap(true);
        textArea.setWrapStyleWord(true);
        JFrame frame = new JFrame();
        frame.add(new JScrollPane(textArea));
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setSize(850, 200);
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
    Microsoft Windows [Version 6.1.7600]
    Copyright (c) 2009 Microsoft Corporation.  All rights reserved.
    C:\Users\Darryl>java -version
    java version "1.6.0_17"
    Java(TM) SE Runtime Environment (build 1.6.0_17-b04)
    Java HotSpot(TM) Client VM (build 14.3-b01, mixed mode, sharing)Any tips for a workaround will be much appreciated.
    Thanks, Darryl

    The fix using System.setProperty worked 100% for all font and attribute combinations I tried -- thanks again.
    2) Does it work to set the property after the GUI is already created and shown? (shall test that myself in a few hours, but would be nice to know earlier :)No. However, you may set this property as a component client property (on the JTextComponent), but before that component is made visible.This didn't work for me. I tried both putClientProperty and getDocument().putProperty, as suggested in the other thread. What did I miss?import java.awt.Font;
    import java.awt.font.TextAttribute;
    import java.util.HashMap;
    import java.util.Map;
    import javax.swing.*;
    public class TextAreaProblem {
      public static void main(String[] args) throws Exception {
        //System.setProperty("i18n", Boolean.TRUE.toString());
        SwingUtilities.invokeLater(new Runnable() {
          @Override
          public void run() {
            new TextAreaProblem().makeUI();
      public void makeUI() {
        Map<TextAttribute, Object> attributes = new HashMap<TextAttribute, Object>();
        attributes.put(TextAttribute.FAMILY, "Arial");
        attributes.put(TextAttribute.SIZE, 36.0);
        attributes.put(TextAttribute.TRACKING, TextAttribute.TRACKING_LOOSE);
        attributes.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON);
        attributes.put(TextAttribute.STRIKETHROUGH, TextAttribute.STRIKETHROUGH_ON);
        Font font = Font.getFont(attributes);
        font = font.deriveFont(attributes);
        final JTextArea textArea = new JTextArea("The quick brown fox jumps over the lazy dog.");
        textArea.setFont(font);
        textArea.setLineWrap(true);
        textArea.setWrapStyleWord(true);
        // tried either or both -- didn't help
        textArea.getDocument().putProperty("i18n", Boolean.TRUE.toString());
        textArea.putClientProperty("i18n", Boolean.TRUE.toString());
        JFrame frame = new JFrame();
        frame.add(new JScrollPane(textArea));
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setSize(850, 200);
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
    }Darryl
    edit Setting this property seems to remove the ability to render underlined and strikethrough attributes. Changed the code above to add these. When "i18n" is set, they are ignored.
    edit2 GlyphPainter2 also doesn't appear to support foreground/background colors and swap_colors. It's beginning to look like whoever wrote that class solved a single problem of cumulative integer math error but introduced several others. Or maybe just didn't reimplement the features that weren't inherited..
    Edited by: DarrylBurke on Sep 8, 2010 5:13 AM

  • In Acrobat XI, how can I select and move multiple text/image blocks simultaneously on the same page?

    I work with student-generated PDFs that require all content to be within a specific margin range. Occasionally tables and figures are indented or otherwise spaced incorrectly so that the content violates the margin requirements. In Acrobat X, I could use the select tool to draw a select box around all of the text and lines within a table, for example, and just slide the entire table over a bit to meet the requirements without sending the PDF back to the author for a correction. This didn't always work, but often enough that I was able to use it on a daily basis.
    Is there a way to select multiple (but not ALL) text blocks and image pieces on a page, so they may be moved simultaneously? If I have to select every text block and line (or every point and line within a graph) and move them each individually, this is going to be a nightmare.
    I have Acrobat XI for both Mac and Windows, but tend to use the Windows version more often.

    Hey, I'm using Acrobat XI and I can't multi select like I use too do with shift as always. Now I get a green note every time I want to multi select with shift + click as always. I also use Pitstop and I get the same green notes.
    Can someone help me ?

Maybe you are looking for

  • Merging two XML Document Objects

    I'm trying to merge two seperate XML Document Objects into one Object. Any suggestions would be very much appreciated. This is what the Objects look like when returned. FIRST: <?xml version = '1.0'?> <app> <name>Home</name> <active>true</active> <ord

  • Java SE 6 on PPC (Mac 10.5.8)?!?

    I want to be able to use Netbeans on my PowerMac, but it requires Java6. I can't seem to find the Java 6 SDK for PPC anywhere. Please help, this machine is not dead yet, it's still kicking, why does apple drop software support so quickly (especially

  • Here's a Temp Solution to the iOS6 WiFi Crisis

    Hello fellow Apple users. I updated to iOS 6 on my iPad 3 4G/64GB and like most of you, found the annoying pop-up Apple can't find page thing and that it wouldn't stay connected to my WiFi.  I tried the solutions given around this forum (clear cache/

  • Unable to Play new movie

    I recently upgraded itunes and also purchased a new movie. When opening my Apple tv2 to play the new movie it is auto upgraded but them would not play the new movie as it stated that my comuter was not authorised. When I de-authorised and re-authoris

  • How to get Valid Row Count on Matrix

    Our code reads certain fields on the marketing document form (both Header and Line fields) every time before Add or Update the document. To read the lines, we have a function "GetLinebyUI(i, FormType, other parameters...)" that is called for every Li