Custom Icon in JLabel - center?

I have a custom Icon that I am placing in a JLabel, but I can't get it to be centered!
I can put an ImageIcon in the JLabel, and it will be centered, but my custom Icon doesn't seem to follow the setVerticalAlignment/setHorizontalAlignment properties.
I am using java 1.3.1.
Any suggestions?

The first thing I would do is check the frame of the custom icon to see if it is bigger than the picture...that could be the problem.

Similar Messages

  • Draw image icon on JLabel

    Does anyone know how I can paint an icon on an already existing JLabel image without having the original image disappear partially or completely?
    The way I have it set up right now is that the original image listens to MouseListener, and displays information on a textArea when I click on the map.
    What I wish to do is to display an icon on the map image whenever I click on it.
    I'm a rather amateur with Java, and don't know how to make interfaces interact with eachother, no matter how hard I try. I need to know if I can add something to my current code to get what I want. I have had tried to interact different classes with eachother, but I haven't been getting what I wanted. Please help me out!
    I know how to display the icon on another panel, and make it move. but not on the same panel on the original picture.
    Here's my code:
    package screem.netrol.communication.event;
    * @author Nazli
    import java.awt.*;
    import java.awt.image.*;
    import java.awt.Component;
    import java.awt.Image;
    import java.awt.Color;
    import javax.swing.*;
    import javax.swing.ImageIcon;
    import java.net.*; // For class URL.
    import java.awt.event.MouseListener;
    import java.awt.event.MouseEvent;
    import java.io.*;
    import java.util.*;
    import java.awt.event.*;
    import java.awt.geom.*;
    import javax.swing.border.TitledBorder;
    import javax.swing.event.MouseInputAdapter;
    import java.applet.*;
    public class MyMapPanel extends JPanel implements DataTurbineListener, MouseListener, ImageObserver
    final static String newline = "\n";
    JTextArea textArea; //= new JTextArea();
    public static String url;
    public static ImageIcon ic;
    public static ImageIcon ic2 = new ImageIcon("http://www-jkn.ee.uec.ac.jp/tnklab/96/nakazawa/icons/colorball/small/BALL120.gif");
    public static JLabel mapArea;
    //public static JApplet mapArea;
    //public static File output = new File("results.txt");
    public static boolean showPoint;
    public static int x;
    public static int y;
    private BufferedImage bufImg ;
    private Image smallImg ;
    int w;
    int h;
    /*public static BufferedImage bufImg ;
    public static Image smallImg ; */
    /* GeneralPath path;
    final int PAD = 20;
    final int N = 8; */
    public static MyJFrame f;
    public MyMapPanel() {}
    public MyMapPanel(ImageIcon ic)
    super(new FlowLayout (FlowLayout.CENTER, 0,0));
    textArea = new JTextArea();
    setImageIcon(ic);
    textArea.setEditable(false);
    JScrollPane scrollPane = new JScrollPane(textArea);
    add(scrollPane);
    scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    scrollPane.setPreferredSize(new Dimension(700,100));
    //getContentPane().add(new MyPanel(), BorderLayout.CENTER);
    //addMouseListener( new MusClk() ) ;
    protected class MusClk extends MouseAdapter {
    public void mouseClicked ( MouseEvent musEvt ) {
    if( musEvt.getX() > bufImg.getWidth() || musEvt.getY() > bufImg.getHeight() ) {
    return ;
    Graphics g = bufImg.getGraphics() ;
    int w = smallImg.getWidth( null ) ;
    int h = smallImg.getHeight( null ) ;
    g.drawImage( smallImg , musEvt.getX() - w / 2 , musEvt.getY() - h / 2 , null ) ;
    MyMapPanel.this.repaint( musEvt.getX() - w / 2 , musEvt.getY() - h / 2 , w , h ) ;
    public ImageIcon getImageIcon()
    setImageIcon(ic);
    return ic;
    public void setImageIcon(ImageIcon ic)
    //MyPanel panel = new MyPanel();
    try{
    URL u = new URL(url);
    ic = new ImageIcon(u);
    } catch (MalformedURLException e) {
    System.out.println (e);
    mapArea = new JLabel(ic, JLabel.CENTER);
    add(mapArea);
    mapArea.addMouseListener(this);
    try {
    URL u = new URL(url);
    ic = new ImageIcon(u);
    } catch (MalformedURLException e){
    System.out.println(e);
    mapArea = new JApplet();
    add(mapArea);
    mapArea.addMouseListener(this); */
    /* public void setMouseEvent(MouseEvent e)
    x = e.getX();
    y = e.getY();
    showPoint = true;
    protected void paintComponent(Graphics g){ }
    public void dataTurbineOutputEvent(DataTurbineEvent event){}
    public void dataTurbineInputEvent(DataTurbineEvent event){}
    public void mouseReleased(MouseEvent e){}
    public void mousePressed(MouseEvent e) { }
    public void mouseEntered(MouseEvent e) {}
    public void mouseExited(MouseEvent e) { }
    public void mouseClicked(MouseEvent e)
    //setMouseEvent(e);
    //System.out.println("x="+x+" y="+y);
    showPoint = true;
    ImageIcon icon = new ImageIcon("C:/Documents and Settings/Nazli/My Documents/My Pictures/ball.gif");
    w = icon.getIconWidth();
    h = icon.getIconHeight();
    bufImg = new BufferedImage(w , h , BufferedImage.TYPE_INT_RGB ) ;
    Graphics g = bufImg.getGraphics();
    g.drawImage( icon.getImage() , 0 , 0 , null ) ;
    //MyMapPanel.this.repaint(e.getX() - w / 2 , e.getY() - h / 2 , w , h ) ;
    /*Point p = e.getPoint();
    Rectangle tag;
    final int SIDE = 6;
    tag = new Rectangle(0, 0, SIDE, SIDE);
    float x = e.getX();
    float y = e.getY();
    tag.setLocation(p.x - SIDE/2, p.y - SIDE/2);
    if(tag.contains(p.x,y))
    showPoint = true;
    setPoint(p);
    //System.out.println("e.getX="+e.getX()+""+"e.getY="+e.getY());
    saySomething("Position in pixels:(" + e.getX() + ", " + e.getY() + ")", e);
    String s1 = computeLatLong(e.getX());
    String s2 = computeLatLong(e.getY());
    saySomething("Position in Lat/Long: (" + s1 + ", " + s2 + ")", e);
    //g.drawImage(img, e.getX(), e.getY(), this);
    //DrawImage d = new DrawImage();
    //public void mouseClicked ( MouseEvent musEvt ) {
    //DrawImage d = new DrawImage();
    void saySomething(String eventDescription, MouseEvent e)
    textArea.append(eventDescription + " detected on " + e.getComponent().getClass().getName() + "." + newline);
    textArea.setCaretPosition(textArea.getDocument().getLength());
    public String computeLatLong(double d)
    double d1;
    double seconds;
    double minutes;
    double m;
    double s;
    String rval;
    d1 = d - Math.floor(d);
    seconds = d1 / 3600;
    minutes = seconds / 60;
    m = minutes - Math.floor(minutes);
    s = m * 60; //minutes converted to seconds
    rval = (int)Math.floor(d) + "deg " + (int)minutes + "' " + (int)s + '"';
    return rval;
    public MyJFrame getFrame()
    return f;
    public static void main(String[] args) throws IOException {
    //DrawImage d = new DrawImage();
    System.out.println("x="+x+" y="+y);
    ArrayList file = new ArrayList();
    File input = new File("lat_lon.txt");
    FileReader in = new FileReader(input);
    File output = new File("archive3.txt");
    FileWriter out = new FileWriter(output);
    //FileWriter in2 = new FileWriter(input);
    FileOutputStream outdata = new FileOutputStream(output);
    PrintStream p = new PrintStream(outdata);
    BufferedReader br = new BufferedReader(in, 4096);
    BufferedWriter bw = new BufferedWriter(new FileWriter("lat_lon.txt", true));
    String line; //each line in input file
    String s=null; //Main string containing points information, to be written to the output file
    while ((line = br.readLine()) != null )
    file.add(line);
    StringTokenizer st = new StringTokenizer(line,";");
    while(st.hasMoreTokens())
    s = st.nextToken();
    p.println(s);
    p.println("FINISHED DATA TRANSFER");
    p.println("\n");
    bw.write("DATA TRANSFERRED TO OUTPUT FILE");
    bw.newLine();
    bw.flush();
    p.close();
    //pops up the input dialogue window for the user to enter the image URL
    url = JOptionPane.showInputDialog(null,"Provide image URL:\n","Map Image", JOptionPane.PLAIN_MESSAGE);
    MyMapPanel panel = new MyMapPanel();
    if(url != null)
    panel.setImageIcon(ic);
    MyMapPanel mp = new MyMapPanel(ic);
    MyPanel panel2 = new MyPanel();
    //MyMapPanel mp2 = new MyMapPanel();
    JFrame jf = new JFrame();
    f = new MyJFrame(700,400);
    f.getContentPane().add(mp);
    //f.getContentPane().add(panel2);
    public static class MyJFrame extends JFrame {
    // Constructor.
    public MyJFrame (int width, int height)
    // Set the title and other frame parameters.
    this.setTitle ("GPS Map");
    this.setResizable (true);
    this.setSize (width, height);
    // Create and add the panel.
    MyMapPanel panel = new MyMapPanel();
    //MyPanel p = new MyPanel();
    //this.getContentPane().add (panel);
    this.getContentPane().add(panel);
    // Show the frame.
    this.setVisible (true);
    }

    Hi,
    I'm sorry that I didn't use the buttons to make the code readable for you. and I'm sure you don't want to hear how hectic my mind has been for the past few weeks, so I'm not going to explain why I didn't pay attention to the formatting. Although, I think it could have been possible to address my mistake in a less aggressive manner.
    Here's my code in a better readable format. I appreciate your advice, it looks so much better now. I'd very much appreciate it if you can go over it.
    In regards to your previous solution, I have to say that I've tried it before, but it hasn't worked for me, possibly because I'm not sure how to use it.
    * @author Nazli
    import java.awt.*;
    import java.awt.image.*;
    import java.awt.Component;
    import java.awt.Image;
    import java.awt.Color;
    import javax.swing.*;
    import javax.swing.ImageIcon;
    import java.net.*; // For class URL.
    import java.awt.event.MouseListener;
    import java.awt.event.MouseEvent;
    import java.io.*;
    import java.util.*;
    import java.awt.event.*;
    import java.awt.geom.*;
    import javax.swing.border.TitledBorder;
    import javax.swing.event.MouseInputAdapter;
    import java.applet.*;
    public class MyMapPanel extends JPanel implements DataTurbineListener, MouseListener, ImageObserver
    final static String newline = "\n";
    JTextArea textArea; //= new JTextArea();
    public static String url;
    public static ImageIcon ic;
    public static ImageIcon ic2 = new ImageIcon("http://www-jkn.ee.uec.ac.jp/tnklab/96/nakazawa/icons/colorball/small /BALL120.gif");
    public static JLabel mapArea;
    //public static JApplet mapArea;
    //public static File output = new File("results.txt");
    public static boolean showPoint;
    public static int x;
    public static int y;
    private BufferedImage bufImg ;
    private Image smallImg ;
    int w;
    int h;
    /*public static BufferedImage bufImg ;
    public static Image smallImg ; */
    /* GeneralPath path;
    final int PAD = 20;
    final int N = 8; */
    public static MyJFrame f;
    public MyMapPanel() {}
    public MyMapPanel(ImageIcon ic)
    super(new FlowLayout (FlowLayout.CENTER, 0,0));
    textArea = new JTextArea();
    setImageIcon(ic);
    textArea.setEditable(false);
    JScrollPane scrollPane = new JScrollPane(textArea);
    add(scrollPane);
    scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    scrollPane.setPreferredSize(new Dimension(700,100));
    //getContentPane().add(new MyPanel(), BorderLayout.CENTER);
    //addMouseListener( new MusClk() ) ;
    protected class MusClk extends MouseAdapter {
    public void mouseClicked ( MouseEvent musEvt ) {
    if( musEvt.getX() > bufImg.getWidth() || musEvt.getY() > bufImg.getHeight() ) {
    return ;
    Graphics g = bufImg.getGraphics() ;
    int w = smallImg.getWidth( null ) ;
    int h = smallImg.getHeight( null ) ;
    g.drawImage( smallImg , musEvt.getX() - w / 2 , musEvt.getY() - h / 2 , null ) ;
    MyMapPanel.this.repaint( musEvt.getX() - w / 2 , musEvt.getY() - h / 2 , w , h ) ;
    public ImageIcon getImageIcon()
    setImageIcon(ic);
    return ic;
    public void setImageIcon(ImageIcon ic)
    //MyPanel panel = new MyPanel();
    try{
    URL u = new URL(url);
    ic = new ImageIcon(u);
    } catch (MalformedURLException e) {
    System.out.println (e);
    mapArea = new JLabel(ic, JLabel.CENTER);
    add(mapArea);
    mapArea.addMouseListener(this);
    try {
    URL u = new URL(url);
    ic = new ImageIcon(u);
    } catch (MalformedURLException e){
    System.out.println(e);
    mapArea = new JApplet();
    add(mapArea);
    mapArea.addMouseListener(this); */
    /* public void setMouseEvent(MouseEvent e)
    x = e.getX();
    y = e.getY();
    showPoint = true;
    protected void paintComponent(Graphics g){ }
    public void dataTurbineOutputEvent(DataTurbineEvent event){}
    public void dataTurbineInputEvent(DataTurbineEvent event){}
    public void mouseReleased(MouseEvent e){}
    public void mousePressed(MouseEvent e) { }
    public void mouseEntered(MouseEvent e) {}
    public void mouseExited(MouseEvent e) { }
    public void mouseClicked(MouseEvent e)
    //setMouseEvent(e);
    //System.out.println("x="+x+" y="+y);
    showPoint = true;
    ImageIcon icon = new ImageIcon("C:/Documents and Settings/Nazli/My Documents/My Pictures/ball.gif");
    w = icon.getIconWidth();
    h = icon.getIconHeight();
    bufImg = new BufferedImage(w , h , BufferedImage.TYPE_INT_RGB ) ;
    Graphics g = bufImg.getGraphics();
    g.drawImage( icon.getImage() , 0 , 0 , null ) ;
    //MyMapPanel.this.repaint(e.getX() - w / 2 , e.getY() - h / 2 , w , h ) ;
    /*Point p = e.getPoint();
    Rectangle tag;
    final int SIDE = 6;
    tag = new Rectangle(0, 0, SIDE, SIDE);
    float x = e.getX();
    float y = e.getY();
    tag.setLocation(p.x - SIDE/2, p.y - SIDE/2);
    if(tag.contains(p.x,y))
    showPoint = true;
    setPoint(p);
    //System.out.println("e.getX="+e.getX()+""+"e.getY="+e.getY());
    saySomething("Position in pixels:(" + e.getX() + ", " + e.getY() + ")", e);
    String s1 = computeLatLong(e.getX());
    String s2 = computeLatLong(e.getY());
    saySomething("Position in Lat/Long: (" + s1 + ", " + s2 + ")", e);
    //g.drawImage(img, e.getX(), e.getY(), this);
    //DrawImage d = new DrawImage();
    //public void mouseClicked ( MouseEvent musEvt ) {
    //DrawImage d = new DrawImage();
    void saySomething(String eventDescription, MouseEvent e)
    textArea.append(eventDescription + " detected on " + e.getComponent().getClass().getName() + "." + newline);
    textArea.setCaretPosition(textArea.getDocument().getLength());
    public String computeLatLong(double d)
    double d1;
    double seconds;
    double minutes;
    double m;
    double s;
    String rval;
    d1 = d - Math.floor(d);
    seconds = d1 / 3600;
    minutes = seconds / 60;
    m = minutes - Math.floor(minutes);
    s = m * 60; //minutes converted to seconds
    rval = (int)Math.floor(d) + "deg " + (int)minutes + "' " + (int)s + '"';
    return rval;
    public MyJFrame getFrame()
    return f;
    public static void main(String[] args) throws IOException {
    //DrawImage d = new DrawImage();
    System.out.println("x="+x+" y="+y);
    ArrayList file = new ArrayList();
    File input = new File("lat_lon.txt");
    FileReader in = new FileReader(input);
    File output = new File("archive3.txt");
    FileWriter out = new FileWriter(output);
    //FileWriter in2 = new FileWriter(input);
    FileOutputStream outdata = new FileOutputStream(output);
    PrintStream p = new PrintStream(outdata);
    BufferedReader br = new BufferedReader(in, 4096);
    BufferedWriter bw = new BufferedWriter(new FileWriter("lat_lon.txt", true));
    String line; //each line in input file
    String s=null; //Main string containing points information, to be written to the output file
    while ((line = br.readLine()) != null )
    file.add(line);
    StringTokenizer st = new StringTokenizer(line,";");
    while(st.hasMoreTokens())
    s = st.nextToken();
    p.println(s);
    p.println("FINISHED DATA TRANSFER");
    p.println("\n");
    bw.write("DATA TRANSFERRED TO OUTPUT FILE");
    bw.newLine();
    bw.flush();
    p.close();
    //pops up the input dialogue window for the user to enter the image URL
    url = JOptionPane.showInputDialog(null,"Provide image URL:\n","Map Image", JOptionPane.PLAIN_MESSAGE);
    MyMapPanel panel = new MyMapPanel();
    if(url != null)
    panel.setImageIcon(ic);
    MyMapPanel mp = new MyMapPanel(ic);
    MyPanel panel2 = new MyPanel();
    //MyMapPanel mp2 = new MyMapPanel();
    JFrame jf = new JFrame();
    f = new MyJFrame(700,400);
    f.getContentPane().add(mp);
    //f.getContentPane().add(panel2);
    public static class MyJFrame extends JFrame {
    // Constructor.
    public MyJFrame (int width, int height)
    // Set the title and other frame parameters.
    this.setTitle ("GPS Map");
    this.setResizable (true);
    this.setSize (width, height);
    // Create and add the panel.
    MyMapPanel panel = new MyMapPanel();
    //MyPanel p = new MyPanel();
    //this.getContentPane().add (panel);
    this.getContentPane().add(panel);
    // Show the frame.
    this.setVisible (true);
    }

  • Custom icons 'unclickable' in icon view & not shown in coverflow

    Hi,
    I just got off the line with Apple support, who couldn't solve my problem and then just told me that Leopard didn't support what I was doeing and thus that it was not there problem. Very un-apple if you ask me...
    Here's the problem:
    I create custom icons for my movies by pasting images (Jpeg's or what have you) onto the icon in the 'Get info' window of a file. This works fine, however when I view the files in icon view I can't select the file by clicking on the icon, only by clicking on the text below. Strangly enough this problem dissapears when I edit the icon size in the 'View options' to a size equal too or smaller then 116x116. At this point I can select the file without any problem.
    The same sort of happens in coverflow. Here I can't see the icon in coverflow if the icons are fairly large. Once I reduce the size of the coverflow bar too the point where the icons are very small the custom icons reappear.
    The make the matter even more strange this problem only occurs with files where I created a custom icon for since I had Leopard installed. All custon icons created under 10.4 work fine.
    This indicates too me that Leopard has problem with handeling the resolution of icons.
    Note also that Leopard stores icon images in different sizes. Try copying an icon image from the 'Get info' window, then launch Preview, then select 'File' and 'New from Clipboard'. You will see that there are multiple images here.
    Anybody know how to solve this?

    Getting the same stupid behavior here!
    I had a lot of customized Tiger folder icons but now i've got no good tools for customizing these new huge Leopard ones.
    I began using *Icon Composer* from the developer tools after doing the graphics in Photoshop, then using IconDroplet to get them into a form where i can copy and paste them between *Get Info* windows. What a pain.
    Now i discover this bit where they're not clickable once i replace them! I didn't know about the behaviors when making them big in *Cover Flow* and small in Icon view until i read this.
    I've been snooping around but i haven't found what needs to be tweaked where to allow them to behave properly.
    !http://img228.imageshack.us/img228/5186/scottdartve1.png!

  • Custom Icon Frustration

    I built an AS3 component and designed a custom icon.
    Right-clicked symbol in library, selected component definition and
    clicked on the icon button (under description) to set an icon.
    When I select custom... my finder pops up and I can navigate
    to any folder on my machine but I can't select an icon, all .pngs
    (and all other files) are greyed out.
    Possibly related, if I select one of the normal icons (button
    or something) it sets the icon correctly but I then can't set the
    icon back to the default icon and I still can't set a custom icon.
    I originally created the icons in photoshop, but I've also
    tried exporting them from Fireworks -- no luck. I also tried
    finding the default icons in my installation and editing them but
    sadly this didn't work either (maybe I looked in the wrong place).
    I'm using CS3 on Mac -- please tell me this isn't a bug, I
    really don't want to have to buy a windows copy of Flash just to
    add an icon to a component.

    It is a bug. Nivesh at Adobe support was kind enough to email
    me the solution: you need to enable Version Cue for file operations
    (Preferences / General category / Enable Version Cue).

  • Automatically create folders then attach custom icon to each folder.

    This is my current working script, does anyone know how I can now add customer icons to the folders in Applescript
    Many thanks
    Matt
    set theWeekNumber to ""
    repeat
    display dialog "Please enter the week number:" default answer theWeekNumber
    set theWeekNumber to text returned of result
    try
    if theWeekNumber = "" then error
    set theWeekNumber to theWeekNumber as number
    exit repeat
    on error
    set thePrefix to "INVALID ENTRY! "
    end try
    end repeat
    set theAFolder to "AFolder_WK" & theWeekNumber
    set theBFolder to "BFolder_WK" & theWeekNumber
    set theEnd to "_PSD"
    set theEnd2 to "todo"
    tell application "Finder"
    make folder at folder "Studio:Users:matthewchild:Desktop" with properties {name:theAFolder & theEnd}
    make folder at folder "Studio:Users:matthewchild:Desktop" with properties {name:theBFolder & theEnd}
    make folder at folder "Studio:Users:matthewchild:Desktop" with properties {name:theAFolder & theEnd2}
    make folder at folder "Studio:Users:matthewchild:Desktop" with properties {name:theBFolder & theEnd2}
    end tell

    The following script uses a handler that will set a custom icon to a file item. In this example, you are prompted for the icon file and the file item to set to the icon, but you can just pass the desired image and folder paths directly to the handler.
    <pre style="
    font-family: Monaco, 'Courier New', Courier, monospace;
    font-size: 10px;
    font-weight: normal;
    margin: 0px;
    padding: 5px;
    border: 1px solid #000000;
    width: 720px; height: 340px;
    color: #000000;
    background-color: #FFD891;
    overflow: auto;"
    title="this text can be pasted into the AppleScript Editor">
    -- assign an icon to a folder or file (requires Developer Tools)
    -- any image file can be used for the icon
    property startingDirectory : (path to home folder) -- a place for the file choice dialogs to start from
    on run -- example
    try -- check for tools
    get "/Developer/Tools/" as POSIX file as alias
    on error
    error "Developer Tools not installed"
    end try
    set iconFile to (choose file with prompt "Choose an image file for the icon:" default location startingDirectory)
    if (do shell script "/usr/bin/file " & quoted form of POSIX path of iconFile) does not contain "image" then -- check image file
    error "The icon file is not an image"
    end if
    tell application "Automator Runner" to tell open panel -- using this panel allows the choice of a file or folder
    set floating to true
    set can choose directories to true
    set can choose files to true
    set allows multiple selection to false
    call method "setShowsHiddenFiles:" of it with parameters {false}
    set title to "Select an item to set to the custom icon:"
    set prompt to "Set Icon" -- this is actually the button text
    activate
    if (display it in directory startingDirectory) is 0 then -- cancel button
    error number -128
    else
    my (setCustomIcon from iconFile to (it's path names as text)) -- just one item
    end if
    end tell
    end run
    to setCustomIcon from imageFile to destination
    Set the icon of a destination file item to the image contained in imageFile
    parameters - imageFile [various]: an imagefile for the icon (Finder alias or POSIX text)
    destination [various]: a destination item to set to the icon (Finder alias or POSIX text)
    returns [boolean]: true if icon is set, false otherwise
    set imageFile to imageFile as text
    if imageFile starts with "/" then -- check for POSIX file
    set imageFile to imageFile as POSIX file as alias
    else
    set imageFile to imageFile as alias
    end if
    set destination to destination as text
    if destination does not start with "/" then -- check for POSIX file
    set destination to POSIX path of destination
    end if
    try
    tell application "Finder" -- copy the icon image to a temporary file
    (duplicate imageFile to (path to temporary items) with replacing) as alias
    set tempImage to quoted form of POSIX path of the result
    end tell
    set tempResource to quoted form of (POSIX path of (((path to temporary items) as text) & "TempResource"))
    do shell script "/usr/bin/sips -i " & tempImage -- add a Finder icon to the image
    do shell script "/Developer/Tools/DeRez -only icns " & tempImage & " > " & tempResource -- get the icon resource
    do shell script "/usr/bin/file " & quoted form of destination -- determine the destination file type
    if the result contains "directory" then -- folder
    set theTarget to quoted form of (destination & "/Icon" & return) -- create Icon\r file
    set Command to "rm " & theTarget & "; " -- remove any existing custom icon
    set Command to Command & "/Developer/Tools/Rez -a " & tempResource & " -o " & theTarget & "; " -- add resource file to a folder
    set Command to Command & "/Developer/Tools/SetFile -a V " & theTarget & "; " -- make it invisible
    else -- file
    set Command to "/Developer/Tools/Rez -a " & tempResource & " -o " & quoted form of destination & "; " -- add resource to a file
    end if
    set Command to Command & "/Developer/Tools/SetFile -a C " & quoted form of destination -- set custom icon attribute
    do shell script Command -- do it
    on error errmess number errnum -- oops
    log errmess
    -- display alert "Error " & errnum message errmess buttons {"OK"}
    return false
    end try
    try -- remove temporary files
    do shell script "rm " & tempImage & space & tempResource
    end try
    tell application "Finder" to update (destination as POSIX file)
    return true
    end setCustomIcon
    </pre>

  • How to assign file extension and custom icon to executable?

    Hi all,
    I was reading an old thread about this issue:
    http://forums.ni.com/ni/board/message?board.id=170&thread.id=116925 
    I need to try to do this.  My application uses a custom file extension (i.e. .abc).  Upon installation I would like to:
    1.  Assign My App and custom icon to the file class (extension .abc).
    This could be done by manipluting the registry (http://msdn.microsoft.com/en-us/library/bb776856(VS.85).aspx)?  This could be a problem with Vista s unless registry operations occur during installation any changes are placed in a VirtualStore, correct?
    2.  Enable the double-clicking of .abc file type to pass the data in the file to my VI (exe). 
    According to the File Handling Guidelines of Jean-Pierre Drolet (http://www.openg.org/tiki/tiki-index.php?page=File+Handling+Guidelines) the best way to do this may be using LabVIEW as an ActiveX server.
    I know that when I build an executable (or installer?) there is the option to enable LabVIEW to act as an ActiveX server.  This much I know I need to do.
    I thought I would open this discussion again as others may be interested and there doesn't appear to be a completely clear solution available.  Please do contribute where you can.
    Cheers,
    Battler.

    battler. wrote:
    My application consists of Event Structure.
    How to register for ommand line event so that when a user double-clicks on a .abc file I can handle the opening of it?
    This needs to work (the files need to open) not only when the application is closed but also when it's already open.
    Anyone have ideas? 
    The solution to that is to implement a DDE server in your application (and add DDE entries to the registry on installation). There are still DDE functions in LabVIEW vi.lib\Platform\dde.llb but they are considered depreciated and have been removed from the palette, also because Microsoft is trying to tell everyone that DDE is depreciated and sort of unsupported too. But it is still the mechanisme to pass actions from the shell to running applications.
    I hesitate to send you over to lavag.org where there have been some discussions about this years ago. If you go there you would do good to employ a friendly attitude. That board is run all by enthusiasts and idealists and they are all great folks but react not very friendly to people with an attitude.
    Rolf Kalbermatter
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • Mystery of the Disappearing Custom Icons

    iMac 2.66; 10.6.4
    I create simple custom icon labels for the docs & folders in my dock. I type a filename in TextEdit, take a screenshot of it, open the screenshot in GraphicConverter, and copy & paste it into the getinfo window of the doc or folder. Then I drag it to the dock. Now and then, with no pattern or seeming cause, the custom icons on one or more disappear. Some never disappear. Sometimes it'll be weeks with no problem, sometimes hours. I repair permissions twice a week without fail. I have no other issues going on. Anyone know why this is happening? I've searched the fora but can't find similar problems.

    jimbo66
    I tried helping another with a similar problem. He eventually found a solution from another post. http://discussions.apple.com/message.jspa?messageID=4499196#4499196
    Powerbook G4, MacBook Pro, Mac G5, Mac G4, Mac Mini   Mac OS X (10.4.8)  

  • Trouble with some documents: no custom icon, only generic appears

    I tried anything: rebuilt launch servcice, permission repair, daily, weekly, monthly scripts (using maintanace, onyx, etc...) BUT all the documents associated with Openoffice have no custom icon. I also tried reinstalling oo with no success. It happens with textedit and keynote (using "get info", open with, apply to all) and don't know why?
    Can anybody help me?
    Thanks!

    You could create a new admin user and move the data within each of these folders to the corresponding folder on the new account: Desktop, Documents. Library, Movies, Music, etc. You can di it most easily IMO, by copying your Home folder to DVD first. Alternatively, you could use Users/Shared for the data.
    But it would really be best to sort this issue in your present user.
    It would be a good idea to test with a new user though to see if the problem exists there.
    Create a new account, name it "test" and see how your OO & TE work in that User acct? (That will tell if your problem is systemwide or limited to your User acct.) This account is just for test, do nothing further with it.
    Open System Preferences >> Accounts >> "+" make it an admin account.
    Let us know and we'll troubleshoot this further.
    -mj
    [email protected]

  • Custom icons not showing up in installer dialogs

    What are the steps that are required to get a custom icon to show up in the installation dialogs?
    I have custom icons setup in the application descriptor xml file for my app... and they do show up in the OS after I install the application but I don't see the icon showing up in the install dialogs.
    Any ideas why the custom icons are not showing up in the installation dialogs?
    Here is what TweetDecks installation dialog looks like... (this is what I want)
    Here is screenshot of what my installation dialog looks like...

    You need to sign your app with a certificate that chains up to a trusted root certificate. In general that means you need to get a cert from verisign or someone like that. If you get the friendly warning dialog on the first installer screen rather than the scary one with lots of red x's, you should then see your image

  • Custom icon seems locked ... can't change it

    Powermac G5/10.4.6
    A while back I put custom icons on two partitions of a LaCie FW drive. I'd like to change the icons, but I can't select them in the "Get Info" window. I can change icons of other drives, just not these two partitions. When I click on the icon in the info window, it does not become "selected" (with the blue border around it.) Pasting does nothing and dragging an image into the Preview area of Get Info does nothing, either.
    I've got Read & Write permissions on both these drives.
    Any ideas?
    AG

    hi again,
    just follow the steps as i wrote them before. i'll put them here again w/ some more comments to walk you through
    1. double-click on the Terminal Application: Applications > Utilities > Terminal.
    2. a "Terminal" window pops up
    3. now enter the letters "cd", then a space, then drag the icon for the drive from a finder window into this Terminal window.
    4. hit return.
    now enter this: ls -lasF
    then hit return to see what's in that area.
    do you see a file in that listing called .VolumeIcon.icns ?
    post back if it's still not clear so far...
    to delete that file, enter in tothe same Terminal window the following command:
    sudo rm .VolumeIcon.icns
    then hit return.
    then enter your admin password and hit return.
    then enter ls -lasF again. this custom icon file will be gone now...
    cheers

  • Custom icon image for folders not showing up in dock

    I have used custom icons for years for various folders so I don't have to read through names of folders to know what's in them. With Leopard (10.5.2), the folder icons are visible up on the desktop and everywhere else; however, when I drag a folder with a special icon to the dock,it becomes a normal blue folder again. Why can't the folder in the dock retain the special icon I have assigned to it?

    right click on the folder after placing it on the dock and choose display as folder.

  • Custom Icon Images for Folders in KM

    Hello Everyody,
                   I have to display folders such as Pesonal Documents, Public documents, Recently used, Favourites etc which are there in the entry point repository in KM. Right now all these folders are being displayed with the default icon image specified. I want to replace these default images with custom images but couldnt see any property where i can change the image path for these folders. I checked the details of all these folders and even went through the properties but there it shows only the default image name speciefied for that folder and no active settings where i can change the image path for custom icon. Kindly suggest how to implement custom image for KM folder icons.
    Thanking you all in advance,
    Regards,
    Sarabjeet.

    Hi,
    If I understood, you have a KM navigation iview, where some folders apperar. You want to change the icon for each of them differently.
    For this do the following:
    First have a look into the KM.navigation iview and get the layout set property. Go to System config->KM->Content management->User interface->Settings->LayoutSet and find the layout set you are using. Go to appropriate resource renderer and check the "<b>Icon setting</b>". Change it to: <b>iconreplace</b>.
    Now get the KM details for your folders and change the <b>IconSource</b> property to your image Example:
    /etc/public/mimes/images/add.gif
    Voila...the icons for these folders are changed!
    Hope this is your case.
    Romano

  • Custom icon lost from dock when clicked.

    Hello.
    I'm currently running OS 10.6.1 on 15" MBP w/ 2.4 Ghz Intel Core 2 Duo, 4 GB RAM. I experienced this same issue in Leopard, but was hoping Snow Leopard would fix it. I thought it did, but it just happened again.
    I keep several documents in the dock that I use very frequently (three MS Excel workbooks, 1 FM Pro database). For some reason, when I click on any of the Excel docs, the custom icon I have assigned to it is lost. Even when I reveal in Finder, the icon has just been removed, and the standard Excel icon shows.
    The funny thing is that the custom icons, when replaced, seem to last for several clicks, then for some reason, they just go away when the doc is clicked.
    Has anyone experienced this issue? Any help would be awesome.

    Hi eye sean,
    The program icons on your Dock (App Store, System Preferences) are alias links (shortcuts) and not the programs themselves. You can't delete them by removing them from the Dock. Now, if somehow they were accidentally removed from the /Applications folder then that's a bigger issue. I take it neither of the programs or in that folder?
    If that's the case there's two things I'm aware of worth trying:
    Run a repair Disk Permissions from the installation disc that came with your computer
    Reinstall the Operating System via the installation disc
    If System Preferences (the application) is completely gone, then it's option #2. If it's corrupted the disk permissions may resolved it. I'd say you could make a new user to see if a preference pane that's specific to your current user is causing problems, but without System Preferences access that's not really a valid option.

  • Custom icon for desktop shortcut

    Hi All,
    I have a link in the portal which when the end users click should create a desktop shortcut to the portal.
    I used this to create the desktop shortcut
    var WshShell = new ActiveXObject("WScript.Shell");
    strDesktop = WshShell.SpecialFolders("Desktop");
    var oShellLink = WshShell.CreateShortcut(strDesktop + "
    Portal.url");
    oShellLink.TargetPath = "URL to the portal";
    oShellLink.Save();
    By default we get the IE icon for this shortcut. I want a custom icon to be associated with this shortcut.
    I can use oShellLink.IconLocation but the icon needs to be in every users c:\windows folder.
    Does somebody know how can I add this custom icon?
    Many Thanks,
    Akhilesh

    Google for Favicon
    "TonyEB" <[email protected]> wrote in
    message
    news:fb57gl$ea4$[email protected]..
    > Hi,
    >
    > How do you incorporate an Icon in to your website so
    that when someone
    > puts a
    > web short cut on their desktop it changes from the
    default to your
    > customized
    > one. Where in DW CS3 do you put this file?
    >
    >
    > Thanks
    >
    > Tony
    >

  • Custom icon on a disk shared via Airport Extreme

    I have a USB hard drive that I am sharing via an airport extreme. In the finder, under "Shared" I see my airport extreme. When I click on that, I see my external drive. I would like to change the icon for that, but the standard Get Info -> paste doesn't seem to work.
    I've tried to set a custom icon on a test folder on my hard drive and it works. I also tried it on a test folder on the USB drive shared via airport extreme, and that worked. But I can't set the icon for the drive itself. Any suggestions?

    No, they pulled it, even though Steve promised the wireless backup feature in his latest keynote. One hour into it to be exact.
    http://events.apple.com.edgesuite.net/d7625zs/event/
    Now, I am very much against releasing a product before its ready, so I respect them for that. However Steve VERY clearly states that it was already working and would release with Leopard. He usually makes a very very clear distinction between things they "can/might" do and things that are working. He even goes into detail about how all the house macs can wirelessly use the same backup through the Airport Express. THEY EVEN HAVE A PICTURE of it!
    So they need more time, okay. But I feel lied to. The least they could do is make a press release with an ETA! The hush hush, makes it seem like they are going to scrap it and pretend it never happened.

Maybe you are looking for

  • Inter company Billing - for service

    Dear SD Experts, My client has 2 company; that are,            Company 1000 with sales org 1000      and            Company 2000 with sales org 2000 A customer placed order by company 1000. How can I create an order by company 1000 and an invoice it

  • How to send docs via bluetooth from / to iPad?

    How to send quickly docs via bluetooth from / to iPad instead via itunes etc?

  • ONS.Log is filling up my machine

    Can anyone help me with this problem. I have installed 9iAS infrastructure and mid-iter (portal and forms only) on a Windows 2000 server. Everything seems to run fine for a few hours and then I am out of disk space - almost 30GB are used up in the on

  • Which database version to download?

    Hello, I need to install Oracle 10G database on an IBM blade system running Red Hat Enterprise Linux ES release 4. How do I tell which version to choose? Output from uname -a is: Linux xxxxxxx 2.6.9-42.0.3.ELsmp #1 SMP Mon Sep 25 17:28:02 EDT 2006 i6

  • 10-Bit display test with 16-bit TIFF

    Okay, I just got this new HP Dreamcolor Z27x and want to test it on 10-Bit with Windows 8.1 64bit and Photoshop CC 2014. I followed that guide: 10 Bit Color Depth and Adobe Photoshop CS6 | ted lansing photography blog to create the TIFF-File: In Adob