Can I use a translucent picture as a main JFrame's icoimage?

Discussion in 'Java' started by ¼û·çʹ¶æ, Feb 20, 2009.

  1. Mainly code is like the flowing:
    public class MyFrame extends JFrame {
    public MyFrame (){
    String logoPath ="c:/test.png"
    ImageIcon icon =new ImageIcon(logoPath);
    this.setIconImage(icon.getImage());
    }
    }

    but the result is not right,the test.png looks distortion.

    Can you help me?
    ¼û·çʹ¶æ, Feb 20, 2009
    #1
    1. Advertising

  2. In article
    <>,
    º˚∑àπ∂Ê <> wrote:

    > Mainly code is like the f[ol]lowing:


    You will perhaps get better answers if you post actual (rather than
    similar) code:

    <http://pscode.org/sscce.html>
    import java.awt.EventQueue;
    import javax.swing.ImageIcon;
    import javax.swing.JFrame;
    import javax.swing.JLabel;

    public class ImageIconTest {

    public static void main(String[] args) {
    EventQueue.invokeLater(new Runnable() {
    //@Override
    public void run() {
    ImageIcon img = new ImageIcon("image.png");
    JFrame f = new JFrame("Frame");
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.setIconImage(img.getImage());
    f.add(new JLabel(img));
    f.pack();
    f.setVisible(true);
    }
    });
    }
    }
    </sscce>
    [...]

    > but the result is not right,the test.png looks distortion.


    Perhaps you can supply a link to the image or describe more fully what
    you mean by "distortion". Not all platforms support the concept of
    minimizing a window.

    --
    John B. Matthews
    trashgod at gmail dot com
    <http://sites.google.com/site/drjohnbmatthews>
    John B. Matthews, Feb 20, 2009
    #2
    1. Advertising

  3. On 2月21æ—¥, 上åˆ12æ—¶27分, "John B.. Matthews" <> wrote:
    > In article
    > <>,
    >
    >  º˚∑àπ∂Ê <> wrote:
    > > Mainly code is like the f[ol]lowing:

    >
    > You will perhaps get better answers if you post actual (rather than
    > similar) code:
    >
    > <http://pscode.org/sscce.html>
    > import java.awt.EventQueue;
    > import javax.swing.ImageIcon;
    > import javax.swing.JFrame;
    > import javax.swing.JLabel;
    >
    > public class ImageIconTest {
    >
    >   public static void main(String[] args) {
    >     EventQueue.invokeLater(new Runnable() {
    >       //@Override
    >       public void run() {
    >         ImageIcon img = new ImageIcon("image.png");
    >         JFrame f = new JFrame("Frame");
    >         f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    >         f.setIconImage(img.getImage());
    >         f.add(new JLabel(img));
    >         f.pack();
    >         f.setVisible(true);
    >       }
    >     });
    >   }}
    >
    > </sscce>
    > [...]
    >
    > > but the result is not right,the test.png looks distortion.

    >
    > Perhaps you can supply a link to the image or describe more fully what
    > you mean by "distortion". Not all platforms support the concept of
    > minimizing a window.
    >
    > --
    > John B. Matthews
    > trashgod at gmail dot com
    > <http://sites.google.com/site/drjohnbmatthews>


    Thank you for your answers.But the problem still exist.
    I don't want "minimizing a window".
    I mean that the icon of the JFrame looks rough,not clear differ to the
    origin image.png file.
    The color of the origin image.png file is 16-bit True Color,But the
    runtime result is not .

    Why?Can you help me? Thank you very much.
    è§é£Žä½¿èˆµ, Feb 21, 2009
    #3
  4. In article
    <>,
    ºš…Á ¼Ê <> wrote:

    > On 2åé21ì™, è“åþ12 ±27…÷, "John B. Matthews" <> wrote:
    > > In article
    > > <>,
    > >
    > > ݺš…Á ¼Ê <> wrote:
    > > > Mainly code is like the f[ol]lowing:

    > >
    > > You will perhaps get better answers if you post actual (rather than
    > > similar) code:
    > >
    > > <http://pscode.org/sscce.html>

    [...]
    > > </sscce>
    > > > but the result is not right,the test.png looks distortion.

    > >
    > > Perhaps you can supply a link to the image or describe more fully
    > > what you mean by "distortion". Not all platforms support the
    > > concept of minimizing a window.


    [Please trim sigs when responding.]

    > Thank you for your answers. But the problem still exist. I don't want
    > "minimizing a window".


    I don't know how else to interpret the API for JFrame#setIconImage():
    "Sets the image to be displayed in the minimized icon for this frame.
    Not all platforms support the concept of minimizing a window." On my
    platform, a minimized window shows a thumbnail of the frame's content
    pane overlain by a cup of coffee; invoking setIconImage() has no
    apparent effect.

    > I mean that the icon of the JFrame looks rough, not clear differ to
    > the origin image.png file. The color of the origin image.png file is
    > 16-bit True Color, but the runtime result is not. Why?


    You might try a different image format, a different image, or an image
    that has been scaled to display clearly at the required size.

    > Can you help me?


    As setIconImage() does nothing on my platform, no. You will perhaps get
    a more helpful answer if you post a link to the image, the code, and a
    screenshot showing the problem. I use <http://sites.google.com>, but
    alternatives abound.

    > Thank you very much.


    --
    John B. Matthews
    trashgod at gmail dot com
    <http://sites.google.com/site/drjohnbmatthews>
    John B. Matthews, Feb 21, 2009
    #4
  5. On Sat, 21 Feb 2009 04:15:50 -0500, John B. Matthews wrote:

    > In article
    > <>,
    > ºš…à¼ÂÊ <> wrote:

    [ SNIP ]
    >> Can you help me?

    >
    > As setIconImage() does nothing on my platform, no. You will perhaps get
    > a more helpful answer if you post a link to the image, the code, and a
    > screenshot showing the problem. I use <http://sites.google.com>, but
    > alternatives abound.


    Agreed. I'm half interested in the OP's problem, and would be willing to
    test on various flavours of Windows, Linux and Mac OS X, but since we
    don't have enough information about the image (in fact, we need the
    specific image), and I'm unclear as where the app icon is problematic,
    it's tough to help out.

    AHS
    Arved Sandstrom, Feb 21, 2009
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Spitfire

    translucent popups

    Spitfire, Feb 13, 2007, in forum: Java
    Replies:
    2
    Views:
    314
    Spitfire
    Feb 15, 2007
  2. jakester
    Replies:
    3
    Views:
    1,824
    jakester
    Apr 3, 2007
  3. Spitfire

    translucent window

    Spitfire, Feb 13, 2007, in forum: Ruby
    Replies:
    4
    Views:
    100
    Spitfire
    Feb 15, 2007
  4. Replies:
    8
    Views:
    1,253
    Mick White
    Apr 19, 2005
  5. Replies:
    2
    Views:
    413
    markspace
    Aug 27, 2012
Loading...

Share This Page