/** * Sets the background color of this text editor. Note that this is * equivalent to calling <code>setBackgroundObject(bg)</code>.<p> * * NOTE: the opaque property is set to <code>true</code> when the * background is set to a color with 1.0 alpha (by this method). When an * image is used for the background, opaque is set to false. This is * because we perform better when setOpaque is true, but if we use an * image for the background when opaque is true, we get on-screen * garbage when the user scrolls via the arrow keys. Thus we * need setOpaque to be false in that case.<p> * You never have to change the opaque property yourself; it is always done * for you. * * @param bg The color to use as the background color. */ @Override public void setBackground(Color bg) { Object oldBG = getBackgroundObject(); if (oldBG instanceof Color) { // Just change color of strategy. ((ColorBackgroundPainterStrategy)backgroundPainter). setColor(bg); } else { // Was an image painter... backgroundPainter = new ColorBackgroundPainterStrategy(bg); } setOpaque(bg==null || bg.getAlpha()==0xff); firePropertyChange("background", oldBG, bg); repaint(); }
/** * Sets the background color of this text editor. Note that this is * equivalent to calling <code>setBackgroundObject(bg)</code>.<p> * * NOTE: the opaque property is set to <code>true</code> when the * background is set to a color with 1.0 alpha (by this method). When an * image is used for the background, opaque is set to false. This is * because we perform better when setOpaque is true, but if we use an * image for the background when opaque is true, we get on-screen * garbage when the user scrolls via the arrow keys. Thus we * need setOpaque to be false in that case.<p> * You never have to change the opaque property yourself; it is always done * for you. * * @param bg The color to use as the background color. */ @Override public void setBackground(Color bg) { Object oldBG = getBackgroundObject(); if (oldBG instanceof Color) { // Just change color of strategy. ((ColorBackgroundPainterStrategy)backgroundPainter). setColor(bg); } else { // Was an image painter... backgroundPainter = new ColorBackgroundPainterStrategy(bg); } setOpaque(bg==null || bg.getAlpha()==0xff); firePropertyChange("background", oldBG, bg); repaint(); }
/** * Sets the background color of this text editor. Note that this is * equivalent to calling <code>setBackgroundObject(bg)</code>. * * NOTE: the opaque property is set to <code>true</code> when the * background is set to a color (by this method). When an image is used * for the background, opaque is set to false. This is because * we perform better when setOpaque is true, but if we use an * image for the background when opaque is true, we get on-screen * garbage when the user scrolls via the arrow keys. Thus we * need setOpaque to be false in that case.<p> * You never have to change the opaque property yourself; it is always done * for you. * * @param bg The color to use as the background color. */ public void setBackground(Color bg) { Object oldBG = getBackgroundObject(); if (oldBG instanceof Color) { // Just change color of strategy. ((ColorBackgroundPainterStrategy)backgroundPainter). setColor(bg); } else { // Was an image painter... backgroundPainter = new ColorBackgroundPainterStrategy(bg); } setOpaque(true); firePropertyChange("background", oldBG, bg); repaint(); }
/** * Sets the background color of this text editor. Note that this is * equivalent to calling <code>setBackgroundObject(bg)</code>. * * NOTE: the opaque property is set to <code>true</code> when the * background is set to a color (by this method). When an image is used * for the background, opaque is set to false. This is because * we perform better when setOpaque is true, but if we use an * image for the background when opaque is true, we get on-screen * garbage when the user scrolls via the arrow keys. Thus we * need setOpaque to be false in that case.<p> * You never have to change the opaque property yourself; it is always done * for you. * * @param bg The color to use as the background color. */ public void setBackground(Color bg) { Object oldBG = getBackgroundObject(); if (oldBG instanceof Color) { // Just change color of strategy. ((ColorBackgroundPainterStrategy)backgroundPainter). setColor(bg); } else { // Was an image painter... backgroundPainter = new ColorBackgroundPainterStrategy(bg); } setOpaque(true); firePropertyChange("background", oldBG, bg); repaint(); }