Apply change of style on DefaultStyledDocument

Hi All,
I have problem with DefaultStyledDocument. I want change attribute of some style and apply changes on text, that was written by this style. I can get style by the metod getStyle(String name) and change attribute by the metod StyleConstants.setForeground(style, color). May somebody tell me, how I must apply change on document? Thanks.

camickr wrote:
If you change the attributes of an existing Style then you should just repaint() the text pane.
If you need further help then you need to create a [Short, Self Contained, Compilable and Executable, Example Program (SSCCE)|http://homepage1.nifty.com/algafield/sscce.html], that demonstrates the incorrect behaviour.
Don't forget to use the [Code Formatting Tags|http://forum.java.sun.com/help.jspa?sec=formatting], so the posted code retains its original formatting.
Thanks for your reaction. I am sorry, ok here is some example:
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.FlowLayout;
import javax.swing.JPanel;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTextPane;
import javax.swing.SwingUtilities;
import javax.swing.text.BadLocationException;
import javax.swing.text.DefaultStyledDocument;
import javax.swing.text.SimpleAttributeSet;
import javax.swing.text.Style;
import javax.swing.text.StyleConstants;
import javax.swing.text.StyleContext;
import java.awt.GridBagLayout;
import java.util.Enumeration;
import javax.swing.JButton;
public class TestStyle extends JFrame {
     private static final long serialVersionUID = 1L;
     private JPanel jContentPane = null;
     private JScrollPane jScrollPane = null;
     private JTextPane jTextPane = null;
     private Style attrs[] = new Style[2]; //  @jve:decl-index=0:
     private DefaultStyledDocument doc;
     private JPanel jPanel = null;
     private JButton jButton = null;
     public TestStyle() {
          super();
          initialize();
     private void initialize() {
          this.setSize(300, 200);
          this.setContentPane(getJContentPane());
          this.setTitle("JFrame");
          this.setVisible(true);
          this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
     private JPanel getJContentPane() {
          if (jContentPane == null) {
               jContentPane = new JPanel();
               jContentPane.setLayout(new BorderLayout());
               jContentPane.add(getJScrollPane(), BorderLayout.CENTER);
               jContentPane.add(getJPanel(), BorderLayout.NORTH);
          return jContentPane;
     private JScrollPane getJScrollPane() {
          if (jScrollPane == null) {
               jScrollPane = new JScrollPane();
               jScrollPane.setViewportView(getJTextPane());
          return jScrollPane;
     private JPanel getJPanel() {
          if (jPanel == null) {
               jPanel = new JPanel();
               jPanel.setLayout(new FlowLayout());
               jPanel.add(getJButton(), null);
          return jPanel;
     private JTextPane getJTextPane() {
          if (jTextPane == null) {
               jTextPane = new JTextPane();
               String text = "This is some text witch will be changed.\n"
                         + "And next line...";
               int len = text.length();
               doc = (DefaultStyledDocument) jTextPane.getStyledDocument();
               Style def = StyleContext.getDefaultStyleContext().getStyle(
                         StyleContext.DEFAULT_STYLE);
               attrs[0] = doc.addStyle("one", def);
               attrs[1] = doc.addStyle("two", def);
               StyleConstants.setForeground(attrs[1], Color.red);
               doc.addStyle("one", attrs[0]);
               StyleConstants.setForeground(attrs[0], Color.blue);
               doc.addStyle("two", attrs[1]);
               try {
                    doc.insertString(0, text, attrs[0]);
                    doc.insertString(len, "This is default style. ", null);
                    doc.insertString(doc.getLength(), "And this is red style.",
                              attrs[1]);
               } catch (BadLocationException e) {
                    e.printStackTrace();
          return jTextPane;
     private JButton getJButton() {
          if (jButton == null) {
               jButton = new JButton("Change");
               //change attribute (don't work)
               jButton.addActionListener(new java.awt.event.ActionListener() {
                    public void actionPerformed(java.awt.event.ActionEvent e) {
                         Style s = doc.getStyle("one");
                         System.out.println(s);
                         StyleConstants.setForeground(s, Color.green);
                         SwingUtilities.invokeLater(new Runnable() {
                              public void run() {
                                   jTextPane.repaint();
          return jButton;
     public static void main(String[] arg) {
          new TestStyle();
}If I press the Change button blue text should change its color on green, but it isn't work.

Similar Messages

  • InDesign Paragraph Style won't apply / change

    0 down vote  favorite  
    Im hoping someone might be able to help me troubleshoot an InDesign question. Im a beginner-to-intermediate user.
    I am unable to apply my Paragraph Style to a number of my text boxes. I have tried holding Opt/Alt while choosing the PS with no luck. I have also checked for local overrides and character styles, and there appear to be none. The fly-out menu from the Paragraph Styles menu is almost all greyed-out, so it won't let me select the Clear Overrides option.
    However, when I double-click the text box to go into the frame, I am able to select the text directly and then apply the paragraph style to it directly inside the frame. This seems weird; Im hoping there's a way that I can just select the frames normally and apply a paragraph style as usual.
    The text came from a Word document that was flowed into each chapter, if that gives any help.
    Looking forward to some advice. Cheers, -Ben

    P Spier, thank you very much. What is the work around then to achieve this? Simply selecting all the text in all of the threaded frames and applying the Paragraph Style directly to them? Is it possible to select all of the threaded frames at the same time and apply the Paragraph Style to it? Advice for best method of practice is much appreciated.

  • How can I apply a GREP style to a text variable?

    Hello everybody,
    I have a question concerning GREP styles inside Paragraph styles.
    1. I've created a text variable to generate a recurring title on the upper side of the page based on the main title paragraph style;
    2. The recurring title is in Adobe Garamond Small Caps, all letters in lower case, and it is formatted with a paragraph style sheet in the master page;
    3. I want to create a GREP style for the recurring title, according to which every time that in the recurring title appear an apostrophe or the double quotes, they are automatically lowered 2pt on the baseline
    (I already created the character style sheet that lowers letters of 2pt).
    What I need is the correct GREP formula to automatically apply the character style sheet to apostrophes and double quotes, in the line of text generated by the text variable...
    Thanks for your  help
    p.

    Hi,
    As I said, using Power Headers is the best way to do it.
    As Power Headers treats the header as "live text", you can use a simple grep style inserted in the header para style:
    … to obtain:
    For the sample, I use a char style named "-2pts" with Shift -5 pts and Green color to show you the place of ' and ".
    Don't forget that, even Power Headers treats the header as "live text", you only have to update Power Headers to make an update of the headers! 
    Even I use in another cases Tomaxxi's [JS] and it's a good way to treat the question, Jean-Claude Tremblay's solution is less interesting because the variable used is converted in text. If the variable text content changes, it's more complicated to manage the update!

  • How to apply multiple paragraph styles to one sentence?

    I'm using paragraph styles but is not helpful because I'm trying to apply 2 different styles within the same sentence which is not working.
    To make it work I select the sentence, apply the style, for instance "xfont-regular" then I select the word within the sentence that I want it to have a different style and I choose from the font list maybe italic so that it looks "something like this"
    Obviously by doing this, I'm loosing all the benefits of using p styles and of course it's so time consuming. Is there any way to break the sentence, keeping it in the same line, so that I can apply different styles to it? and still keep the benefits of just going to the styles and make the changes to the whole document that have that style applied.
    Thank you

    pchinique wrote:
    I'm using paragraph styles but is not helpful because I'm trying to apply 2 different styles within the same sentence which is not working.
    To make it work I select the sentence, apply the style, for instance "xfont-regular" then I select the word within the sentence that I want it to have a different style and I choose from the font list maybe italic so that it looks "something like this"
    Obviously by doing this, I'm loosing all the benefits of using p styles and of course it's so time consuming. Is there any way to break the sentence, keeping it in the same line, so that I can apply different styles to it? and still keep the benefits of just going to the styles and make the changes to the whole document that have that style applied.
    Thank you
    As Diane King mentioned, nested character styles may work for your need. Her example was an initial dropped capital (multi-line first one or several letters of a paragraph.) Dropped caps are a specific type of nested style - always the first one or more characters in a paragraph, two or more lines high.
    To use the general kind of nested style, you need to be able to identify the word or words within the paragraph that gets the nested character style. For example, the third word, or the first two words after the first semi-colon. If there is no pattern of word(s) that can be identified by position or sequence, it's possible that a GREP style can be used to find a common pattern of characters and apply a character style to it, for example a telephone number, date, or currency amount that's identified by a dollar sign, pound, or yuan.
    Search InDesign Help and Google for "InDesign nested style," "InDesign grep style," and similar terms (without quotes) for details. There have been many discussions of GREP on this forum.
    HTH
    Regards,
    Peter
    Peter Gold
    KnowHow ProServices

  • How can I change the style of a row in tableview?

    Hi,
    How can I change the style of a row in tableview, for example ,I have 10 items in table view, and I'd like to change row 1,4,10 background-color:red; font-family:Arial ,Font-Weight:BOLD.
    Any suggestion?

    Yes, I knew how can I change the style using cell factory. there is a lot of work to do if it has so many columns in table view. we need to implement every cell factory, Do we have a simple way to change the whole row style , just like fabsav said, I 'd like to set the special row like this line:
    tableview.getItems().get(i).setStyle("myRowstyle"); And I found a bug if I implement my functionality with cell factory way, I can't change the cell style after rendering cell.
    protected void updateItem(Object object, boolean empty) {
          super.updateItem(object, empty);
    }updateItem() was only triggered while cell is being rendering, there is no way if I'd like to change the cell style after rendering event.
    Hi fabsav, How can I apply a CSS class to a specific row? Can you please provide a short example?
    Edited by: imtoocute on Aug 28, 2012 10:31 AM

  • How to apply a Character Style that's already been made in a template document?

    First of all I'd like to thank everyone that helps. I'm a complete beginner at scripting and appreciate all your help.
    I'm basically using GREP expressions to find patterns in a document and apply a Character Style which has already been made. This Character style was not made using script, but just in InDesign when making and setting up the template.
    var myDoc = app.activeDocument;
    //Clear the find/change grep preferences.
    app.findGrepPreferences = NothingEnum.nothing;
    app.changeGrepPreferences = NothingEnum.nothing;
    //Set the find options.
    app.findChangeGrepOptions.includeFootnotes = false;
    app.findChangeGrepOptions.includeHiddenLayers = false;
    app.findChangeGrepOptions.includeLockedLayersForFind = false;
    app.findChangeGrepOptions.includeLockedStoriesForFind = false;
    app.findChangeGrepOptions.includeMasterPages = false;
    //GREP Expression for finding all HEADERS
    app.findGrepPreferences.findWhat = ".+\n";
    //Applying formatting changes to put into All Caps, Bold and changing the font size to 12 pt.
    app.changeGrepPreferences.capitalization = Capitalization.allCaps;
    app.changeGrepPreferences.fontStyle = "Bold";
    app.changeGrepPreferences.pointSize = "12";
    myDoc.changeGrep();
    //Clear the find/change preferences after the search.
    app.findGrepPreferences = NothingEnum.nothing;
    app.changeGrepPreferences = NothingEnum.nothing;
    This is how I currently have it. I will manually define the changes to the text. The problem is, each template uses a different set of fonts and not all of them use Bold e.g. Sabon can use CE Bold.
    I would like to learn how to apply a Character Style and have tried looking around but nothing seems to work.
    Any help would be much appreciated.
    Thanks.

    select the text where u went  and run below  script after change group as per ur template.
    var myDoc = app.activeDocument;
    var mySel = app.selection[0];
    //Clear the find/change grep preferences.
    app.findGrepPreferences = NothingEnum.nothing;
    app.changeGrepPreferences = NothingEnum.nothing;
    //Set the find options.
    app.findChangeGrepOptions.includeFootnotes = false;
    app.findChangeGrepOptions.includeHiddenLayers = false;
    app.findChangeGrepOptions.includeLockedLayersForFind = false;
    app.findChangeGrepOptions.includeLockedStoriesForFind = false;
    app.findChangeGrepOptions.includeMasterPages = false;
    //GREP Expression for finding all HEADERS
    app.findGrepPreferences.findWhat = "role";
    //Applying formatting changes to put into All Caps, Bold and changing the font size to 12 pt.
    //app.changeGrepPreferences.capitalization = Capitalization.allCaps;
    //~ app.changeGrepPreferences.fontStyle = "Bold";
    //~ app.changeGrepPreferences.pointSize = "12";
    app.changeGrepPreferences.appliedCharacterStyle=myDoc.characterStyleGroups.item("Style Group 1").characterStyleGroups.item("Style Group 2").characterStyles.item("Header")// Header is name of character name
    mySel.changeGrep();
    //Clear the find/change preferences after the search.
    app.findGrepPreferences = NothingEnum.nothing;
    app.changeGrepPreferences = NothingEnum.nothing;
    If it's help then click yes
    Mi_D

  • GREP for changing paragraph style?

    Okay folks, I have another one for all you smart people out there. I think GREP can be used to change formatting in the following instance, but I have no idea how to set it up.
    I have a very long document, essentially a phone book-type listing of names, phone numbers, addresses, well over 150 pages' worth. The paragraph styles are fairly simple, only two per listing. The name/phone number is bold with a right hand tab with leader dots to a phone number that is flush to the right side of the column. The following lines are flush left, not bold, but indented 6pts. I've placed the text file and assigned the entire thing the NameListing paragraph style. I'd like to use GREP to find the address lines and change them to the NameListingAddress paragraph style.
    Here's a screen shot to give you an idea. The left column is formatted correctly with both styles, the right column is "raw", all paragraphs formatted with the NameListing paragraph style.
    Is this an appropriate application for GREP? If so, how do I set it up to only change the paragraphs that "don't have tabs"? It would save me a crapload of time.
    THANKS again! --Dina

    If your intent here is to use the character style to trigger a variable, as I belive it is based on your other thread, you MUST apply the character style up to the first tab to pick up the text at the start of the paragraph. There are two approaches to automating the formatting after that, but it may be too late for you to be much help.
    In cases where every listing has the same number of lines it makes sense to use a unique paragraph style name (not necessarily format -- base on on another) for each lline and make it its own paragraph. Set up "next styles" to rotate through the list so each line is assigned the correct style based on the style of its predecessor. You get the rotation to sart over by making the first line style the next style for the last line. This works for manual entry and can be applied to an entire block of placed text in a single operation by selecting the text, then right-clicking the name of the first style to be applied and choose Apply <stylename>, Then Next Style.This ONLY works if you have exactly the same number of paragraphs in each listing.
    The other option is to use forced line breaks instread of paragraphs and use one style for the entire listing. Set a left indent and negative first line indent, create a character style for the part of the first line that you want to appear in your header and apply it Up To ^t^n (that's a little-known trick -- if you enter more than one character in the trigger for a nested style it will activate on the first instance of any of the characters listed that occurs, so for example if you enter the word cat, your style will end on the first, c, a or t that appears inthe paragraph. ^t is the metacharacter for tab, and ^n is for forced line break) so that the style will end at either the tab, if present, or the forced line break if there is no tab (if you use a right-indent tab instead of a regualr right aligned tab [tricky to do a leader, but that's another discussion] substitute ^y for the ^t), then add a nested Line Style for one line. That line style should use a second character style that is based on the first character style you created for the name text and has no other attributes if you want the line to be the same from end to end. Sounds more complex than it is, and will work for listings with variable lenghths. The trick is to repalce your paragraph returns with forced line breaks, and will require a little thinking.
    If using separate paragraph styles for each line, you'd use the same technique of a nested style up to a tab for the first line, but there is no need to get fancier since it will apply to the whole line if there is no tab. The paragraph style, in this case, would carry all of the bold and size formatting (and no need for any indents), and the character style would be nothing more than a name that will allow you to use it in the variable.

  • How to Apply A Font Style in Mail?

    This seems like a simple question, but I can't seem to find an answer by searning this forum.
    I'm new to Mail (recently converted over from Entourage). Quite often, the e-mails I compose are a hodge podge of cut and pastes from other messages and documents. The result is a mix of fonts and font formats.
    I would like a simple way to highlight all of the text in a document and apply a single style. Essentially, I want a way to apply a single style to all of the text in a mail message.
    I can't seem to find this in Mail. I've tried to "apply" the default style using the Format --> Style ... menu, but that doesn't work as expected (I don't think it changes anything). Looking up "Style" in the Help menu brings up nothing of help.
    Any suggestions?

    you could also select Verdana 12pt as your Fixed-width font and your Message font in preferences under fonts/colors, then check the box that says "use fixed-width font for plain text messages"
    then you could select your text command-A, then Shift-Command-A (to convert to plain text) which would convert everthing to verdana 12pt, then if you wanted rich text message again, just press Shift-Command-A again and it will stay with Verdana 12pt but be a rich text message.
    This would only be 2 and at the most 3 key combos with no mouse clicks to achieve what you mentioned in your previous post.

  • Apply different font styles in single text frame

    hi all
    how can i apply different font styles in a single text frame using indesign script ?
    for example :
    "dasdnasndasndlasndnasdlasdasdas"
    may i know is it possible to do that and how to do that ?
    thanks

    You can set (as well as read) every single property of any text range with scripts. This is javascript; it assumes you text cursor is inside a frame with some text.
    * Setting some specific characters to a color:
    app.selection[0].parentStory.characters.itemByRange(5,10).fillColor = "Red";
    * Change the font of words:
    app.selection[0].parentStory.words[3].appliedFont = "Arial\tBold";
    * .. or just the style:
    app.selection[0].parentStory.lines[2].fontStyle = "Italic";
    * .. or any other attribute (this one requires you to have at least 5 characters selected):
    app.selection[0].characters[5].underline = true;
    Of course these operations are not limited to something you select; they work the same with any text frames you can refer to.
    app.activeDocument.textFrames[1].paragraphs[2].appliedCharacterStyle = "charstyle";

  • Changing a style in xss depending on the facet

    Is it possible to change a style in the xss depending on the facet?
    I want to change in my UIX application the prompt style of the messageTextInput components - not the contentStyle - for example underline the prompts. But I want this to happen only if facet==printable.
    Can I change this once in an xss and apply it to the whole application? I know I should change the OraPromptsomething (I've found the correct one, I just don't have its name here) - but I don't know how to change it depending on the facet

    So I suppose it is not possible?

  • Multiple record data merge into paragraph styles-applies the wrong style

    Hi, I've been working on this project for sometime and everytime I manage to get one part of the workflow to work another seems to break. My agency publishes catalogs in multiple formats: large-print, audio, braille, and HTML. I've been trying to redesing our work process so that the catalogs will be laid out from merged data out of comma-separated file. The data merges have worked fairly well in Word, but InDesign is a challenge. I'm merging multiple records on a page, like a mailing label. The paragraphs need to be formatted and I'm trying to apply a paragraph style to them. After much work, I think I've finally got the data merge to work correctly, but the wrong paragraph styles are applied. I'm going to apply a new master page to the data once the data is merge that uses the paragraph styles for text variable running headers and I need to build a table of contents based on the paragraph styles so I need this to work. Attached are some screenshots.
    Master page set up for data merge with paragraph styles:
    Here is the merged document with the wrong paragraph styles applied:
    I have only a few weeks to get this process ironed out to keep to our rigorous production schedule. If anyone can help I would really appreciate it.
    thanks,
    Lina

    I don't remember this happening in past versions. But I mainly use XML. And a quicky test converting your file to XML worked fine (and besides, it ends up all in continuous text frames...).
    I don't do much GREP. But you can do this via a Find/Replace.
    First, in your main document, you can delete the tags--but do this on a second copy of your working file!
    Change your Content Placement options to not remove blank lines (these are in the Datamerge panel).
    Then after the merge, change the format of the two blank lines at the beginning of the records without the two lines of data:
    Note the Change Format style is changing those two paragraphs to Title.
    Then rerun the find to remove the two blank paragraphs.
    I suspect this can be done easier. I am sitting awaiting an appointment and cannot go much further than this for now, sorry.

  • Changing Multilist Styles causes RH not to Compile

    I am using Robohelp 8 HTML. After changing the style of the Multilevel list by clicking the Increase space between list prefix and paragraph text twice for each of the 9 levels, I could not complie correctly. I got the 512 byte warning but no fatal errors. When the compilation was completed, I clicked View Result and got nothing. The .chm file could not be opened. I dont like the look of the default multi level list format with the text wrapping under the number and want to fix it. I can fix it in my topics but once I go to compile, the .chm can not be opened...please help!

    Thanks to Peter, whose messages late Friday and yesterday I
    didn't see until this morning, I now retract nearly all of my
    previous post.
    It happened that kadov cleanup was coded late in the RH 7
    development cycle. I was looking at topics in a project that I had
    started in RH 6, then opened in a test version of RH 7 that was not
    the final release. Even though I started fresh, with a new project
    in the final RH 7 release, and imported those topics from the old
    RH 7 project, they had been tainted, apparently. I apologize for
    this false alarm.
    I think my old .css stylesheet was an unnecessary
    complication. I plan to create a new one in RH 7 to match those
    styles.
    Another oddity that still clouds the picture:
    When you import topics from an RH 6 project, the RH 7 view of
    html source shows no evidence of kadov tags.
    However, even after you save and close the new RH 7 project,
    Notepad and FAR find kadov tags lurking about until you make a
    change and save the topic in RH 7.
    I understand you can edit and restore text in RH 7 before
    saving, and kadovs will be gone in Notepad and FAR, as well as from
    RH html view.
    RH 7 does better if you open the old project directly, rather
    than importing individual topics. Yet, the old .css style sheets
    (default, etc.) retain kadovs. Maybe they get cleaned up later if
    you apply them, I haven't tried.
    Harvey

  • Envelopes & Changing Graphic Styles

    Hi All,
    When I create an envelope warp with text then apply a "Graphic Style 1" that works fine. If I close the file and reopen the "Graphic Style 1" is correct. When I attempt to change to"Graphic Style 2" the text seems to make a double. If I remove the envelope I can toggle from graphic styles fine.
    Any help is appreciated!! Thank you!!

    Jennifer I am using CS 4 and if I apply a graphic style the text after I do an envelope distort with warp it applies fine if I then select a new graphic style for the text it is now the new graphic style.
    <br />
    <br />I think it should work this way in Illustrator CS2 and CS 3!
    <br />
    <br />I would try to trash the preferences or perhaps you could go step by step for us on how you are doing this!
    <br />
    <br />
    <a href="http://www.pixentral.com/show.php?picture=1NW8z66B8s52GNRTqS8h1FT1rhKZE" /></a>
    <img alt="Picture hosted by Pixentral" src="http://www.pixentral.com/hosted/1NW8z66B8s52GNRTqS8h1FT1rhKZE_thumb.png" border="0" />
    <br />
    <br />
    <a href="http://www.pixentral.com/show.php?picture=1LahzVcWrwhuYNMbsyp7RdPvghOC" /></a>
    <img alt="Picture hosted by Pixentral" src="http://www.pixentral.com/hosted/1LahzVcWrwhuYNMbsyp7RdPvghOC_thumb.png" border="0" />

  • Can you apply different paragraph styles for each orientation?

    I would like to apply different paragraph styles to the text, depending if it is viewed on portrait or landscape mode, but everytime I change one the other changes automatically. Is there a way to break this link?
    Thanks

    Unfortunately, iBA doesn't provide a lever to pull that can make a particular text style orientation specific.

  • Help: apply different para styles to several consecutive paragraphs via script

    Hi all,
    I need to apply different para styles to several consecutive paragraphs via script, something like this (found somewhere on the net):
    var myDoc = app.documents[0];
    var mySel = app.selection[0];
    var myPStyle1 = "A";
    var myPStyle2 = "B";
    //need to add 6 more styles here:
    //var myPStyle3 = "C";
    //var myPStyle4 = "D";
    //var myPStyle5 = "E";
    //var myPStyle6 = "F";
    //var myPStyle7 = "G";
    //var myPStyle8 = "H";
    //the last style not needed in script?
    // apply 1st style to 1st paragraph
    mySel.appliedParagraphStyle = myDoc.paragraphStyles.item (myPStyle1);
    // apply styles to paragraphs after selected
    //2nd style
    mySel.paragraphs[-1].insertionPoints[-1].appliedParagraphStyle = myDoc.paragraphStyles.item (myPStyle2);
    //next style
    mySel.paragraphs[-1].insertionPoints[-1].paragraphs[0].insertionPoints[-1].appliedParagrap hStyle = myDoc.paragraphStyles.item (myPStyle2).nextStyle;
    I've tried badly, but can't find the way to extend the sequence
    Sorry, no skills in scripting yet...
    all styles have 'Next Style' option activated, but I can't use 'Apply style, then Next style' or Object styles, because I need four different sequences of those para styles:
    A-B-C-D-E-F-G-H
    A-B-D-E-G-H
    A-C-D-F-G-H
    A-D-G-H
    and I really don't want to create special clones of the same style for each sequence (Keep It Simple, they say ).
    I believe it can be done via four slightly adjusted scripts...
    any suggestions would be greatly appreciated...

    Sorry about being late to the party, I usually pick up stuff like this right away.
    How about this one?
    1. No separate scripts needed, it uses a tiny dialog where you can choose what style set to use. If I'm correct, you can press a number key on Windows to immediately select one of the items.
    2. It works down from the paragraph your cursor is in. It has nothing to do with text frames, though -- consecutive paragraphs inside a story always ignore any text frames.
    3. Extensible: you can easily change the names of the styles in the top array, and the number of style groups in the list.
    var styleLists = [
              [ "A", "B", "C", "D", "E", "F", "G", "H" ],
              [ "A", "B", "D", "E", "G", "H" ],
              [ "A", "C", "D", "F", "G", "H" ],
              [ "A", "D", "G", "H" ]
    var radiobutts = [];
    styleDialog = app.dialogs.add ({name:"Set Multiple Styles",canCancel:true});
    with (styleDialog)
              with (dialogColumns.add())
                        with (radiobuttonGroups.add())
                                  for (i=0; i<styleLists.length; i++)
                                            // Build radio button string
                                            str = "&"+String (i+1)+". ";
                                            for (j=0; j<styleLists[i].length; j++)
                                                      if (j) str += "-";
                                                      str += styleLists[i][j];
                                            radiobutts.push (radiobuttonControls.add({staticLabel:str, checkedState:false}) );
    radiobutts[0].checkedState = true;
    if (styleDialog.show())
              for (i=0; i<radiobutts.length; i++)
                        if (radiobutts[i].checkedState == true)
                                  break;
              if (i < radiobutts.length)
                        par = app.selection[0].paragraphs[0];
                        for (j=0; j<styleLists[i].length; j++)
                                  par.appliedParagraphStyle = styleLists[i][j];
                                  par = par.parentStory.paragraphs.nextItem(par);

Maybe you are looking for

  • Open a Particular view in MM03

    Hi all I want to open the MRP4 view of MM03 (directly) by passing the value of Material plant & Storage loc to the tcode. I have tried using the BAPI -> MATERIAL_MAINTAIN_DIALOUGE, but it opens the MRP1 view any pointers will be helpful. Regards Ravi

  • I am in Greece, do i need a power converter or can i just use a plug adaptor to charge my macbook pro?

    I am in Greece, do i need a power converter or can i just use a plug adaptor to charge my macbook pro?

  • Java.util.NoSuchElementException

    Hi friends, I am retrieving data from SAP to mysql table.. While doing that i am getting the error of java.util.NoSuchElementException. Exact code which error is getting is count++;                     for(com.sap.mw.jco.JCO.FieldIterator fI = tableL

  • No sound in itunes 7

    ive just downloaded the new itunes 7 and updated my ipod and its all workin fine expect there is no sound, nothin at all! perfect sound in all other media players but nothin in itunes! any ideas? help!! windows xp    

  • Out standing  downpayment in project

    Hi, I'm trying to close project , but am getting the message that there is an outstanding downpayment on  wbs . How do find out that  which down payment request or downpayment are not cleared for particular wbs. Your valuable  in this regards highly