Solved

App icon

Posted on 2000-04-27
2
239 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 50 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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
In this post we will learn different types of Android Layout and some basics of an Android App.
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses

628 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