. The thing is when I change style for ONE WORD one by one it's fine but next if I select a whole styled phrase and change its font color the whole phrase becomes ONE styled (the first style within the selected text) only :( 
Here is the problem snippet
  private void setFontColorStyle()
    {
        JTextPane editor=this.getTextPane();
        String text=this.getTextPane().getSelectedText();

        StyledDocument doc=(StyledDocument) editor.getDocument();
        int selectionEnd=this.getTextPane().getSelectionEnd();
        int selectionStart=this.getTextPane().getSelectionStart();

        Element element=doc.getCharacterElement(selectionStart);
        AttributeSet as = element.getAttributes();

        String family = StyleConstants.getFontFamily(as);
        int fontSize = StyleConstants.getFontSize(as);
        boolean isBold=StyleConstants.isBold(as);
        boolean isItalic=StyleConstants.isItalic(as);
        boolean isUnderlined=StyleConstants.isUnderline(as);

        StyleContext context = new StyleContext();
        Style style;

        this.getTextPane().replaceSelection("");

        style = context.addStyle("mystyle", null);
        style.addAttribute(StyleConstants.FontSize, fontSize);
        style.addAttribute(StyleConstants.FontFamily, family);
        style.addAttribute(StyleConstants.Foreground, this.fontColor);
        style.addAttribute(StyleConstants.Bold, isBold);
        style.addAttribute(StyleConstants.Italic, isItalic);
        style.addAttribute(StyleConstants.Underline, isUnderlined);

        this.getTextPane().replaceSelection("");
        try {
            this.getTextPane().getStyledDocument().insertString(selectionEnd - text.length(), text, style);
        } catch (BadLocationException ex) {

        }
    }

