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

1⟩ What is JavaFX?

The latest flagship of Java/Oracle. promising to be the facto standard in developing rich desktop or web applications.

 147 views

2⟩ What is SwingX?

Based on Swing and it's mission is to create rich components for swing. Still under development. (not very active though.) Have a very nice set of components, like for example TreeTable. But the TreeTable does not support filtering and sorting as far as i know. It does however support searching with highlighting.

 144 views

3⟩ Can you explain Swing?

Based on AWT as previously stated. In its infancy it was regarded as slow and buggy and caused IBM to create SWT for Eclipse. However with Java 5 (or 6?) Swing became the framework of choice for building new applications. Swing has a lot of rich components but are still lacking in some areas. One example being that there isn't a full featured TreeTable component which can do sorting and filtering/searching.

 125 views

4⟩ What do you know about SWT?

Created by IBM for Eclipse, they seemed to think that Swing was not suited for Eclipse at the time. By itself is pretty low-level, and it uses the platform's native widgets through JNI. It is not related to Swing and AWT at all. Their API is however somewhat clunky and not intuitive. They do have some advanced component's like a TreeTable. (but i don't think they support sorting and filtering out of the box). SWT uses some native bindings (through JNI?) and the rant on the internet is that this framework should not be used in today's projects. (why not?)

 141 views

5⟩ Do you know AWT?

Is the very foundation of swing, it performs well but is lacking in advanced components. If you intend to create rich applications, AWT is probably not the way to go. However for smaller gui applications that doesn't require rich user interfaces. This might suit perfectly as it's a tried and proven framework.

 137 views

6⟩ What is Event-Driven-Thread (EDT) in Swing?

Event-Driven-Thread or EDT is a special thread in Swing and AWT. Event-Driven Thread is used to draw graphics and listen for events in Swing. You will get a bonus point if you able to highlight that time consuming operations like connecting to database, opening a file or connecting to network should not be done on EDT thread because it could lead to freezing GUI because of blocking and time consuming nature of these operations instead they should be done on separate thread and EDT can just be used to spawn those thread on a button click or mouse click.

 145 views

8⟩ How to draw a tree?

This seems to be a common homework question, so please have a look at the "Which topics are not welcome in the newsgroup?" to understand why this answer is intentionally vague.

If the fixed layout of JTree suits your needs, you could start reading the JTree API documentation.

Or you could use a simple (recursive) algorithm. E.g

x(node) = K * level(node), and

y(node) = M * inorder_rank(node).

gives very ugly trees, but trees. If this doesn't get you started, ask your professor or tutor for more hints. Consult your text book about (inorder) tree traversal, and consult

http://home.earthlink.net/~patricia_shanahan/beginner.html

 136 views

9⟩ What is an SSCCE?

Short/small, self contained, compilable, example (source code).

It would be best if you provide such short (see the group's charter) example source code in our first request for help. When asked for one, please don't complain that your source code is to large, to tricky, to secret for being cut down to a reasonable size and posted. You have the problem, and you asked in a public forum, so it is in your interest to provide the requested information.

 135 views

10⟩ How to draw lines between JLabels on a JPanel?

You are apparently trying to draw a graph by using normal widgets to draw the nodes of your graph. This is not a good idea. Consider using the Java 2D API (nowadays part of J2SE) to draw the complete graph. Have a look at java.awt.geom for predefined shapes. Also check out Sun's 2D Programmer's Guide

 137 views

11⟩ What is the equivalent of AWTs Canvas in Swing?

JPanel, if you want to have a "complete" component with a UI delegate which handles opaque settings (if paintComponent() is correctly overridden).

JComponent if you intend to always draw every pixel in the area of the component (and break the opaque attribute API contract). If you need to have your own special key and mouse processing, you might also want to start with JComponent and create your own UI delegate.

You could even start higher up in the inheritance chain. java.awt.Component is lightweight since Java 1.1. However, you will not get Swing additions like double-buffering.

If this is all Greek to you, use JPanel. And remember, if you use JComponent or JPanel, override paintComponent(), not paint().

 142 views

12⟩ How to get the screen size? How Do I center a window on the screen?

Manually, pre 1.4:

Use java.awt.Toolkit.getDefaultToolkit().getScreenSize() to get the screen size, and do the math:

import java.awt.*;

Dimension winSize = win.getSize();

Dimension screenSize =

Toolkit.getDefaultToolkit().getScreenSize();

win.setLocation(

screenSize.width / 2 - winSize.width / 2,

screenSize.height / 2 - winSize.height / 2

);

Since 1.4:

Window.setLocationRelativeTo(null);

 136 views

13⟩ How to generate some charts / plots in Java?

If you want to do the drawing in Java, consider using a chart drawing library. E.g.

http://www.jfree.org/jfreechart/index.html

gets recommended often. The web site also has a list of other chart libraries.

If you just have to plot some (scientific) data, and if you can live with an external C program, consider using gnuplot

http://www.gnuplot.info/

Use System.exec() to pipe the plot commands and data into gnuplot, or just write the data to a file and use gnuplot separately.

 142 views

14⟩ How to to write a diagram editor. How to start?

Consider using a framework like

http://www.jhotdraw.org/

for a start. You also might want to familiarize yourself with many of the design patterns in

Gamma, E.; Helm, R.; Johnson, R.; Vlissides, J.: Design

Patterns: Elements of reusable object-oriented Software.

Addison-Wesley professional computing series. Brian W.

Kernighan, Consulting Editor. Reading, MA: Addison-Wesley,

1994.

And (if you manage to find documentation), the early work on UniDraw and IDraw by Vlissides is also interesting (in C++).

 126 views

16⟩ How to (de)iconify a window?

Before Java 1.2 you had to revert to native calls.

Since Java 1.2 you can use [J]Frame.setState().

Since Java 1.4 you can use [J]Frame.setExtendedState(), too. setExtendedState() provides more features than setState().

 124 views

18⟩ What is Qt Jambi?

A java wrapper to the native qt library which is written in c/c++. Very powerful, widely used and accepted. Has a lot of GUI components and a easy to use API.

 132 views

19⟩ What is Apache Pivot?

It renders UI using Java2D, thus minimizing the impact of (IMO, bloated) legacies of Swing and AWT.

It's main focus seems to be on RIA (Rich internet applications), but it seems it can also be applied to desktop applications. And as a personal comment, Looks very interesting! I Especially like that it's an apache project.

 139 views

20⟩ Write code for JTable with custom cell editor and custom cell renderer?

Now comes harder part of swing interviews, questions asked in this part of Swing interview is mostly about writing code and checking developer’s capability of API familiarity, key concept of swing code etc.

JTable is one of favorite topic of all Swing interviews and most popular questions on swing interviews are from JTable why? Because here interviewer will directly asked you to write code another reason is JTable heavily used in all Electronic trading GUI. GUI used for online stock trading uses JTable to show data in tabular format so an in depth knowledge of JTable is required to work on online trading GUI developed in Swing. While this question is just an example questions around JTable are mostly centered around updating table, how do you handle large volume of data in table, using customize cell renderer and editor, sorting table data based on any column etc. so just make sure you have done quite a few handsone exercise on JTable before appearing for any java swing interview in IB.

 135 views