Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

App icon

Posted on 2000-04-27
2
Medium Priority
?
242 Views
Last Modified: 2012-06-27
Hi,
How do I set a frame's icon, using a .gif file? for both JFrame and JDialog.

By setting an icon I mean like an app icon.
0
Comment
Question by:s_lavie
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 19

Expert Comment

by:Jim Cakalic
ID: 2756332
Use Frame.setIconImage(Image):

    Frame frame = new Frame("Application");
    ImageIcon icon = new ImageIcon("my_frame_icon.gif");
    frame.setIconImage(icon.getImage());

Best regards,
Jim Cakalic
0
 
LVL 19

Accepted Solution

by:
Jim Cakalic earned 200 total points
ID: 2756360
Sorry, that wasn't a complete answer. This works for JFrame since it extends Frame.

JDialog is another story. JDialog will use whatever icon image its parent Frame uses. You set the parent Frame of a JDialog by using one of the four JDialog constructors that has 'Frame owner' as its first argument.

If you want your JDialog to have a different icon image or you don't want to (or can't) set an existing Frame as the dialog owner, you can create a dummy JFrame, set its image, and make this the owner of the JDialog.

    JFrame dummyFrame = new JFrame();
    ImageIcon icon = new ImageIcon( ....... );
    dummyFrame.setIconImage(icon.getImage());
    JDialog dialog = new JDialog(dummyFrame, ...);

Best regards,
Jim Cakalic

0

Featured Post

The top UI technologies you need to be aware of

An important part of the job as a front-end developer is to stay up to date and in contact with new tools, trends and workflows. That’s why you cannot miss this upcoming webinar to explore the latest trends in UI technologies!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Suggested Courses

704 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question