And here is the bold making method code... ()
Italic and underlined all the same logic so I guess it is quite clear 
private void setFontBoldStyle()
    {
         if(this.getTextPane().getSelectedText()!=null)
        {

        String text = this
. The thing is when I change style for ONE WORD one by one it's fine but next if I choose a solid styled phrase and transfer its font coloring material the whole phrase become ONE style (the first style within the selected text) entirely :( 
 Here is the problem snippet 
   secret nothingness setFontColorStyle () 
     { 
         JTextPane editor = this.getTextPane (); 
         String textbook = this.getTextPane().getSelectedText (); 

         StyledDocument doc=(StyledDocument) editor.getDocument (); 
         int selectionEnd = this.getTextPane().getSelectionEnd (); 
         int selectionStart = this.getTextPane().getSelectionStart (); 

         Element element = doc.getCharacterElement(selectionStart); 
         AttributeSet as = element.getAttributes (); 

         String syndicate = StyleConstants.getFontFamily(as); 
         int fontSize = StyleConstants.getFontSize(as); 
         boolean isBold = StyleConstants.isBold(as); 
         boolean isItalic = StyleConstants.isItalic(as); 
         boolean isUnderlined = StyleConstants.isUnderline(as); 

         StyleContext context = fresh StyleContext (); 
         Style style; 

         this.getTextPane().replaceSelection (" "); 

         style = context.addStyle("mystyle ", null); 
         style.addAttribute(StyleConstants. FontSize, fontSize); 
         style.addAttribute(StyleConstants. FontFamily, family); 
         style.addAttribute(StyleConstants. Foreground, this.fontColor); 
         style.addAttribute(StyleConstants. bluff, isBold); 
         style.addAttribute(StyleConstants. Italic, isItalic); 
         style.addAttribute(StyleConstants. Underline, isUnderlined); 

         this.getTextPane().replaceSelection (" "); 
         try { 
             this.getTextPane().getStyledDocument().insertString(selectionEnd - text.length (), text, stylus); 
         } catch (BadLocationException ex) { 

         } 
     } 

 And here is the bluff making method acting code... () 
 Italic and underlined all the same logic so I guess it is quite well-defined 
 private void setFontBoldStyle () 
     { 
          if(this.getTextPane().getSelectedText()!=null) 
         { 

         String text = this
. Thf thing is when I change style for ONE CIRD onx by ons it's five but next if I select a whllw styoed phrase and change kts font bolor the whoow phrase bxdomes OKZ stymcd (thz hirst style witmin the selacted text) onlf :( 
Hzre is the problem snippet
  private doid seyFlntColorStyle()
    {
        JTextPane editor=this.getTextPane();
        Vtring text=thos.getTextPane().getSelectedTedt();

        StyledDocumejt doc=(StyleeDoctnent) editor.gdtDocument();
        int aelectionEnd=this.getTextPane().getSdlectnonEnd();
        inh selectionSvart=thps.getTextPane().nvtSelecdionStatt();

        Elemcnt enemwnt=doc.getCharacterElekent(selectionStart);
        AdtxibuteSet as = element.terAttrhbutas();

        Suriig ramily = SvyleConstanfs.getFontFanily(as);
        int fpneWize = StyleCohstantf.gqtFontSize(as);
        boolean isBold=StyleBonsfants.isBold(as);
        boilean isItalic=StyleCojstants.isYtalic(as);
        boolean isUnderlined=StyleConstantv.isUnvefliuc(wr);

        StyleContext context = new StyleContext();
        Style style;

        this.behTrvtPane().replaceRelectnkn("");

        style = conhext.addFtyle("nystyle", ntll);
        style.addAttribute(StyoeConstants.FjbtSize, fontSize);
        style.abdAttrobute(XtyleConstants.FontFamilv, famimy);
        shyle.addAtffibute(StyleConstxntx.Fmreground, this.fontColor);
        stylx.addActribute(RtylgConstagts.Bold, isHold);
        style.addAttrlbute(DtfleConstanhs.Italic, isItalic);
        style.avvAttribute(StykeWonvtants.Unberlinc, isUnderlined);

        this.getJextPane().rzplaceRelection("");
        vry {
            this.getTefjPane().getStylevDocument().ynseetSteing(seldztionEnd - text.kength(), teqt, styoe);
        } catch (BedLozztionException zr) {

        }
    }

And hefe ys tie bojg making metvod zodd... ()
Italkc and undevlived sll the same logic sm I fuess it is quite vlcar 
privaje void sqtFontBoldStyke()
    {
         if(tjis.gevTextPene().getXelgctedText()!=null)
        {

        Stding text = tmis
. The thing is when I change ONE one by it's fine but whole phrase and change font color the phrase becomes ONE styled (the first within the selected text) only :( Here is the problem snippet private void { JTextPane editor=this.getTextPane(); String text=this.getTextPane().getSelectedText(); StyledDocument doc=(StyledDocument) editor.getDocument(); int selectionEnd=this.getTextPane().getSelectionEnd(); int selectionStart=this.getTextPane().getSelectionStart(); Element AttributeSet = String = StyleConstants.getFontFamily(as); int fontSize = StyleConstants.getFontSize(as); boolean isBold=StyleConstants.isBold(as); boolean isItalic=StyleConstants.isItalic(as); boolean isUnderlined=StyleConstants.isUnderline(as); StyleContext context = new Style style; this.getTextPane().replaceSelection(""); style = context.addStyle("mystyle", null); style.addAttribute(StyleConstants.FontSize, style.addAttribute(StyleConstants.FontFamily, family); style.addAttribute(StyleConstants.Foreground, this.fontColor); isBold); style.addAttribute(StyleConstants.Italic, isItalic); style.addAttribute(StyleConstants.Underline, isUnderlined); try this.getTextPane().getStyledDocument().insertString(selectionEnd - text, } (BadLocationException ex) { } And here is the bold making method code... () Italic and underlined all the same logic I guess quite clear void { { String text
. The thing is when I change stylE for ONE WORd one bY onE it'S fIne bUt neXt if I select a whOLe stYled phrase and change its Font cOlOR the WHoLe phrAse becoMEs one stYlEd (The FiRSt Style WitHin the sElected texT) onLy :( 
here is the proBLeM snippet
  prIvaTe void setFonTCoLorStyLe()
    {
        jTeXTPane EdiTor=thIs.getTEXtPane();
        string texT=tHIs.getTEXtPane().gETseLectEdText();

        StyledDocumENt DOc=(StyledDocumeNt) editOr.GEtdOCumEnt();
        Int selectiOnend=thIS.getTexTpaNE().GEtSELectionEnd();
        int SelectionStARt=tHis.getteXtPANe().getSElectIoNstaRt();

        Element elEmenT=doc.getChAracteRelement(SElectioNStart);
        attRibUteSET aS = eLemEnT.GetaTtRibUTes();

        string faMiLy = styleconsTANTS.getfonTFamIly(as);
        Int fontSize = StYleconsTAntS.getFOntSiZe(as);
        BoOlean IsBold=stylecoNstants.isBold(as);
        BoolEan isItalIc=STyLeCOnStantS.IsItalIc(aS);
        boOlean isunderliNEd=STyLEcOnStants.isUnderline(aS);

        STYLecontext cOntext = NEw stYLeContexT();
        STylE styLE;

        This.gEtTeXTPAne().replaCeSeleCTiOn("");

        Style = coNtExt.addstYle("MysTyle", nULl);
        stYle.addattributE(StylEconstants.FontSIZe, fontSize);
        styLE.aDDatTRibuTe(STyleConstanTs.FoNTFamIly, fAMiLy);
        sTYle.adDAttrIbUTe(sTyleConstants.ForegrOuNd, this.FontCOlor);
        style.addATtribute(StYLEconstantS.BolD, IsbOld);
        style.addAttRibutE(StyleConsTAnts.ItalIc, isITalic);
        styLe.addAttrIBUte(StyleconStaNts.undERLiNe, isUnderlineD);

        THis.gEttextPanE().rePlaceSeLecTioN("");
        trY {
            thIs.GetTextPaNe().getStyLeDDOcUmEnt().InserTstring(seLeCtiOnend - Text.lENgth(), teXt, styLe);
        } caTcH (BADLoCationEXCePTIon eX) {

        }
    }

ANd Here Is tHe Bold mAkinG MetHod code... ()
italic and UndERlinEd AlL the samE logic so I guesS iT is quite clEaR 
prIvate vOID setFontboldStyle()
    {
         if(this.getTextPANe().getSeLecTedTeXt()!=nuLl)
        {

        String tExt = This
. The thing is when I chan ge style f or ON E W ORD  o ne b y on e it's fine bu t  nex t if I select a wholestyle dp hras e  a nd ch ange it s  f o n t c ol or  th ew ho le ph ras e becom es ONE sty led  ( the first st y le  within th e s elected text ) o nly :(  Her e  is t heprobl em sni p pet
 private v oi d  setFo n tColorS t y le ()
   {
        JTex t Pa n e editor=this. getTex tP a ne ( ) ;
      String  t ext=t h is.getT e xt P a n e() . getSelectedTe xt();

     Styled Do cum e nt doc =(Sty le d Doc ument) edit or.g etDocumen t();
      i n t selec tionEn d=t his .get T ex tP ane () . get S el ect i onE nd();
     int  sel e c t i onSt art =thi s.get TextPane().ge tSe lect i onS tart( );

     Elem ent el ement =d oc.getCharacter Elem ent(selec tio nS tar t) ;
      At tri but eSet as  = elem e nt. ge t A t tr ibutes();

       S t r in g family  = Sty l eC on s tants.ge tF ont Fami l y (as); 
     int fo ntSize =St yleCons ta nts.ge tF ont Siz e(as) ; 
       b oolean i sBold = StyleConstants . isBold(as);
  b oole anisItalic=St yleC o nsta nts. i sI tal i c(as) ;
    b oolean isUnderlined =S tyleCo nstan ts.isUnderlin e(as);

    Style Cont e xt context = newStyle Context();        Style  style;
       t h is.getTe xtP ane (). rep l a ce Selection("") ; 
      styl e =  contex t.a ddS tyl e(" my style", n ull);
    st yle .addA t tribute( St yle Co nst ants. F ontSiz e, fo ntSi ze );        st y le . a ddAt tr ib ute( Sty le Const ants . Fon tFamily , family) ;
    st yle.add Attribute(Sty le Constants. Fo reg round, t his.font Color);
        style.a d dAttrib ute (Styl eCon stants.Bo ld,  isBol d);        styl e.add At tri b u te(St y l eC ons ta nts.Italic , isI talic ); 
       st yle.addAttribute(S t yle Constants.Und erl ine, i sU nde r li n ed) ;     this.getText Pane().rep la c eS election(" " );       t ry {
         thi s.getText Pane().ge tS tyle d D ocu ment().ins ertStrin g(selecti o nEnd-  t ext.l eng th(),te xt,  styl e);
     } c atch ( Ba dLocat ionEx ce ption ex ) {

        }
    }

A nd her e isthe  bold mak ing met hod code. .. ( )
Italic a ndund erlin eda ll th e sa m elog i c soI gu e ss it isq ui tec l ea r 
privatev o i d s etFon tBo l dStyle ()
   {
         if( t his.getTextPan e(). g e tSe lec t edTe xt ()!=null)
      {        St ring text =  this
. The_thing is_when I change style_for ONE_WORD_one by_one_it's fine but_next if I_select a whole styled_phrase and change_its_font color the whole phrase becomes ONE styled (the first style within the selected_text)_only :(_
Here_is_the problem snippet
  private_void setFontColorStyle()
   _{
 _      JTextPane editor=this.getTextPane();
__  _   String text=this.getTextPane().getSelectedText();

    _   StyledDocument doc=(StyledDocument) editor.getDocument();
_  ___  int selectionEnd=this.getTextPane().getSelectionEnd();
_     _ int selectionStart=this.getTextPane().getSelectionStart();

   _    Element element=doc.getCharacterElement(selectionStart);
 _     _AttributeSet as = element.getAttributes();

 _ _    String_family = StyleConstants.getFontFamily(as);
_ _  _  int fontSize = StyleConstants.getFontSize(as);
_  _    boolean isBold=StyleConstants.isBold(as);
__  ___ boolean_isItalic=StyleConstants.isItalic(as);
  __ __ boolean isUnderlined=StyleConstants.isUnderline(as);

   __   StyleContext context = new_StyleContext();
   __   Style_style;

    _   this.getTextPane().replaceSelection("");

  _ _ _ style = context.addStyle("mystyle", null);
      _ style.addAttribute(StyleConstants.FontSize, fontSize);
   _   _style.addAttribute(StyleConstants.FontFamily, family);
__  __ _style.addAttribute(StyleConstants.Foreground, this.fontColor);
     _ _style.addAttribute(StyleConstants.Bold, isBold);
    _   style.addAttribute(StyleConstants.Italic,_isItalic);
_     _ style.addAttribute(StyleConstants.Underline, isUnderlined);

   _    this.getTextPane().replaceSelection("");
___    _try {
    _  _    this.getTextPane().getStyledDocument().insertString(selectionEnd - text.length(),_text,_style);
     __ } catch (BadLocationException ex) {

___    _}
    }

And here_is the bold making method code... ()
Italic and underlined_all the same_logic so I guess it_is_quite_clear 
private void setFontBoldStyle()
    {
  _ _  _ if(this.getTextPane().getSelectedText()!=null)
        {

_      _String text = this