Foreground Color using Swing
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Anonymous
Posted On:   Tuesday, January 1, 2002 11:52 PM

I am mkaing use of JColorChoose in my application..Using Swing Components(JTextComponent) The problem is that whenever iam trying to fire the action the WHOLE text is being painted.. I want only the selected Text to get painted and Not the Whole Text Here is the piece of code iam using class FontColorAction extends AbstractAction { public FontColorAction(){ super(fontAction); } public void actionPerformed(ActionEvent e){ AttributeSet as = textpane.getCharacterAttributes(); SimpleAttributeSet sas = new SimpleAttributeSet(as); Color newColor = JColorChooser.showDialog(Stylepad.this, "Choose Text Col   More>>


I am mkaing use of JColorChoose in my application..Using Swing Components(JTextComponent)
The problem is that whenever iam trying to fire the action the WHOLE text is being painted..
I want only the selected Text to get painted and Not the Whole Text


Here is the piece of code iam using


class FontColorAction extends AbstractAction {

public FontColorAction(){

super(fontAction);

}

public void actionPerformed(ActionEvent e){


AttributeSet as = textpane.getCharacterAttributes();

SimpleAttributeSet sas = new SimpleAttributeSet(as);

Color newColor = JColorChooser.showDialog(Stylepad.this, "Choose Text Color", doc.getForeground(as));

if(newColor!=null){

StyleConstants.setForeground(sas,newColor);

textpane.setCharacterAttributes(as,true);

textpane.setForeground(newColor);

//textpane.setSelectedTextColor(newColor);

}

Stylepad.this.repaint();

}

}



Thanks in advance

Mohan

   <<Less
About | Sitemap | Contact