/** * 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(); }
/** * Returns whether or not the specified object is equivalent to * this one. * * @param o2 The object to which to compare. * @return Whether <code>o2</code> is another * <code>ColorBackgroundPainterStrategy</code> representing * the same color as this one. */ @Override public boolean equals(Object o2) { return o2!=null && (o2 instanceof ColorBackgroundPainterStrategy) && this.color.equals( ((ColorBackgroundPainterStrategy)o2).getColor()); }
/** * Constructor. * * @param color The color to use when painting the background. */ public ColorBackgroundPainterStrategy(Color color) { setColor(color); }
/** * Constructor. * * @param color The color to use when painting the background. */ public ColorBackgroundPainterStrategy(Color color) { setColor(color); }
/** * 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(); }
/** * Returns the <code>Object</code> representing the background for all * documents in this tabbed pane; either a <code>java.awt.Color</code> or a * <code>java.lang.Image</code> containing the image used as the background * for this text area. * * @return The <code>Object</code> used for the background. * @see #setBackgroundObject(Object newBackground) */ public final Object getBackgroundObject() { if (backgroundPainter==null) { return null; } return (backgroundPainter instanceof ImageBackgroundPainterStrategy) ? (Object)((ImageBackgroundPainterStrategy)backgroundPainter). getMasterImage() : (Object)((ColorBackgroundPainterStrategy)backgroundPainter). getColor(); }
/** * Constructor. * * @param color The color to use when painting the background. */ public ColorBackgroundPainterStrategy(Color color) { setColor(color); }
/** * 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(); }
/** * Returns whether or not the specified object is equivalent to * this one. * * @param o2 The object to which to compare. * @return Whether <code>o2</code> is another * <code>ColorBackgroundPainterStrategy</code> representing * the same color as this one. */ public boolean equals(Object o2) { return o2!=null && (o2 instanceof ColorBackgroundPainterStrategy) && this.color.equals( ((ColorBackgroundPainterStrategy)o2).getColor()); }
/** * Constructor. * * @param color The color to use when painting the background. */ public ColorBackgroundPainterStrategy(Color color) { setColor(color); }
/** * 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(); }
/** * Returns whether or not the specified object is equivalent to * this one. * * @param o2 The object to which to compare. * @return Whether <code>o2</code> is another * <code>ColorBackgroundPainterStrategy</code> representing * the same color as this one. */ @Override public boolean equals(Object o2) { return o2!=null && (o2 instanceof ColorBackgroundPainterStrategy) && this.color.equals( ((ColorBackgroundPainterStrategy)o2).getColor()); }
/** * Returns whether or not the specified object is equivalent to * this one. * * @param o2 The object to which to compare. * @return Whether <code>o2</code> is another * <code>ColorBackgroundPainterStrategy</code> representing * the same color as this one. */ public boolean equals(Object o2) { return o2!=null && (o2 instanceof ColorBackgroundPainterStrategy) && this.color.equals( ((ColorBackgroundPainterStrategy)o2).getColor()); }
/** * Returns the <code>Object</code> representing the background for all * documents in this tabbed pane; either a <code>java.awt.Color</code> or a * <code>java.lang.Image</code> containing the image used as the background * for this text area. * * @return The <code>Object</code> used for the background. * @see #setBackgroundObject(Object newBackground) */ public final Object getBackgroundObject() { if (backgroundPainter==null) return null; return (backgroundPainter instanceof ImageBackgroundPainterStrategy) ? (Object)((ImageBackgroundPainterStrategy)backgroundPainter). getMasterImage() : (Object)((ColorBackgroundPainterStrategy)backgroundPainter). getColor(); }
/** * Returns the <code>Object</code> representing the background for all * documents in this tabbed pane; either a <code>java.awt.Color</code> or a * <code>java.lang.Image</code> containing the image used as the background * for this text area. * * @return The <code>Object</code> used for the background. * @see #setBackgroundObject(Object newBackground) */ public final Object getBackgroundObject() { if (backgroundPainter==null) { return null; } return (backgroundPainter instanceof ImageBackgroundPainterStrategy) ? (Object)((ImageBackgroundPainterStrategy)backgroundPainter). getMasterImage() : (Object)((ColorBackgroundPainterStrategy)backgroundPainter). getColor(); }
/** * Returns the <code>Object</code> representing the background for all * documents in this tabbed pane; either a <code>java.awt.Color</code> or a * <code>java.lang.Image</code> containing the image used as the background * for this text area. * * @return The <code>Object</code> used for the background. * @see #setBackgroundObject(Object newBackground) */ public final Object getBackgroundObject() { if (backgroundPainter==null) return null; return (backgroundPainter instanceof ImageBackgroundPainterStrategy) ? (Object)((ImageBackgroundPainterStrategy)backgroundPainter). getMasterImage() : (Object)((ColorBackgroundPainterStrategy)backgroundPainter). getColor(); }