Highting lines in JTextArea objects

does anyone know how to selectively hightlight lines
in a JTextArea object?
I have thought about creating a custom view by
extending PlainView and overriding the drawLine method
and fire a propertyChange event selectively.
The JTextArea object couild then be registered as
a propertyChange listener with the custom view and
when a propertyChagne event occurs then change
the text area background color.
I have created a custom UI using BasicTextUI and
overriding the getEditor method to return the
custom view. Seems to work OK but I can't get a
reference to the custom view to add the text area as
a property change listener.
There is a method to return the root view of the UI
but doesn't appear to be the custom view.
Any ideas would be greatly appreciated.
thanks eric lucas
[email protected]

say u got a line like ____________________________
and u can highlight it easily,Here's the code.....
DefaultHighlighter high =new DefaultHighlighter();
DefaultHighlighter.DefaultHighlightPainter highlight_painter =new DefaultHighlighter.DefaultHighlightPainter(new Color(198,198,250));
yourTextArea.setHighLighter(high);
try{
         high.addHighlight(start,end,highlight_painter);
    }catch(Exception e){}->Sasivarnan<-

Similar Messages

  • When I render and Export there are these little lines around moving objects

    When I render and Export there are these little lines around moving objects, what are they and how do I fix it?

    The lines are caused by the video being interlaced.
    If you export to DVD they should no longer appear. However, if they don't disappear you can use the Deinterlace filter on the footage whilst in FCE.
    How are you exporting ..... QT Movie or QT Conversion ....... and what are you exporting to - the internet or DVD?

  • Weird chars at end of line in JTextArea

    I am getting these weird characters at the end of the line in JTextArea when I use setText.
    I am doing the foll:
    //Creation of JTextArea
    JPanel p2 = new JPanel(); // for JTextArea and video
    displayText = new JTextArea(15,30);
    JScrollPane scrollPane = new JScrollPane(displayText);
    p2.add(scrollPane);
    //Wrapping the lines
    // I read the lines from a file, set a text and use foll code to wrap the lines.
    setLineWrap(true);
    setWrapStyleWord(true);
    The text from the file is displayed correctly. But the last line of the para is filled by weird characters like [] ( to complete the line I guess).
    Any idea of this strange behaviour?

    Hi,
    it seems that this text, you have read in, is not plain ASCII-text - perhaps there are some special byte sequences at the beginning of a paragraph, that you will have to filter out during input. Unfortunately that requires in most cases, that you know the basics about that format you want to read in.
    You said, you see [ like characters - hm ... ANSI-Sequences start with ESC [ - if you see something like this "[30;41;1m" with a weird char before it, that is an ANSI-Sequence specifying forground-color, background-color and bold for example. Also ESC [ 1m is possible, there are not all parts needed.
    If you have found out, which format that is, that your text file has, you can write a subclass of FilterInputStream to filter out these characters during you read it in.
    greetings Marsian

  • Microsoft JScript Runtime Error, Line: 0, Error: Object Expected?

    Hi,
    I just got a new computer and I have Java 2 Runtime Environment SE v 1.4.2. I keep having problems with it. It says, "Microsoft JScript Runtime Error, Line:0, Error: Object Expected. I have no idea what to do or what is actually causing this. It shows up randomly when I have been using "Dell Jukebox by musicmatch" or even when I'm surfing. Can someone please help me fix the problem?
    "Jay"

    Hi,
    I just got a new computer and I have Java 2 Runtime
    Environment SE v 1.4.2. I keep having problems with
    it. It says, "Microsoft JScript Runtime Error, Line:0,
    Error: Object Expected. I have no idea what to do or
    what is actually causing this. This is not a java err. It is a scripting error.
    It shows up randomly
    when I have been using "Dell Jukebox by musicmatch" or
    even when I'm surfing. Can someone please help me fix
    the problem?
    "Jay" Someone can certainly help you - contact the website's webmaster & send them the err. They wrote it; they have to fix it.

  • A Runtime Error Has Occured Do you wish to Debug? Line 90 Error: Object Expected

    A Runtime Error Has Occured Do you wish to Debug? Line 90
    Error: Object Expected
    This error is recieved when trying to open "The Fan" video
    news Page from Comcast, This error appears and when you select yes
    or no, the page comes up to install Adobe Flash Player, however
    even after installing it, the error still appears when attempting
    again, even after restart, this does not occur on Firefox, only
    IE

    Also I am on Windows Vista

  • SetDocument method with a JTextArea object

    I'm trying to load a text file into a JTextArea object (called textArea) like this...
    Document Doc = mydata.txt;
    textArea.setDocument(Doc);
    It tells me: Undefined variable or class name: mydata
         Document Doc = mydata.txt;
    It also won't let me just do:
    textArea.setDocument(mydata.txt);
    What should I do?

    You can use something like this:
    import java.io.*
        public static String fileToString(String fileName)
                throws IOException {
            FileReader fr = new FileReader(fileName);
            StringBuffer contents = new StringBuffer();
            int c;
            while((c = fr.read()) !=-1) {
                contents.append((char)c);
            fr.close();
            return contents.toString();
    [...]and then try
        textArea.setText(fileToString("myData.text"));I hope that helps.
    -- Scott

  • How to delete the logical lines in JTextArea

    Hi all,
    Now that I know how to find the logical line count in JTextArea as
    I found the following in the forum.
    public static int getLineCount (JTextArea _textArea)
    boolean lineWrapHolder = _textArea.getLineWrap();
    _textArea.setLineWrap(false);
    double height = _textArea.getPreferredSize().getHeight();
    _textArea.setLineWrap(lineWrapHolder);
    double rowSize = height/_textArea.getLineCount();
    return (int) (_textArea.getPreferredSize().getHeight() / rowSize);
    I want to delete the 4th line to the last line and append ... at the 4th, if the getLineCount exceeds 3. Does any body know how to do so?
    The intention is for the multiline tooltip as I just want to show
    the first three logical line and ... if the string is too long.
    Thanks
    Pin

    The code looks good to me. The only thought I have is that the y coordinate for the rowThree point is wrong and is referencing row four.
    I've been playing around with using a JTextArea as a renderer for a JTable. I have it working so that "..." appear when the text exceeds 2 rows. Try clicking on "B" in the letter column and then the update cell button a few times to add text. My code is slightly different than yours.
    import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    import javax.swing.*;
    import javax.swing.table.*;
    public class TestTable extends JFrame
         private final static String LETTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
         JTable table;
         Vector row;
         public TestTable()
              Object[][] data = { {"1", "A"}, {"2", "B"}, {"3", "C"} };
              String[] columnNames = {"Number","Letter"};
              DefaultTableModel model = new DefaultTableModel(data, columnNames);
              table = new JTable(model)
                   public String getToolTipText( MouseEvent e )
                        int row = rowAtPoint( e.getPoint() );
                        int column = columnAtPoint( e.getPoint() );
                        if (row == 0)
                             return null;
                        else
                             return row + " : " + column;
              table.setRowSelectionInterval(0, 0);
              table.setColumnSelectionInterval(0, 0);
              table.setRowHeight(0,34);
              table.setRowHeight(1,34);
              table.setRowHeight(2,34);
              table.setDefaultRenderer(Object.class, new TextAreaRenderer(2));
              JScrollPane scrollPane = new JScrollPane( table );
              getContentPane().add( scrollPane );
              JPanel buttonPanel = new JPanel();
              getContentPane().add( buttonPanel, BorderLayout.SOUTH );
              JButton button2 = new JButton( "Update Cell" );
              buttonPanel.add( button2 );
              button2.addActionListener( new ActionListener()
                   public void actionPerformed(ActionEvent e)
                        int row = table.getSelectedRow();
                        int column = table.getSelectedColumn();
                        String value = (String)table.getValueAt(row, column);
                        value += value;
                        table.setValueAt( value, row, column );
                        DefaultTableModel model = (DefaultTableModel)table.getModel();
                        model.fireTableCellUpdated(row, column);
                        table.requestFocus();
         public static void main(String[] args)
              TestTable frame = new TestTable();
              frame.setDefaultCloseOperation( EXIT_ON_CLOSE );
              frame.pack();
              frame.setVisible(true);
         private class TextAreaRenderer extends JTextArea implements TableCellRenderer
              public TextAreaRenderer(int displayRows)
                   setRows(displayRows);
                   setLineWrap( true );
              public Component getTableCellRendererComponent(JTable table,
                                             Object value,
                                             boolean isSelected,
                                             boolean hasFocus,
                                             int row,
                                             int column)
                   setText( value.toString() );
                   Dimension d = getPreferredSize();
                   int maximumHeight = getRows() * getRowHeight();
                   if (d.height > maximumHeight)
                        setSize(d);
                        int offset = viewToModel( new Point(d.width, maximumHeight - 1) );
                        replaceRange( "...", offset-3, getDocument().getLength() );
                   return this;
    }

  • PDF - Text on multiple lines become seperate objects - is there a way to prevent this?

    I'm exporting to PDF from inDesign with the idea that the text would be editable with Acrobat Pro.
    However, when opening the PDF in Acrobat Pro, each line is a seperate instance / object.
    Is there a way around this?
    I imagine I can recreate the text in Acrobat Pro - but it would be good if there was a way round from inDesign - as i imagine it would be better for SEO and screen readers. Also, i've uploaded PDFs to sites before like Slideshare, yudu, issuu which create a text only version - only the text only version is scr*wed up due to the above problemo.
    Help much appreciated or even to know if its not possible. Thanks.

    Not really sure what SEO has to do with it? But I think  you're talking about "Accessibility"
    When a PDF is created that's what happens. You can't export it and have paragraphs of text editable. PDFs are meant to be FINAL files.
    For accessiblity follow these tips -
    http://www.adobe.com/accessibility/products/acrobat/
    http://tv.adobe.com/watch/accessibility-adobe/preparing-indesign-files-for-accessibility/
    http://tv.adobe.com/watch/accessibility-adobe/acrobat-tagging-pdf-content-as-a-table/
    http://indesignsecrets.com/creating-accessible-pdf-documents.php

  • How to Capture New Line in JTextArea?

    I apologize if this is easy, but I've been searching here and the web for a few hours with no results.
    I have a JTextArea on a form. I want to save the text to a database, including any newline characters - /n or /r/n - that were entered.
    If I just do a .getText for the component, I can do a System.println and see the carriage return. However, when I store and then retrieve from the database, I get the lines concatenated.
    How to I search for the newline character and then - for lack of a better idea - replace it with a \n or something similar?
    TIA!

    PerfectReign wrote:
    Okay, nevermind. I got it.
    I don't "see" the \n but it is there.
    I added a replaceAll function to the string to replace \n with
    and that saves to the database correctly.
    String tmpNotes = txtNotes.getText().replaceAll("\n", "<br />");Oh, you're viewing the text as HTML? That would have been good to know. ;)
    I'll have to find a Wintendo machine to try this as well.Be careful not to get a machine that that says "Nii!"

  • Passing an internal table WITH HEADER LINE to abap object

    Hi. In another thread, it was explained how to pass an internal table to an abap object method. Is it possible to pass an internal table that has a header line, and RETAIN the header line once the table has been passed?
    My problem is, that I can pass the table, update it, but the read buffer is not populated when returning from the object's method. This is the result of being able to pass a STANDARD TABLE type, but not a STANDARD TABLE WITH HEADER LINE.
    This means that I have to read the table into a work area instead of doing a READ TABLE LKNA1 within the method, which is what I need to do.
    Thanks.

    Please check this sample program, notice that it is modifing the internal table and passing it back modified as well as passing the "work area" or "header line" back thru the exporting parameter.
    report zrich_0001.
    *       CLASS lcl_app DEFINITION
    class lcl_app definition.
      public section.
        types: t_t001 type table of t001.
        class-data: it001 type table of t001.
        class-data: xt001 like line of it001.
        class-methods: change_table
                                    exporting ex_wt001 type t001
                                    changing im_t001 type t_t001.
    endclass.
    data: w_t001 type t001.
    data: a_t001 type table of t001 with header line.
    start-of-selection.
      select * into table a_t001 from t001.
      call method lcl_app=>change_table
                 importing
                     ex_wt001 = w_t001
                 changing
                     im_t001  = a_t001[] .
      check sy-subrc  = 0.
    *       CLASS lcl_app IMPLEMENTATION
    class lcl_app implementation.
      method change_table.
        loop at im_t001 into xt001.
          concatenate xt001-butxt 'Changed'
               into xt001-butxt separated by space.
          modify im_t001 from xt001.
        endloop.
        ex_wt001 = xt001.
      endmethod.
    endclass.
    Regards,
    Rich Heilman

  • How to remove/avoid faint line after dividing objects and recoloring intersection

    I created two rings which  should pass through each other similar to the olympic rings.
    I recreate the two rings (both objects, filled no stroke) and position them. I  select them both and click divide using the pathfinders tool.
    I then change the color of one point of intersection to that of the background ring (in this case from pink to black).
    However, as shown in the image below a very faint line is left. This shows up when I create a .pdf file of the ring.
    How can I prevent this faint line from showing? Have searched for the answer but can't find it.

    Probably just an artifact. But you can select that oath and look at the appearance panel and make sure it only has on fill and no stroke.
    Orr you can turn that into alive paint group and use the Live Paint Bucket to fill it with black even though it already is black.
    Or you can redo this by creating outlines of the rings as you did before  selecting both outline rings and clicking on the live paint bucket to turn the art into a live paint group and fill the segment with black.
    If using CS 5 you might want to hide the original path after using the outline stroke command.
    In CS5 when you outline a stroke the original Path is preserved so you either want to use it delete it or turn its visibility off.
    This is the result of the live paint group method

  • Exporting as a PDF - white grainy line appears around object

    When I export as a PDF a white grainy line appears around an object where I've used a gaussian blur? why is this?

    Thanks for getting back to me
    here is an example of the problem....
    I'm using a trial of Illustrator CC, Not sure on the programme to inspect the files...Hope this helps.

  • HELP - Trying to make multiple lines one single object

    I have tried everything and to no avail. I know it's due to my lack of experience w/ PS CS3. Any help you can offer and quickly, would be greatly appreciated!
    I've traced/drawn an ice machine with the line tool. There are about 20 individual lines that make the shape. All are in one layer. I want to group the lines so that I can make it one object so that I can move it all together. When I select all of the individual lines and then click Combine, some of my lines disappear.
    Please help.
    Thank you.

    Which option?

  • Lines on moving objects

    When I export DV clips from FCE I get lines appear on moving objects, (HDTV). When I export the same clip using iMovie08 it all looks smooth.
    I've tried the de-interlace, it made it worse.
    How can I get rid of the lines in FCE?

    shuggyboy1 wrote:
    ... What is the _best setting to export_ from imovie HD 6 to idvd to prevent this yet still maintain DV quality?
    .. not to export at all, that simple..
    the zillions of Export options could cause trouble.
    simply, store your iM projects in the 'Movies' folder of your Mac ...
    iDVD will 'find' them automatically and cares for itself to import..
    Plan B)
    drag'n drop the whole project from Finder to iDVD.. again: no export involved, no trouble..

  • Converting separate lines of JTextArea to LinkedList Node

    I have a JTextArea where user can input text in multiple lines. When the user click a button, I would like to convert each line in the JTextArea into a node of LinkedList. For example, if the JTextArea has 5 lines of text, then the LinkedList should have 5 nodes where each node represents the string of each line.
    I do not have problem with LinkedList. The problems I'm having is I do not know what reader should I use and how validate that it is a new line.
    Here's what I have which is definately incorrect.
         public void changeTextToNode( String text )
              String text = textArea.getText();
              try
                   StringReader reader = new StringReader( text );
                   BufferedReader reader2 = new BufferedReader( reader );
                   StringBuffer strBuf = new StringBuffer();
                   while( // validate it's a new line and not end of stream )
                                   LineNode ln = new LineNode( // String of a single line );
              catch( Exception e )
              }     Any help would be greatly appreciated. Thank you.

    Yes, I would like to split on \n. How can I checkwhen it's a
    new line (\n)? Thanks for helping out.I have a couple of questions about this:
    1) When a JTextArea wraps to the next line does it
    automatically insert a newline?probably not, thats why it might be best to split on \n and also keep a char counter, and split when it becomes greater then the length of the textarea

Maybe you are looking for