Interview Questions Answers.ORG
Interviewer And Interviewee Guide
Interviews
Quizzes
Home
Quizzes
Interviews Java Programming Language Interviews:Advanced JavaCore JavaEclipseFull Stack Developer (Java)HibernateIBM WebSphereInternationalization LocalizationJ2EEJ2MEJ2SEJavaJava ANTJava AppletJava BeansJava ClassesJava EJB ProgrammingJava Game DeveloperJava GUI FrameworkJava JNDIJava JNIJava JSP ProgrammingJava Message Service (JMS)Java Multi-ThreadingJava Networking - Sockets and RMIJava PatternsJava SecurityJava Server FacesJava Servlet ProgrammingJava Software EngineerJava Swing ProgrammingJava TechnicalJava ThreadsJava Transaction APIJava Web ServicesJavaMailJBossJDBCJMSJSFPortal and PortletRMISpring FrameworkSr.Java Web DeveloperStrutsSunOneSwing AWTSWT JFace
Copyright © 2018. All Rights Reserved
Java GUI Framework Interview Question:
How to replace the icon in the title bar (window decoration) of a [J]Dialog?
Submitted by: AdministratorThere is only a partial solution to this problem, and it is not recommended.
A dialog gets its icon from its parent frame. You can create a dummy frame, set the icon of that dummy frame, and use it in the constructor of the dialog as the dialog's owner:
JFrame dummy = new JFrame();
Image icon = ...
dummyFrame.setIconImage(icon);
JDialog dialog = new JDialog(dummy);
However, this is dangerous. Certain GUI behavior depends on a correct [J]Frame (parent window) <-> [J]Dialog (child window) relation. Introducing a dummy parent breaks this relation. Things which can go wrong include (de)iconising of all windows of an application, and ensuring a modal dialog is always placed on-top of the main window.
Submitted by: Administrator
A dialog gets its icon from its parent frame. You can create a dummy frame, set the icon of that dummy frame, and use it in the constructor of the dialog as the dialog's owner:
JFrame dummy = new JFrame();
Image icon = ...
dummyFrame.setIconImage(icon);
JDialog dialog = new JDialog(dummy);
However, this is dangerous. Certain GUI behavior depends on a correct [J]Frame (parent window) <-> [J]Dialog (child window) relation. Introducing a dummy parent breaks this relation. Things which can go wrong include (de)iconising of all windows of an application, and ensuring a modal dialog is always placed on-top of the main window.
Submitted by: Administrator
Copyright 2007-2024 by Interview Questions Answers .ORG All Rights Reserved.
https://InterviewQuestionsAnswers.ORG.
https://InterviewQuestionsAnswers.ORG.