I figured out how to make indentation with

SimpleAttributeSet  style = new SimpleAttributeSet();// = doc.addStyle(null, null);
StyleConstants.setLeftIndent(style, 12);
StyleConstants.setFirstLineIndent(style, -12);

and then use doc.setParagraphAttributes(doc.getLength(), 1, style, false); after the insert into document. now numbers there doc.getLenght(), 1, i've been changing around but always same issue. The problem is the indentation works perfectly but when i have setParagraph on the first line of text is slightly thicker than the indented lines on multi line tells or a single line if one line is thicker. This is more noticeable in some fonts than others. I don't get why this is so. Its subtle but noticeable. the first line is about the same size, but a bit thicker and brighter.

Any ideas? full code of this method below.

void processLink(StyledDocument doc, String thetell, Color col, int index, int attempt, int game, SimpleAttributeSet attrs)
{

try{
	if(game == GAME_CONSOLES && sharedVariables.boardConsoleType == 0)// they hid game console
{	game=SUBFRAME_CONSOLES;
	doc = sharedVariables.mydocs[0];
}// end if
}catch(Exception cant){}


try {

if(attrs == null)
	attrs = new SimpleAttributeSet();
SimpleAttributeSet  style = new SimpleAttributeSet();// = doc.addStyle(null, null);
StyleConstants.setLeftIndent(style, 12);
StyleConstants.setFirstLineIndent(style, -12);


StyleConstants.setForeground(attrs, col);


parseString mine = new parseString();
mine.parse(thetell);


//Style styleQ = doc.addStyle(null, null);

//StyleConstants.setForeground(styleQ, col );



if(mine.itsLink == 0)
{
//	doc.setParagraphAttributes(doc.getLength()+5000, 1, style, false);

doc.insertString(doc.getEndPosition().getOffset(), thetell, attrs);

}
else
{
if(mine.text1.length() !=0)
{
if(attempt == 1)
{
	doc.insertString(doc.getEndPosition().getOffset(), mine.text1, attrs);
//	doc.setParagraphAttributes(doc.getLength(), 1, style, false);

}
else
processLink(doc, mine.text1, col, index, attempt -1 , game, attrs);
}
StyleConstants.setUnderline(attrs, true);
//attrs.addAttribute(ID, new Integer(++linkID));
attrs.addAttribute(javax.swing.text.html.HTML.Attribute.HREF, mine.text2);

doc.insertString(doc.getEndPosition().getOffset(), mine.text2, attrs);
//	doc.setParagraphAttributes(doc.getLength(), 1, style, false);

StyleConstants.setUnderline(attrs, false);

if(mine.text3.length() !=0)
{


if(attempt == 1)
{
	doc.insertString(doc.getEndPosition().getOffset(), mine.text3, attrs);
//	doc.setParagraphAttributes(doc.getLength(), 1, style, false);

}
else
processLink(doc, mine.text3, col, index, attempt -1,  game, attrs);


}




}// end else
if(attempt == maxLinks && game == 0)
writeToConsole(doc, index);
else if(attempt == maxLinks && game == 1)
writeToGameConsole(doc, index);

}  // end try
catch(Exception e){}


}

any update on this? I can't release with hanging indentation on if the on paint call is messed up on the first line. A tester reported it, tells me he got used to it but comeon.

Mike

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.