Java GUI Framework

  Home  Java Programing  Java GUI Framework


“Java GUI Framework  frequently Asked Questions by expert members with experience in Java GUI Framework . These interview questions and answers on Java GUI Framework  will help you strengthen your technical skills, prepare for the interviews and quickly revise the concepts. So get preparation for the Java GUI Framework  job interview”



28 Java GUI Framework Questions And Answers

21⟩ How to replace the icon in the title bar (window decoration) of a [J]Dialog?

There 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.

 153 views

22⟩ How to handle opening of database, file or network connection on a click of button?

This one is one of the easy java swing interview question. Interviewer is interested on whether you know the basic principle of Java GUI development or not. answer is you should not do this operation in EDT thread instead spawn a new thread from actionListener or button and disable the button until operation gets completed to avoid resubmitting request. Only condition is that your GUI should always be responsive no matter what happens on network connection or database connection because these operations usually take time.

 182 views

23⟩ Write code to print following layout (mainly focused on GridBag layout)?

After JTable second favorite topic of swing interviewer is GridBagLayout. GridBagLayout in swing is most powerful but at same time most complex layout and a clear cut experience and expertise around GridBagLayout is desired for developing Swing GUI for trading systems. No matter whether you are developing GUI for equities trading, futures or options trading or forex trading you always required GridBagLayout. Swing interview question on GridBagLayout will be mostly on writing code for a particular layout just like an example shown here. In which six buttons A, B, C, D, E and F are organized in certain fashion.

 154 views

24⟩ Explain Prediction of output of code?

This is another category of Swing interview questions asked in IB whether they will give you code and asked what would be the output , how will the GUI look like. This type of question is based upon how well you understand and visualize the code. Whether you are familiar with default layout manager of various component classes or not e.g. default layout of JFrame is BorderLayout. So do some practice of these kinds of java Swing interview questions as well?

 150 views

25⟩ What are differences between Swing and AWT?

One of the classic java swing interview questions and mostly asked on phone interviews. There is couple of differences between swing and AWT:

1) AWT component are considered to be heavyweight while Swing component are lightweights

2) Swing has plug-gable look and feel.

3) AWT is platform depended same GUI will look different on different platform while Swing is developed in Java and is platform dependent.

 160 views

26⟩ Why Swing components are called lightweight component?

Another popular java swing interview question, I guess the oldest that is generally comes as followup of earlier question based on your answer provided. AWT components are associated with native screen resource and called heavyweight component while Swing components is uses the screen resource of an ancestor instead of having there own and that's why called lightweight or lighter component.

 143 views

27⟩ Does Swing is thread safe? What do you mean by swing is not thread-safe?

This swing interview questions is getting very popular now days. Though it’s pretty basic many developer doesn't understand thread-safety issue in Swing. Since Swing components are not thread-safe it means you can not update these components in any thread other than Event-Driven-Thread. If you do so you will get unexpected behavior. Some time interviewer will also ask what are thread-safe methods in swing which can be safely called from any thread only few like repaint() and revalidate().

 137 views

28⟩ What is difference between invokeAndWait and invokeLater?

This swing interview question is asked differently at different point. some time interviewer ask how do you update swing component from a thread other than EDT, for such kind of scenario we use SwingUtilities.invokeAndWait(Runnable r) and SwingUtilities.invokeLetter(Runnable r) though there are quite a few differences between these two, major one is invokeAndWait is a blocking call and wait until GUI updates while invokeLater is a non blocking asynchronous call. In my opinion these question has its own value and every swing developer should be familiar with these questions or concept not just for interview point of view but on application perspective. you can read more on my post How InvokeAndWait and InvokeLater works in Swing

 168 views