Java Document Paragraph Colors

Hi,
I want to change Background color of Styled Document. I am able to change text color through
StyleConstants.setForeground(styles, Color,RED);
Its changing background color for text. If text ends at middle of line then color applied to half line only. I need complete line to be colored. How to apply this with StyleConstants.
I also want to apply Different color effects to different paragraphs. How to achieve this.
StyleConstants.setForeground(styles, getForeground());
        StyleConstants.setBackground(styles, Color.RED);             
        doc.insertString(doc.getLength(), text, styles);waiting for your replies.

I need complete line to be colored. How to apply this with StyleConstants. I don't know how to do this with StyleConstants. However, you should be able to use a highlighter. See how the setDrawsLayeredHighlights(...) method affects the painting of highlights:
import java.awt.*;
import javax.swing.*;
import javax.swing.text.*;
public class Highlighting extends JFrame
     public Highlighting()
          String text = "one\ntwo\nthree\nfour\nfive";
          Dimension d = new Dimension(200, 200);
          JTextArea textArea1 = new JTextArea();
          textArea1.setPreferredSize(d);
          textArea1.setText( text );
          JTextArea textArea2 = new JTextArea();
          textArea2.setPreferredSize(d);
          textArea2.setText( text );
          JPanel north = new JPanel();
          north.add(textArea1);
          north.add(textArea2);
          getContentPane().add(north, BorderLayout.NORTH);
          JTextPane textPane1 = new JTextPane();
          textPane1.setPreferredSize(d);
          textPane1.setText( text );
          JTextPane textPane2 = new JTextPane();
          textPane2.setPreferredSize(d);
          textPane2.setText( text );
          JPanel south = new JPanel();
          south.add(textPane1);
          south.add(textPane2);
          getContentPane().add(south, BorderLayout.SOUTH);
          DefaultHighlighter highlighter1 =  (DefaultHighlighter)textArea2.getHighlighter();
          highlighter1.setDrawsLayeredHighlights(false);
          DefaultHighlighter highlighter2 =  (DefaultHighlighter)textPane2.getHighlighter();
          highlighter2.setDrawsLayeredHighlights(false);
          Highlighter.HighlightPainter yellow = new DefaultHighlighter.DefaultHighlightPainter( Color.YELLOW );
          try
               textArea1.getHighlighter().addHighlight(4, 8, yellow);
               textArea2.getHighlighter().addHighlight(4, 8, yellow);
               textPane1.getHighlighter().addHighlight(4, 8, yellow);
               textPane2.getHighlighter().addHighlight(4, 8, yellow);
               textArea1.getHighlighter().addHighlight(16, 18, yellow);
               textArea2.getHighlighter().addHighlight(16, 18, yellow);
               textPane1.getHighlighter().addHighlight(16, 18, yellow);
               textPane2.getHighlighter().addHighlight(16, 18, yellow);
          catch(BadLocationException ble) {}
     public static void main(String[] args)
          JFrame frame = new Highlighting();
          frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
          frame.setSize(500, 450);
          frame.setLocationRelativeTo( null );
          frame.setVisible(true);
}Also, try selecting all the text with the mouse to see how the selection highlighting is different in each case.

