How to highlight entire line

I am currently implementing an IDE. I try to highlight entire line(not only text but also following blank field) when users set a breakpoint on that line.
Using Highlighter.addhighlight(start, end, HighlightPainter) only allow me to highlight the text part in the line. I haven't figure out how to do that.
Any helps are appreciated.

one way to highlight a full line or draw a breakpoint
symbol on a particular is to create a custom highlight
painter and override the paint method. If you want to
highlight the full line then use the width from the
JTextArea and only the y coordinate and height from
the view coordinates.
If you would like a breakpoint symbol and a particular
line then just put a drawImage call in the paint method
which draws an icon on that line
I've included some code for custom painter for both
highlighting a full line and rendering a breakpoint
icon.
     private class     SingleLineHighlighterPainter      extends DefaultHighlighter.DefaultHighlightPainter {
               public     SingleLineHighlighterPainter( Color color )
               {     super( color );          }
     * Paints a highlight over a single line.
               * just uses the first point a work around only
     * @param g the graphics context
     * @param offs0 the starting model offset >= 0
     * @param offs1 the ending model offset >= offs1
     * @param bounds the bounding box for the highlight
     * @param c the editor
          public void paint(Graphics g, int offs0, int offs1, Shape bounds, JTextComponent c) {
                    Rectangle alloc = bounds.getBounds();
                         Rectangle area = c.getBounds();
                         try {
                    // --- determine locations ---
                                   TextUI mapper = c.getUI();
                                   Rectangle p0 = mapper.modelToView(c, offs0);
                    // --- render ---
                                   Color color = getColor();
                                   if (color == null) {
                                   g.setColor(c.getSelectionColor());
                                   else {
                                   g.setColor(color);
                    // render using just the y coordinates and height from the initial point
                                   g.fillRect(0, p0.y, alloc.width, p0.height);
                         catch (BadLocationException e) {
                    // can't render
     private class     BreakpointPainter      extends DefaultHighlighter.DefaultHighlightPainter {
                    public     BreakpointPainter()
                    {     super( Color.green );          }
          * Paints a breakpoint image
                    * just uses the first point a work around only
          * @param g the graphics context
          * @param offs0 the starting model offset >= 0
          * @param offs1 the ending model offset >= offs1
          * @param bounds the bounding box for the highlight
          * @param c the editor
               public void paint(Graphics g, int offs0, int offs1, Shape bounds, JTextComponent c) {
                         Rectangle alloc = bounds.getBounds();
                              Rectangle area = c.getBounds();
                              try {
                         // --- determine locations ---
                                        TextUI mapper = c.getUI();
                                        Rectangle p0 = mapper.modelToView(c, offs0);
                                        Image im = ( (ImageIcon) Icons.stopSignIcon ).getImage();
                         // render using just the y coordinates and height from the initial point
                                        g.drawImage( im,0,p0.y+2,null );          
                              catch (BadLocationException e) {
                         // can't render
to use these do the following
     DefaultHighlighter dh = new DefaultHighlighter();
          dh.setDrawsLayeredHighlights( false );
          SingleLineHighlighterPainter     dhp = new SingleLineHighlighterPainter(Color.green);
          BreakpointPainter                    bpp = new BreakpointPainter();
          buff.setHighlighter(dh);
          try {
               dh.addHighlight(25, 30, dhp);     // single line highlighter here
               dh.addHighlight(60, 60, bpp);     // add breakpoint highlighter here
               dh.addHighlight(120,120,bpp);     // add breakpoint highlighter here
          catch (javax.swing.text.BadLocationException jst) { };
          buff.setMargin( new Insets( 0,20,0,0 ) );
where numbers used with the addHighlight method are
the location within the model. In this case the
addHighlight( 25,30, dhp ) will highlight the line with
a view location corresponding to position 25 in
the model. So just need to specify any model location
on the line you want to highlight.
Setting breakpoints is the same just need one model
position on the line where you want the image to be
drawn.
Hope that's clear.
Also helps to look at the source code for
DefaultHighlighter.java.
eric
[email protected]

Similar Messages

  • Conditinoal formatting - How to highlight even lines in a report ?

    The report standards folks in my team came up with a new standard i.e. highlight all the even number lines in the report so that the report will be more readable. Is there an easy way to do it using format triggers or something ? The entire row or a group of rows needs to be highlighted. How to accomplish this ?

    Hi Suresh,
    If a line is equivalent to a row of data, you can put the format trigger in the repeating frame for that row. To count the rows, you can create a running count by having a summary column in that group which does the count and resets at report or some higher level. If :running_count mod 2 = 0 then you can execute the code in your format trigger, otherwise, just return true.
    Hope that helps,
    Toby

  • How to highlight a line in a text stream and position the cursor at the end.

    I would like to select a line in a text control data stream, highlight the text, and place the cursor at the end of the line so that the text control can be edited at that point.

    Depends on what you mean by "highlight". If you mean highlight in the sense of when you use the mouse to select text, then you can't do that and then place the cursor at the end, since that would effectively "unhighlight" the text. You need to use a different kind of "highlight", like turning the text bold or something. This KB article talks about highlighting particular characters: How Do I Highlight Particular Characters in a String Control?
    See attached for simple example. Modify as needed.
    Attachments:
    Text Select.vi ‏19 KB

  • Changes from Visio 2010 to 2013 - highlighting entire line drawing document with text fields and changing line colors

    I work with very large visio drawings that are basically line drawings (network drawings) with text boxes indicating equipment location. We work in future and current drawings, future has colored lines indicating connection type and objects have text in
    them that indicate if they are new by having red text. Current drawings have all black lines and black text.
    Here's my dilemma, previously I would Ctrl+A and then change all text and all lines to black in Visio 2010, everything would change no problem. In Visio 2013 every text box now get's a black border around it, I've tried selecting all text boxes at once
    and trying to remove the line but no luck.
    These drawings are HUGE and it takes me a good hour just to change between future and current where previously it took me seconds. I have many coworkers and we're all experiencing he same issue with the move to 2013.
    Is there a macro or some vb script I can utilize to select all text boxes and remove the black outline?
    Hope you can help!

    try this macro
    Sub Simple()
    Dim sh As Shape, counter As Integer
    ActiveWindow.SelectAll
    For counter = 1 To ActiveWindow.Selection.Count
    Set sh = ActiveWindow.Selection(counter)
    If Len(sh.Text) > 0 Then sh.Cells("Geometry1.Noline").FormulaU = "IF(LEN(SHAPETEXT(TheText))>0,1,0)"
    Next
    MsgBox "All text borders set invisible"
    End Sub
    if in your drawings you have only lines and text label (NOT rectangles, circles and other shapesconteined text for example) this macro can help !

  • How to highlight the whole row of a particular line item of sale

    How to highlight the whole row of a particular line item of sales order depending on condition?
    Please help its urgent..
    Looking forward your reply.
    Moderator message: please do more research before asking, show what you have done yourself when asking, do not flag posts as "urgent".
    [Rules of engagement|http://wiki.sdn.sap.com/wiki/display/HOME/RulesofEngagement]
    [Asking Good Questions in the Forums to get Good Answers|/people/rob.burbank/blog/2010/05/12/asking-good-questions-in-the-forums-to-get-good-answers]
    Edited by: Thomas Zloch on Aug 9, 2011 9:30 AM

    Any ideas on what would cause this NOT to work? I added this row right after the table is created and populated and it is still not highlighted when I enter the form. The snippet of code that does this is:
    MyTableModel modelS = (MyTableModel)dataModel.get("S");
    jTable1 = new JTable(modelS);
    jTable1.setRowSelectionInterval(0,0);MyTableModel is this:
    class MyTableModel extends DefaultTableModel {
      public MyTableModel(Object[] columnNames, int numRows) {
        super(columnNames, numRows);
      public boolean isCellEditable(int row, int column) {
        if (TableKey == 'S') {
          if (column == 6) {
            return false;
        if (TableKey == 'O') {
          if (column == 0 || column == 4 || column == 5) {
            return false;
        if (TableKey == 'P') {
          return false;
      return true;
    }Can anyone help? Thanks.
    Allyson

  • Word Processing problem:  How do I highlight different lines to edit at....

    How do I highlight different lines/words at the same time to edit simultaneously.
    Ex
    I like school
    School is fun
    Let's go to school
    I can't wait
    If I wanted to highlight the first and third line to center at the same time, how exactly would I do that?

    Hi Jeremiah,
    Can't be done. AppleWorks doesn't support non-contiguous selection.
    For your particular example, you can center lines one and three by this procedure:
    Place the insertion point in line 1.
    Press command-\
    Place the insertion point in line 3.
    Press command-\
    Regards,
    Barry

  • How I activate, when in code view current code line, to be highlighted (all line) eg light-blue ?

    How I activate, when in code view current code line, to be
    highlighted (all line) eg light-blue ?

    Actually, in Windows (XP) the highlight color (in DW8) is a
    byproduct of the
    color scheme you set for your desktop.
    Walt
    "Michael" <[email protected]> wrote in message
    news:gn7fpk$hbp$[email protected]..
    > In code view, click the line number in the left margin
    corresponding to
    > the line of code you wish to highlight. Left click that
    number and the
    > whole line will be highlighted in blue.
    >
    > Michael
    >

  • How to highlight a certain line in textArea?

    Hi
    I want to know how can i highlight certain line in atextArea with diffeent colors
    Thanks in advance

    highlight certain line in atextArea with diffeent colorsAre you talking about the foreground or background color??
    If its the foreground, all the text must be the same color. If you need multiple colored text then you need to use a JTextPane.
    If its the background then you can use a Highlighter.
    textArea.getHighlighter().addHighlight(...);

  • BDC - ME52N  how to replicate highlighting a line and coping it

    Hello All,
      i have used SHDB on transaction ME52N and have the code but what is not happening is, when i do the ME52N i highlight the first detail line and then depress the copy icon to create a second line. This is what i can not get to work in the BDC anyone have any ideas. It will not highlight the line and make a copy of it.
             thanks Scott

    Hi Scott,
    Why do you want to copy the line item. How is the 1st line item created. If the 1st line item is created by populating values from your own internal table, then even for creating 2nd line item, populate the data into 2nd from from the internal table itself.
    If you select a line item and click on copy, it validates the 1st line item, checks for mandatory input values viz. material no, quantity, unit, G/L account no.,account assignment category.
    Try to execute the transaction manually and populate the data. If it is working fine then try BDC for the same data with CALL TRANSACTION with MODE `A`.
    Best regards,
    Prashant

  • File  Content  Conversion for ignoring the entire line

    Hi,
       I'm getting a CSV file from that i want to skip some  records based on some validation.. for example:
    I'm getting the following  data :
    EmpNo                   EmpName                   EmpDept
    E101                       ABC                               ABAP
    E102                       XYZ                                BW
    E103                       GFC                               XI
    E104                       BVM                               ABAP
    E105                       ASD                               BW
    E106                       YFC                                XI
    SO, here  where ever i'm getting  EmpDept = XI  .. i want to skip those all the  records( that entire line  i want to skip).. .. this can be possible through Message Mapping.. but i wnat to do this in the File Content Conversion..  how can we do this..
    any  helpful answers   will  appriciated..
    Thanks
    babu

    Hi,
    FCC is used to generate the XML structure so that XI can understood properly. You can not do any kind of validations or Skip the records based on Element value condition in FCC.
    There are scenarios where you want to skip the lines that time you can use the below option in FCC but this is again not based on condition.
    Under Document Offset, specify the number of lines that are to be ignored at the beginning of the document.
    This enables you to skip comment lines or column names during processing. If you do not make an entry, the default value is zero lines.
    The best way to do is use the UDF:
    Write an UDF on target root node.
    take input in one context:
    input a= Emp Dept:
    for(i=o,i<a.length;i++)
      if(a{i}.equals("X"))
       result.addValue(SUPPRESS); this will supress the target root node if condition is equal to X
      else
      result.addValue("Constant"); this will generate the target root node.
    Thnx
    Chirag

  • How to set a line of table as read only during runtime?

    How to set a line (or a cell) of table as read only during runtime?

    hi wei
          when you create a table keep the readonly property of table as false
    you create the columns of table as inputfield.you bind the readonly property of
    the inputfield to two context variables
    say one for all the columnfields you to want always have as readonly and let this contextattribute of type boolean and let this be attr1
    and another for all the columnfields you donot want to be readonly and let this contextattribute of type boolean and let this be attr2
    initially set the context attributes attr1 and attr2 as true so the entire table is readonly.
    based on the condition you want to check change the attr2 to be false.
    if(your condition)
    wdcontext.currentcontextelement.setattr2(false);
    hope this helps.
    regards
    saravana

  • How do I trim lines?

    I am new to illustrator. Please explain in detail how to trim the dash lines so they don't go past the "edge" of the thermometor on the right.  When I try to clip or use any tools basically it deletes the entire line or distorts it.  See picture.

    mmadams,
    Sorry, I was, presumably wrongly, thinking of filled paths as the rounded lines. I now believe they are just simple paths with heavy strokes. Is that right?
    If it is, you may place the copy of the outer (white) path in front, select that and the lines, and Object>Clipping Mask>Make.

  • How to get file line count.

    Hey guys,
    How to get file line count very fast? I am using BufferedReader to readLine() and count. But when dealing with big file, say several GB size, this process will be very time consuming.
    Is there any other methods?
    Thanks in advace!

    What I'd do is you create an infofetcher, register a listener, implement gotMore() and have that scan for '\n'
    Some might suggest getting rid of the listener/sender pattern or use multiple threads to make ii faster. This might help a little, but only if your I/O is super-duper speedy.
    you are welcome to use and modify this code, but please don't change the package or take credit for it as your own work.
    InfoFetcher.java
    ============
    package tjacobs.io;
    import java.io.IOException;
    import java.io.InputStream;
    import java.util.ArrayList;
    import java.util.Iterator;
    * InfoFetcher is a generic way to read data from an input stream (file, socket, etc)
    * InfoFetcher can be set up with a thread so that it reads from an input stream
    * and report to registered listeners as it gets
    * more information. This vastly simplifies the process of always re-writing
    * the same code for reading from an input stream.
    * <p>
    * I use this all over
         public class InfoFetcher implements Runnable {
              public byte[] buf;
              public InputStream in;
              public int waitTime;
              private ArrayList mListeners;
              public int got = 0;
              protected boolean mClearBufferFlag = false;
              public InfoFetcher(InputStream in, byte[] buf, int waitTime) {
                   this.buf = buf;
                   this.in = in;
                   this.waitTime = waitTime;
              public void addInputStreamListener(InputStreamListener fll) {
                   if (mListeners == null) {
                        mListeners = new ArrayList(2);
                   if (!mListeners.contains(fll)) {
                        mListeners.add(fll);
              public void removeInputStreamListener(InputStreamListener fll) {
                   if (mListeners == null) {
                        return;
                   mListeners.remove(fll);
              public byte[] readCompletely() {
                   run();
                   return buf;
              public int got() {
                   return got;
              public void run() {
                   if (waitTime > 0) {
                        TimeOut to = new TimeOut(waitTime);
                        Thread t = new Thread(to);
                        t.start();
                   int b;
                   try {
                        while ((b = in.read()) != -1) {
                             if (got + 1 > buf.length) {
                                  buf = IOUtils.expandBuf(buf);
                             int start = got;
                             buf[got++] = (byte) b;
                             int available = in.available();
                             //System.out.println("got = " + got + " available = " + available + " buf.length = " + buf.length);
                             if (got + available > buf.length) {
                                  buf = IOUtils.expandBuf(buf, Math.max(got + available, buf.length * 2));
                             got += in.read(buf, got, available);
                             signalListeners(false, start);
                             if (mClearBufferFlag) {
                                  mClearBufferFlag = false;
                                  got = 0;
                   } catch (IOException iox) {
                        throw new PartialReadException(got, buf.length);
                   } finally {
                        buf = IOUtils.trimBuf(buf, got);
                        signalListeners(true);
              private void setClearBufferFlag(boolean status) {
                   mClearBufferFlag = status;
              public void clearBuffer() {
                   setClearBufferFlag(true);
              private void signalListeners(boolean over) {
                   signalListeners (over, 0);
              private void signalListeners(boolean over, int start) {
                   if (mListeners != null) {
                        Iterator i = mListeners.iterator();
                        InputStreamEvent ev = new InputStreamEvent(got, buf, start);
                        //System.out.println("got: " + got + " buf = " + new String(buf, 0, 20));
                        while (i.hasNext()) {
                             InputStreamListener fll = (InputStreamListener) i.next();
                             if (over) {
                                  fll.gotAll(ev);
                             } else {
                                  fll.gotMore(ev);
    InputStreamListener.java
    ====================
    package tjacobs.io;
         public interface InputStreamListener {
               * the new data retrieved is in the byte array from <i>start</i> to <i>totalBytesRetrieved</i> in the buffer
              public void gotMore(InputStreamEvent ev);
               * reading has finished. The entire contents read from the stream in
               * in the buffer
              public void gotAll(InputStreamEvent ev);
    InputStreamEvent
    ===============
    package tjacobs.io;
    * The InputStreamEvent fired from the InfoFetcher
    * the new data retrieved is from <i>start</i> to <i>totalBytesRetrieved</i> in the buffer
    public class InputStreamEvent {
         public int totalBytesRetrieved;
         public int start;
         public byte buffer[];
         public InputStreamEvent (int bytes, byte buf[]) {
              this(bytes, buf, 0);
         public InputStreamEvent (int bytes, byte buf[], int start) {
              totalBytesRetrieved = bytes;
              buffer = buf;
              this.start = start;
         public int getBytesRetrieved() {
              return totalBytesRetrieved;
         public int getStart() {
              return start;
         public byte[] getBytes() {
              return buffer;
    ParialReadException
    =================
    package tjacobs.io;
    public class PartialReadException extends RuntimeException {
         public PartialReadException(int got, int total) {
              super("Got " + got + " of " + total + " bytes");
    }

  • Copying an entire line from the previous survey question format

    Hello!
    I was wondering how you copy the formatting of an entire line if you want it to stay consistent with every question? Each question requires 3 additional text boxes added to the right.

    Using shift selection you can copy and past mutiple items at once. Then you can paste them wherever the field toolbar is.
    Andrew

  • In alv report , how to reserve 20 lines from beginning of page

    hi experts
    in alv report , how to reserve 20 lines from beginning of page.
    regards
    subhasis.

    If by reserve you mean should not move on scrolling then make them KEY from fieldcatalog.
    But I think maximum of 10-12 can be handled by that.
    Regards,
    Amit
    Reward all helpful replies.

Maybe you are looking for

  • Cannot send email from outbox

    Why can't i send email from my outbox? Mail is blocked from coming in also.

  • MBP mid 2012 crashing, is it the video card?

    Hello. I have an mid 2012 MBP with an Intel 4000 graphics card. I think it is causing the computer to crash. I recently re-installed Civ 5 which ran great last fall. At first it ran OK, then after a few hours of game time my system crashed during a t

  • GTK L&F Font size

    Using j2sdk 1.4.2_03 on Mandrake Linux and KDE. When I enable the GTK L&F just about every text using the default font is about twice as big as it should be. This version of the SDK should have this bug fixed according to release docs. My xserver DPI

  • What date 1. year warranty starts? 5 months gap between purchasing n activation

    Purchased iPod touch in May for Oct birthday.  iPod touch is not going to be opened until Oct.  But for one year warranty, it starts counting from purchasing Date or until Oct. Activating ?

  • Need help for JSP Dynpro error

    Hi Friends,     I am working with the JSP Dynpros. Suddenly I am getting the predictable error which I have copied the blow log code. Can you check it once and any one describe this. Do the needful. <b>Log:</b> #1.5#000F20F7B2D5003B0000028D0000142000