I have used JLayer to decorate GUI the background color will be changed every second. here is the image.
In this image you could see the blue and yellow line appearing in the timer. I realized that these line are appearing because the text is changing in the text area similar thing happens when new expression is displayed in the text area.
How these lines could be removed?
class MyLayerUISubclass extends LayerUI<JComponent>{
/**
*
*/
private static final long serialVersionUID = 1L;
public void paint(Graphics g, JComponent c){
super.paint(g, c);
Graphics2D g2 = (Graphics2D) g.create();
int red = (int) (Math.random()*255);
int green = (int) (Math.random()*255);
int blue = (int) (Math.random()*255);
Color startColor = new Color(red, green, blue);
red = (int) (Math.random()*255);
green = (int) (Math.random()*255);
blue = (int) (Math.random()*255);
Color endColor = new Color(red, green, blue);
int w = c.getWidth();
int h = c.getHeight();
g2.setComposite(AlphaComposite.getInstance(
AlphaComposite.SRC_OVER, .5f));
g2.setPaint(new GradientPaint(0, 0, startColor, 0, h, endColor));
g2.fillRect(0, 0, w, h);
g2.dispose();
}
}
thanks in advance!
Instead of using JTextField I used JLabel as suggested by trashgod .