Similar Messages

  • How to scan both sides of document in color to pdf with the dr-m160?

    how to scan both sides of document in color to pdf with the dr-m160?

    Hi healthynhappy1.
    To scan a 2-sided document, you will need to change the scanner settings in the software. 
    If you are using Capture On Touch:
    You will need to turn off the "Scan in Full Auto" option. 
    Next, you will open [Scanner Settings] and change the "Scanning Side" to Duplex. 
    Verify that the [Color Mode] shows "24-bit Color" and when you get the option to save the file, verify the [File Type] shows as "PDF".
    If you are using CapturePerfect:
    Click [Scan].
    Click [Scanner Settings].
    Change the [Scan Side] to "Duplex".
    Verify that [Color Mode] is set for "Color" and then save the file as "PDF".
    I hope that this information is helpful to you.  Should you need further assistance, please contact us at 1-800-OK-CANON (1-800-652-2666).  Have a great day!
    Did this answer your question? Please click the Accept as Solution button so that others may find the answer as well.

  • How can I set the default print settings of my document as color.  I want the default print setting to be color when someone opens a document.  similar to duplex print preset is there a color print preset?

    How can I set the default print settings of my document as color.  I want the default print setting to be color when someone opens a document.  similar to duplex print preset is there a color print preset?

    Hi,
    Try saving your settings as a Preset by clicking the Preset drop down and then select Save Current Settings as a Preset.
    Next try changing the settings by selecting the saved preset.
    That allow saving the settings for a specific printer, I assume it may also allow selecting these settings for another printer.

  • Making an ID document one color

    In a document with colored and B&W graphics and text is it possible to make all the graphics and text one color, for example PMS 280, to print on a Xerox Docucolor printer? Heretofore we've been coloring all the text one box at a time and doing the graphics in Photoshop or Illustrator, which is very time-consuming. Or can the document be exported as a PDF and colorized in Acrobat? Thanks!

    If you have CS3, I believe you can use GREP to replace colors. Also, look for a script that will do it. I'm pretty sure there is one.

  • How to make preflight profile witch find out if exist in document spot color with name "CutContour", if not show allert,  I try many combinations but nothing works

    How to make preflight profile witch find out if exist in document spot color with name "CutContour", if not show allert,  I try many combinations but nothing works

    Thanks very much for your help, but I'm still overlooking something. I double checked to make sure that I did not have a hidden .txt file extention. I then decided to abandon the lock on preferences idea until I get it working. I converted my mozilla.cfg file back to plain text. I made sure I do not have an extra blank line at the end of each file. The syntax looks good, as far as I can tell. I'll copy and paste what I have so far. Did I have the file locations correct posted above? Also, if you feel i can delete some lines of text in my mozilla.cfg file I'll be happy to do so.
    mozilla.cfg
    <pre><nowiki>//
    pref("privacy.sanitize.sanitizeOnShutdown", true);
    pref("privacy.sanitize.promptOnSanitize", false);
    pref("browser.rights.override", true);
    pref(“app.update.auto”, false);
    pref(“extensions.blocklist.enabled”, false);
    pref(“extensions.shownselectionUI”, true);
    pref(“browser.shell.checkDefaultBrowser”, false);
    pref(“toolkit.telemetry.enabled”, false);
    pref(“toolkit.telemetry.prompted”, 2);
    pref(“toolkit.telemetry.rejected”, true);
    pref(“app.update.auto”, false);
    pref(“browser.download.useDownloadDir”, true);
    pref(“browser.search.update”, false);
    pref(“signon.autofillForms”, false);
    pref(“signon.rememberSignons”, false);
    pref(“browser.download.manager.scanWhenDone”, true);
    pref(“browser.formfill.enable”, false);
    pref(“xpinstall.enabled”, true);</nowiki></pre>
    channel-prefs.js
    pref("app.update.channel", "release");
    override.ini
    [XRE]
    EnableProfileMigrator=false
    all-lmc.js
    pref("general.config.filename", "mozilla.cfg");
    defaultPref("browser.startup.homepage", "data:text/plain,browser.startup.homepage=http://bbc.co.uk");
    Again, thank you very much for your time. Do I create my own browserconfig.properties, and firefox.js? Also, I forgot to mention I'm running Windows 8.

  • Can't scan document in color to my mac

    Hi.
    I've been trying to scan a Document in color to my Mac but it only scans it into BW. 
    I've already tried to go to Device/ Scan Setting/ Scan Task/ Dokument/Edit and then I should see a blue triangle. Well in my case I only have a grey triangle and if I press on it to make it bigger then obviousely Mode should come up and that's where I supposedly can change from BW to colors. Well, I don't have that option Mode therefor I can't change the color. It's driving me mad and I've been on it for about 5 hours. Could you please help me? Thank you, Jbl20

    Hi Jbl20,
    Due to an issue with Mavericks, a bit earlier versions of the HP Scan software does not display the scan settings as expected.
    As of now I would suggest installing the software for a newer model, that should upgrade the HP Scan software to a newer version and then these settings will become available.
    Be sure to check the HP Scan option while installing in order to upgrade the current software, once the software installation completes and you are prompted to select the device close the device setup utlility by selecting skip or exit:
    http://ftp.hp.com/pub/softlib/software12/COL55906/​Im-134578-1/HP-LaserJet-Pro-MFP-M225_M226_v12.38.0​...
    Once you are done try scanning again andcheck if the issue been resolved, if it still persists go to HP Utility > San to Computer and edit the Scan Task, further options should become available now.
    Please let me know of any problem,
    Shlomi
    Say thanks by clicking the Kudos thumb up in the post.
    If my post resolve your problem please mark it as an Accepted Solution

  • Styles (nested?) in Long Document with Color Coded Sections

    Hi, I am looking for a solid style set-up for a document with seven color coded sections. The character, paragraph, table styles, etc. will be used throughout the book, but several of them (chapter headers, bold color, table strokes) will shift colors from section to section. What is the best way to set this up so I can still make other changes to the styles without having to edit each colored section separately.
    Thanks in advance,
    Marshall

    In practice, I'm having rouble making this work.
    I have one swatched, named "Section Color" and if I change the definition or CMYK recipie of that color it will ripple instantly through the styles( as you said,) I have swatches unchecked from the Syncronize Options, but upon syncing it still rewrites that CMYK recipie back to the style source's and all colors ripple back.
    It's not hard to reset one color for each section, but id like to know why it's changing swatches with swatches unchecked. Is it writing that color from the paragraph or other styles which ARE set to sync?

  • New printer won't print photographs or Word documents in color

    Hi, I bought an HP Officejet Pro 8625 a few weeks ago. All the ink levels are full, but when I'm trying to print a Word document or photograph from Picasa, the printer only prints in black and white. Even the "print preview" is in black and white.
    If I print a page from the Internet, the printer will print in color. But only from the Internet! I cannot get it to print in color from any other application. I've checked all my settings and have no idea how to fix this.
    Thanks for any advice.

    Hi, typically the print preview tells what you will print.
    One suspicion might be somehow the grey scale printing in the driver setting has been checked, go to the printing preferenc,  the paper quality and then advance settings and then under printer to make sure the print in gray scale option is set to Off.
    One better option that I would usually use is to Reinstall the latest Driver from Hp.com

  • Java Applet Background Color Problem on Internet Explorer

    Hi,
    Please check out the following URL:
    http://www.utopiainteractive.com/clients/AkonFinal/glossary.htm
    The menu bar is writting in Java Applet. If you scroll down the page, and scroll back up, I see white background as I scroll back up. It happens only on Internet explorer. Neither Java Applet nor HTML Body bg color is white. I am kinda lost, and any help would really be appreciated.
    Thank you and look forward to hearing from someone soon.
    Sachin

    Hi,
    Well I used HtmlConver utility to generate applet html code, so I assume nothing is wrong with Object tag. Do you know what could cause this problem on Internet explorer? To be honest, I spent last couple of days, but I am just lost. It absolutely works fine on Netscape.
    Thanks,
    Sachin

  • How to get active document  swatch color and its value

    Hi
    i want to get the swatch color of active document
    i use 3 to 4 colors both cmyk and pantone which is in swatches
    now i want to get their values using script
    any one please help me
    Thank you
    Appu

    Download the script "Render Swatch Legend" from the following site: http://www.wundes.com/JS4AI/
    This script generates a legend of rectangles for every swatch in the main swatches palette. You should be able to grab the code you need from this.

  • Inserting a PCL string in java Document for paper source control

    Got a printer issue here.
    I need to set the source printer tray from within the document using PCL because I am printing to a network printer and the driver that is being used always defaults the source tray to the printer default.
    I am inserting the String right at the beginning of the document like so:
    document.insertString(0, "\u001B&l2H", null);
    The "\u001B" is the ASCII escape character used by the control sequence and the "&l2H" is the PCL code for the Manual tray. This does insert the string into the document but when the ,prn file is created (print to file) it does not use the inserted value.
    The document type is text/html and I am 'Printing to file' using:
    aJobAttrs.add(new javax.print.attribute.standard.Destination(new java.net.URI("file:///C:/temp/out.prn"))); as suggested in another forum. The .prn file that is persisted however still sets the tray to the printer default (&l7H).
    Anyone go any suggestions?
    Ps The MediaTray.MANUAL does not work because the network print driver overwrites it.

    No, I does not set the print tray on the .prn file persited by the code. It would appear that the default tray (&l7H) is not overwritten with the tray I set in my document.
    It may have something to do with the escape characters?

  • Is there a way to check inDesign documents for color?

    I need to send a file to print and I want to make sure all of the line art is the same color swatch. The printer will charge me if they have to convert a line. The color is dark blue so I can't visually differentiate it from black in some cases. Is there a script to check the document for me or a feature in inDesign to check?

    You can do it in InDesign and in Acrobat Pro, you should check it in both programs.
    InDesign: Window > Output > Separations Preview (Panel)
    Acrobat Pro > Tools > Print Production > Output Preview, select separations
    There you can turn off any ink plate.

  • New Webi Document Default Color - BOE XI 3.1 SP2

    Hello.
    We would like to change the default color in a new webi document. I have changed defaultconfig.xml in the following paths.
    Tomcat55\webapps\AnalyticalReporting\
        webiApplet\AppletConfig
        webiApplet\AppletConfig\AppletConfig
        WEB-INF\classes
    This works as expected for Webi creation options Advanced and Interactive and the default color on my report is what I have set in the config xml file.
    But, Webi creation option Web Accessibility still shows the out of the box BO blue color. How do I change the default color for the Web Accessibility option?
    Our environment is:
    Windows server
    BOE XI 3.1 SP2
    Tomcat
    Thank you. Nancy

    Hi Nancy
    The accesible option was designed for people with disabilities who may use screen readers or other devices to interpet what is being shown on the report. As such, it probably won't pick up the default formatting properties from the XML file as the colour of the box wouldn't matter much if it's content was being read through a screen reader.
    Hope this helps!
    D.

  • Document Spot color

    Hi All,
    I require a script to find if there is any spot color used in my indesin document.
    Can anyone please provide me the code.
    Regards,
    Chang

    Hi,
    Checking applied color must be scan all objects!! of the document,
    Here is a code, it scans texts and frame objects(Text Frame, Rectangle,,,,)
    but not support table and cell.
    mg
    Thanks
    var doc = app.activeDocument;
    var mySwatch = doc.colors;
    var flag = 0;
    for (var i=0; i < mySwatch.length; i++){
        if (mySwatch[i].model == ColorModel.SPOT){
           flag += 1;
    if ( flag > 1 ){
        check_spot(doc);
    else{
         alert("no spot color");
    function check_spot (doc) {
         // scan text story exclude table and cell
         var flg2 = flg3 = flg4 = flg5 = 0
         var story_obj = doc.stories;
         for (var sti=0, stiL=story_obj.length; sti < stiL ; sti++) {
              var tsr_obj = story_obj[sti].textStyleRanges;
              for (var tsi=0, tsiL=tsr_obj.length; tsi < tsiL ; tsi++) {
                   try{
                        if (tsr_obj[tsi].fillColor.model == ColorModel.SPOT) {
                             flg2 += 1;               
                   }catch(e){$.writeln(e);}
                   try{
                        if (tsr_obj[tsi].strokeColor.model == ColorModel.SPOT) {
                             flg3 += 1;               
                   }catch(e){$.writeln(e);}
         // scan pageitem
         var all_p_item = doc.allPageItems;
         for (var api=0, apiL=all_p_item.length; api < apiL ; api++) {
              try{
                   if (all_p_item[api].fillColor.model == ColorModel.SPOT) {
                        flg4 += 1;
              }catch(e){$.writeln(e);}
              try{
                   if (all_p_item[api].strokeColor.model == ColorModel.SPOT) {
                        flg5 += 1;               
              }catch(e){$.writeln(e);}
         // result message
         if ( flg2 > 0 || flg3 > 0 || flg4 > 0 || flg5 > 0 ) {
              var tx_fill_color   = flg2 > 0 ? "used spotcolor in text fill " + flg2 + "part" : "";
              var tx_stroke_color = flg3 > 0 ? "used spotcolor in text stroke " + flg3 + "part" : "";
              var pi_fill_color   = flg4 > 0 ? "used spotcolor in page item fill " + flg4 + "part" : "";
              var pi_stroke_color = flg5 > 0 ? "used spotcolor in page item stroke " + flg5 + "part" : "";
              var rslt = [tx_fill_color, tx_stroke_color, pi_fill_color, pi_stroke_color].join('\n')
              alert("result\n" + rslt);

  • Where can I find the Java Document of com.sap.aii.af.ra.ms.api.Message

    Com.sap.aii.af.ra.ms.api.Message is class that would be used in Adapter Module development, but I found I can't find the document of it in neither Adapter Module related document nor XI Mapping related document.
    Anyone can help me?

    YiNing,
    Did you check this link,
    http://help.sap.com/saphelp_nw04/helpdata/en/87/3ef4403ae3db12e10000000a155106/content.htm
    Does it help? Also did you look into the Java Docs Section,
    https://help.sap.com/javadocs/index.html
    Regards
    Bhavesh

Maybe you are looking for

  • Why are my podcasts not syncing with Apple TV when all devices connect to the same Apple iD?

    Does anybody have an idea as to why my recently updated Apple TV does not sync my podcasts from my Apple iD. It's supposed to, it's not doing it, and it's very annoying. This is only half the aggravation; the other half is that all my podcasts have b

  • IPod will not restore in iTunes

    when i turn on my iPod it shows a screen that sais "connect iPod to computer, use iTunes to restore." When i connect the iPod to my computer to restore, it sais there was an unknown error and that it could not restore the iPod. How can i overcome thi

  • Empty CD or DVD not recognized

    Hi all After weeks of burning CDs or DVDs without any problems I suddenly get these errors and I cannot burn anymore: a.) If I load a CD-R I get from the Finder the message "Dieses Medium kann nicht verwendet werden, da es nicht erkannt wird." in eng

  • File Browser and Permission

    Hi, I am building a web site and there is a File Browser item in it. When I select a file and submit the page a message about acess denied appears. I know this error occurs because this page is public, but is there another solution to fix it?

  • Problem when trying the Stored Procedures in JDBC receiver side

    Hi, I am facing some problem when i am trying to configure a scenario in the receiver side of JDBC adpater. We have never got stored procedures to work as messages go in 'Delivering'   status always. It's as if control never gets back to the adapter