Best way to alter Icon color/brightness

Hello everyone,
I would like to know what's the best/easiest way to alter the color and brightness of an Icon IE in a JLabel.
I wish to do something like this:
In a panel:
JLabel picture = null;
picture = new JLabel(new Icon(new BufferedImage(...));
picture.setText("");
add(picture);and then have two methods (IE: picture.shade() and picture.unshade()) to darken and brighten the icon in the JLabel at will, to simulate "active" and "not active" statuses.
Thank you in advance!
Fabio.

FabioFranchello wrote:
JLabel picture = null;
picture = new JLabel(new Icon(new BufferedImage(...));
You can't create an instance of Icon since it's an interface, you should create an ImageIcon:
JLabel picture = new JLabel(new ImageIcon(new BufferedImage(...));
picture.setText("");This is unnecessary - picture text is already the empty string.
and then have two methods (IE: picture.shade() and picture.unshade()) to darken and brighten the icon in the JLabel at will, to simulate "active" and "not active" statuses.You will need to change the brightness of the image: [http://java.sun.com/developer/JDCTechTips/2004/tt0210.html]

Similar Messages

  • What is the best way to specify the color of a control or indicator?

    What is the best way to command the color of a control or indicator? 
    Can color be programmed within the code?  If so, which versions of LV have this feature?
    Thanks,
    Jeff
    Jeffrey Bledsoe
    Electrical Engineer

    You can change the color of controls and indicators by using the 'color' parameter in a property node.  I believe this has always been possible in LabVIEW.  (At least back to Ver. 4)
    Here is a little example (LV7.1):
    Using LabVIEW: 7.1.1, 8.5.1 & 2013
    Attachments:
    control colors.vi ‏21 KB

  • Flex Hero - Proper way to alter style/color

    Surely there is an easy way to alter the color of the View...or specifically the Header/ActionBar at the top.
    For example, like I see on this site:
    http://thoughtfaqtory.com/blog/2010/11/10/adobe-flex-mobile-overview-part-1/
    I'd like to be able to alter the background colors to something other then the default black.  Must I create a new skin for this?
    Darren

    I tried setting that in the "design" editor and didn't see any change...so I never thought of trying that.
    Setting it directly in the mxml code on the MobileApplication object made the change.
    Thanks,
    Darren

  • Best way for: OutlineView + icon (for items)

    Hi,
    I have extensively searched, in the cocoa documentation a way to create a display a hierarchical collection of items, each having a corresponding icon.
    Bottom line, the best way of representing it is what mail does with your mailboxes and folders, or what the finder does with the folder tree of the drives.
    One "reasonable solution" I have tried is, through the delegate, returning always the same instance of NSBrowserCell.
    // In my outlineViewDelegate
    - (NSCell *)outlineView:(NSOutlineView *)outlineView dataCellForTableColumn:(NSTableColumn *)tableColumn item:(id)item
    if (tableColumn == nil)
    return thecell; // Assume it is an instance of NSBrowserCell initialized in the init methode of my NSOutlineViewDelegate
    else
    // there is no else. It won't be called. It never has been since I began experementing with it.
    [throw exception]; // assume this works
    Then, I change the icon of the cell as required
    // In my outlineViewDelegate
    - (void)outlineView:(NSOutlineView *)outlineView willDisplayCell:(id)cell
    forTableColumn:(NSTableColumn *)tableColumn item:(id)item
    NSImage* icon = [find appropriateIconForItem:item]; // assume it works
    [(NSBrowserCell*)cell setImage:icon];
    Everything works, but I am not satisfied with the display.
    1. When a row is selected, the color effect of the selection breaks at the cell boundaries. NSBrowserCell does not show represent the selection the same way that the outline view does.
    2. Spacing between items (vertically) is not good.
    3. If I change it, (by means of the delegate) I loose the settings NSSmallControlSize that I did define at the beginning.
    I have been messing around with the settings without managing to have something as nice as mail.app or the finder.
    I am also willing to try other approach, but I ma not fond of subclassing madly everything, especially if it results in a loss of functionalities (e.g. loosing the editability of the text, or having it edit with a shift in position)
    I post this message because I imagine there is an elegant way of doing it. It is a common functionality after all, used in many native MACOS app (finder, mail, itunes, ...) So it should come for free, right ?
    Anyway, any working fast solution, (my app may have to display very heavy collections, is more than welcome.
    Thanks for reading me.

    Any idea anyone ?

  • What is the best way to lay out color-coded Excel data in InDesign?

    I’ve been away from layout for some time. I now need to lay out color-coded Excel data (3 columns, 200 rows) in InDesign 5.5. The data will need to be in alpha order and each row will be color coded, with a color key at the top of the page. What is the best way to lay this out? Should I use the table tool and create a new style for each color that I need to use?
    Thanks for your help.

    I think this will work in CS3.
    Start off by inserting Styles of WEEK, Mon to Friday (as per left)
    Set the Week No. to Bullets and Numbering and insert as per screen shot
    Do the same for Days Monday through to Sunday
    Also set up Monday style NEXT STYLE to be Tuesday
    When you get to Sunday - loop the Styles back to WEEK style.
    Then as per first screen shot you just have to insert RETURNS all the way down to initiate the style.

  • What would be the best way to change the color of part of this image? (image attached)

    I am on XP using PS CS4.
    Please see the photograph below. I would like to change the color of the shirt/apron of this lady & I was wondering what the best way is to do that. I know if I try replace color, the white bowls change color as well. In the past I have isolated parts of images using paths, but I wanted to know if that was the most efficient way. Maybe masking is the answer. I just wanted to hear from the pros
    Thank you.

    You're welcome!
    Refine Edge button is in the options bar when the QST is active.
    Refine Mask should be available whenever a mask is targeted.

  • What is the best way to upload icons I created on illustrator, onto a photoshop file of a website design?

    I currently in the process of designing a website on Photoshop. I have designed some icons for the website using Illustrator. What is the best way to upload these icons onto the photoshop file and keep them looking crisp and high quality? I have tried a number of ways but all seem to come out pixilated.

    What you need to do is make sure you are creating the Illustrator icons at the same ppi as the Photoshop document and at the correct size. If you have created the icons say with 300ppi but are in pixels it won't carry the same properties as the website you are creating if that has been set up as 72ppi and therefore will distort.
    Once you have mastered that then you are best (if you think there may be changes to the icons later down the line) to create .ai files of each icon and place them intt the Photoshop document, then if you make any changes to the source .ai file it will update within you website design.
    If you don't see the icons changing then you can always just copy and paste directly from Illustrator to Photoshop and make any changes on the fly by making sure you keep it as a smart object.

  • Simplist/best way to replace a color with another color?

    I have a series of footage taken at a photography studio where we used purple coloured gels behind 1k fresnels to create spots of purple on the floor and to light the subjects. Floor and background are black.
    There are a few clips where I want to change the purple to another colour (in this case blue), what is the best way to do this? Basically I want to change anything purple to blue, but the purple does have somewhat of a gradient, basically the more purple saturated colours need to become blue.
    What's the best way to go about doing this?

    Take it to Color and use a secondary to make a color selection. You might be able in secondaries to use a hue range selection and change that. Without seeing the images it's difficult to tell. It depends specifically on the colors of the subjects. The problem in your case you're not actually changing a color in the image, but objects that are reflecting the color from gelled lights, and they might not all reflect it in the same way and produce the same colors.

  • Any way to alter one color in a PDF?

    I have some files that are 2/c black and magenta. I was told that the final pdfs could not be created with PMS color and so the 2nd color work (everything that was magenta) is implemented at the printer. And now there is no way of changing the color in the PDF's. They said that they used a generic color because they hadn't determined the 2nd color when typesetting was underway.
    Is there absolutely no way, or just no easy way. There is text as well as raster elements.

    Do you mean pitstop for editing the file or the output? I just want to edit the file so I can put it on the web for preview. Otherwise we get emails and calls asking if its really pink :) I'm not printing. They handle all that stuff, I'm just marketing.

  • What is the best way to get the pixel brightness

    I have a gray-scale .png image. The pixel brightness is used to communicate the information that i need in my application. Note that i do not show this image in my application, the png file is only used to communicate data. Since this data is being collected as an image at the source we are using a png file to pass around this data. The code is given below
    JarEntry entry = m_jarFile.getJarEntry("imageFile.png");
    InputStream stream = m_jarFile.getInputStream(entry);
    BufferedImage image =  ImageIO.read(overlayImageFileStream);
    int cols = overlayImage.getWidth();
    int rows = overlayImage.getHeight();
    short[][] m_pixelBrightnessValues = new short[cols][rows];
    for (int i=0; i<cols; i++) {
         for (int j=0; j<rows; j++) {
              /** BEGIN: Takes too much time */
              int rgb = overlayImage.getRGB(i, j);
              // convert to HSB values.
              int red = (rgb>>16)&0xFF;
              int green = (rgb>>8)&0xFF;
              int blue = rgb&0xFF;
              float[] inputHSB = new float[3];
              inputHSB = Color.RGBtoHSB(red, green, blue, inputHSB);
              /** END: Takes too much time */
              float brightness = inputHSB[2];
              m_pixelBrightnessValues[i][j]= (short)Math.round(brightness * MAX_BRIGHTNESS_VALUE);
    }Some portion of the code above takes too much time. I have been tinkering with the following approaches:
    1). I can parse the png file myself and extract the brightness information thus bypassing the creation of the BufferedImage altogether.
    2). I can continue to create BufferedImage but find out a way to grab brightness directly from the buffered image.
    I prefer option 2, since option 1 will require that I figure out png format and then write custom png parsing logic. I have explored all the methods of BufferedImage and it seems there is no way of getting the HSB directly, the only thing readily availabe is RGB values.
    I would really appreciate any pointers (e.g. is there something in the Raster that can let me access the brightness data directly ?)
    -kashif

    I have a gray-scale .png image. The pixel brightness
    is used to communicate the information that i need in
    my application. Note that i do not show this image in
    my application, the png file is only used to
    communicate data. Since this data is being collected
    as an image at the source we are using a png file to
    pass around this data. The code is given below<snip>
    >
    Some portion of the code above takes too much time. I
    have been tinkering with the following approaches:
    1). I can parse the png file myself and extract the
    brightness information thus bypassing the creation of
    the BufferedImage altogether.
    2). I can continue to create BufferedImage but find
    out a way to grab brightness directly from the
    buffered image.
    I prefer option 2, since option 1 will require that I
    figure out png format and then write custom png
    parsing logic. I have explored all the methods of
    BufferedImage and it seems there is no way of getting
    the HSB directly, the only thing readily availabe is
    RGB values.
    I would really appreciate any pointers (e.g. is there
    something in the Raster that can let me access the
    brightness data directly ?)For a greyscale image, the R G abd B values are all the same, and the brightess is simply that value divided by the maximum value. You could create a brightness map in advance which is simply a 256 element array that maps an RGB value to a brightness:
            short[] brightnessMap = new short[256];
            for (int i = 0; i < 256; i++) {
                brightnessMap[i] = (short)(i/255.0f * MAX_BRIGHTNESS_VALUE);
            }Various experiments I performed using PixelGrabber, Raster and such didn't seem to speed things up more than 25% on a 1280 x 1024 image. Times went from around 400 milliseconds to 300.

  • Best way to remove the color blue from this?

    Trying RGB Curves and Three-Way Color Corrector, but I can't seem to remove the color blue from the cutting tool in the screenshot.
    In photoshop, I could use hue / saturation and adjust only the blues, is that an option in Premiere?

    I've had good luck with Change Color in Premiere Pro, as mention above:
    Go to the Effects Pane > Video Effects > Color Correction > Change Color and apply the Change Color effect to your clip.
    Use the eyedropper to select the color in the shot you want to modify, using Tolerance and Softness to help select the color.
    Then modify the color using the transform settings.
    MtD

  • What is the best way to change to color of the first word in a paragraph?

    I have a lot of paragraphs where I want the first word to keep the same font, size, type - but I want to change just the color of the lettering.

    p:first-child em {} is overqualifying that selector, I think. First, you do not need the :first-child pseudo element to target that first paragraph, since you already have that <em> tag surrounding that word. What's the point of adding in useless specificity? Second, it overcomplicates and bloats the code.
    I also feel <em> is the wrong tag to apply, depending on whether or not you would pronounce that word differently from the rest of the text. The use of em implies that. If it's merely used for styling, a <span> tag would fit better.
    So I would go with mytax's code. Simple, and efficient.
    Would be handy though if CSS had a :first-word pseudo element :-).
    In the meantime while we wait for improvements, if you DO need complete typographic control, try lettering.js (jquery plugin):
    http://letteringjs.com/
    Like this:
    <p class="word_split">Don't break my heart.</p>
    <script>
    $(document).ready(function() {
      $(".word_split").lettering('words');
    </script>
    And then:
    .word1 {} in your css would target "Don't"
    .word2 {} in your css would target "break"

  • Best way to make small icons anywhere in the screen.

    Hi,
    I'm trying to make for my application sort of like a panel where the user will have in the background a JPG image that will be a map and on top of that I need to have smaller images or icons that will be nodes of a network and those nodes will have to attributes that will determine the position in the screen to fit the map underneath.
    Also every node will have to be able to be clicked to open another window that will contain data from that node.
    I'm new to Java and I don't know which is the best way to do that in Java. Can someone point me to the right direction?
    I thought of using Icons or maybe buttons with the node image on top. But I'm not sure if that is the best approach.
    Thank you.

    Here's a pretty crude example of how to do what you want to do.
    import java.awt.Color;
    import java.awt.Dimension;
    import java.awt.Graphics;
    import java.awt.Graphics2D;
    import java.awt.Image;
    import java.awt.Point;
    import java.awt.Rectangle;
    import java.awt.event.MouseEvent;
    import java.awt.event.MouseListener;
    import java.util.ArrayList;
    import java.util.Iterator;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    public class SampleMap {
         public SampleMap() {
              ArrayList<MapNode> mapNodes = new ArrayList<MapNode>();
              mapNodes.add(new MapNode(100, 100, "Node 1"));
              mapNodes.add(new MapNode(250, 250, "Node 2"));
              JFrame frame = new JFrame();
              frame.setTitle("Map Example");
              frame.add(new ImageMap(mapNodes));
              frame.pack();
              frame.setVisible(true);
         public static void main(String[] args) {
              new SampleMap();
         private class ImageMap extends JPanel{
              private static final long serialVersionUID = 7819553397548728320L;
              private ArrayList<MapNode> nodes;
              public ImageMap(ArrayList<MapNode> mapNodes){
                   nodes = mapNodes;
                   setMinimumSize(new Dimension(800, 600));
                   setPreferredSize(new Dimension(800, 600));
                   addMouseListener(new MouseListener() {
                        public void mousePressed(MouseEvent arg0) {
                             Rectangle rect = new Rectangle(arg0.getX() - 10, arg0.getY()-10, 10, 10);
                             Iterator<MapNode> iter = nodes.iterator();
                             while(iter.hasNext()) {
                                  MapNode curNode = iter.next();
                                  Point curPoint = new Point(curNode.getXPos(), curNode.getYPos());
                                  if(rect.contains(curPoint)){
    //TODO launch new JFrame with curNodes details
                                       System.err.println("Clicked on: " + curNode.getTitle());
                                       break;
                        public void mouseReleased(MouseEvent arg0) {     
                        public void mouseExited(MouseEvent arg0) {     
                        public void mouseEntered(MouseEvent arg0) {     
                        public void mouseClicked(MouseEvent arg0) {     
              public void paint(Graphics g) {
                   Graphics2D g2 = (Graphics2D)g;
      //TODO replace rectangle with a background image
                   g2.setColor(Color.WHITE);
                   g2.fillRect(0, 0, 800, 600);
                   Iterator<MapNode> iter = nodes.iterator();
                   while(iter.hasNext()) {
                        MapNode curNode = iter.next();
                        g2.setColor(Color.RED);
                        Image tmp = createImage(10, 10);
                        Graphics tmpG = tmp.getGraphics();
                        paintComponent(tmpG);
                        g2.drawImage(tmp, curNode.getXPos(),curNode.getYPos(), this);
                   repaint();
         private class MapNode {
              private static final long serialVersionUID = 7819553397548728321L;
              private int xPos;
              private  int yPos;
              private String title;
              public MapNode(int x, int y, String name) {
                   title = name;
                   xPos = x;
                   yPos = y;
              public int getYPos(){
                   return yPos;
              public int getXPos() {
                   return xPos;
              public String getTitle() {
                   return title;
    }

  • Best way to go from Final Cut to DVD preserving Color Corrections

    What is the best way to take my video project from Final Cut and burn it on a DVD (using DVD Studio), I need to preserve the color corrections I have made (used an external video monitor)? Also my camera shoots at black level IRE 0 and I have edited it that way, but as we all know NTSC TVs use IRE 7.5 is there anyway DVD Studio or FCP can convert the IRE so it matches?

    from FC; export to compressor
    In compressor, choose appropriate preset (i.e. best quality, >90 minutes, 16x9)
    encode the sound as dolby 2 (if you choose "all" you'll get an extra aif file)
    take the 2 files (video and audio) into dvd studio to encode.
    Not sure about your IRE 7.5 question, I always assumed it was automatically converted but now you have me thinking...

  • Have a picture scanned from a negative, the whole picture is off-color. Whats the best way to fix it

    I scanned an old negative and the resulting picture is off-color (as was the negative). What are the best ways to correct this?

    Trevor - Here it is.

Maybe you are looking for