ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage   interview questions urls   External Links  Contact Us     Login  |  Sign Up                      
info       Did you received any Funny E-Mails from your Friends and like to share with rest of our friends? Yeah!! you can post that stuff   HERE
Google
 
Categories >> Software >> Java-Related >> Java-J2EE >> Swing
 
 


 

Back to Questions Page
 
Question
can we create a object in static block
class A
{
static {
A a=new A();
}
}
Rank Answer Posted By  
 Question Submitted By :: Rajender
I also faced this Question!!   © ALL Interview .com
Answer
Yes, we can create a object in static block
 
0
Chellammal
 
 
Answer
We can create object because static block is a executable 
block and we don't want any Instance to call. It will be 
called before executing or calling the main thread 
But here we will get object and exception 
//Exception in thread "main" java.lang.NoSuchMethodError: 
main
 
0
Karthik
 
 
Question
Difference between ligt weight and heavy weight?
Rank Answer Posted By  
 Question Submitted By :: Guest
I also faced this Question!!   © ALL Interview .com
Answer
1. Heavy weight components are always Rectangle in shape
while light weight may or may not.

2. Heavy weight components borrows the native screen to
paint their components while light weight render their
components by their own screen painting APIs.

3. They differ from z-indexing to each other, heavy weight
components are always displayed at the top of all
lightweight components.

4. Light weight components are faster in response and
performance.
 
0
Vishwas Saxena
 
 
 
Answer
2, light weight components borrows the native screen to
paint their components while Heavy weight render their
components by their own screen painting APIs.
 
0
Aileen
 
 
Question
when i run Frame program, it display output in supparate 
window.i try to close using "X" it not close.min'-' & 
max'+' are working.pls what is problem? i run in editplus.
folowing program i given.
import java.awt.*;
class Form1 
{
	
		Frame f1=new Frame("loginpage");
		Label l1=new Label("username");
		Label l2=new Label("password");
		TextField tf1=new TextField();
		TextField tf2=new TextField();
		Button b1=new Button("submit");
		Form1()
		{
			f1.setLayout(new FlowLayout());
			f1.add(l1);
			f1.add(tf1);
			f1.add(l2);
			f1.add(tf2);
			f1.add(b1);
			f1.setSize(437,440);
			f1.setVisible(true);
			
            
			//f1.dispose();
		}
		public static void main(String[] args) 
	   {
			Form1 f=new Form1();
	   }
}
Rank Answer Posted By  
 Question Submitted By :: Guest
I also faced this Question!!   © ALL Interview .com
Answer
By default the close button of the frame is not in working 
state.The close button of the frame has to be set for the 
desired operation (i.e. closing the frame).
Set the close button functionality to close the frame or 
window. This is done using the addWindowListener() method 
of the Frame class which passes the new instance of the 
WindowAdapter class that uses the windowClosing() method 
for receiving the WindowEvent and close the frame or window.
frame.addWindowListener(new WindowAdapter(){
      public void windowClosing(WindowEvent we){
        System.exit(0);
      }
    });
 
0
Raj
 
 
Answer
if u implement this process that problem will be solved

addWindowListener(new WindowAdapter()
	{
	public void windowCloseing(WindowEvent ee)
	{
	System.exit(0);
	}});



 
0
Karthik
 
 
Answer
U have answer in u Question Form is component.we need to 
implement add actionLisioner method and we need to override
public void windowCloseing(WindowEvent ee)
	{
	System.exit(0);
	}});
Because windows action
 
0
Karthik
 
 
Answer
use, Static method of JFrame called setDefaultCloseoperation
()and pass the arguments as ONE of follows :
        Arguments               Description

 1.JFrame.EXIT_ON_CLOSE  Exits the application.             
 2. JFrame_HIDE_ON_CLOSE  closes the clicked frame   
                     window,not the application.            
For example,
   class Frame1 extends JFrame{
      public Frame1(){
           super(" FrameTest ");
           setSize(400,340);
           setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
           setVisible(true);
            }
           }
 
0
Ayyappan Raja
 
 
Question
how to give transparency to JComboBox,JList and JTable
Rank Answer Posted By  
 Question Submitted By :: Hareesh@elitekraft
This Interview Question Asked @   Ness-Technologies
I also faced this Question!!   © ALL Interview .com
Answer
by setOpaque(false)
 
0
Leosun
 
 
Question
How to merging the particular cells in JTable
Rank Answer Posted By  
 Question Submitted By :: Hareesh.b
I also faced this Question!!   © ALL Interview .com
Answer
TableCellRenderer renderer = aColumn.getHeaderRenderer();
or u can modify the code
TableCellRenderer renderer = header.getDefaultRenderer();
 
0
Chaitanya
 
 
Question
how to give transparency for JComboBox,JListBox and JTable
Rank Answer Posted By  
 Question Submitted By :: Hareesh .b
I also faced this Question!!   © ALL Interview .com
Answer
setOpaque(false)
 
0
Me
 
 
Question
how can u handle runtime exceptions in java plz explain 
with examples briefly?
Rank Answer Posted By  
 Question Submitted By :: Jawahar
This Interview Question Asked @   Fujitsu , IBM
I also faced this Question!!   © ALL Interview .com
Answer
You can catch runtime exceptions in try catch  block but 
generally runtime exceptions are unchecked exceptions and 
are not in control of a candidate to handle
 
0
Kamal
 
 
Answer
You can catch compile time Exception,with using try and
catch or throws keyword,Buti think if u r going to catch
Runtime Exception then no,meaning bcoz Runtime Exception are
unchecked
exception.Means no meaning of try and catch but u can use.
 
0
Manish
 
 
Question
what is difference between checked and unchecked exception 
plz explain examples ?
Rank Answer Posted By  
 Question Submitted By :: Jawahar
This Interview Question Asked @   Fujitsu
I also faced this Question!!   © ALL Interview .com
Answer
CHECKED EXCEPTION IS TO BE HANDLED BY USE TRY AND CATCH
EXCEPTION....THAT HAS TO BE THROWN AND CATCH USEING THIS
EXCEPTION...WERE AS UNCHECKED EXCEPTION IS RUN TIME EXCEPTION.  
THIS EXCEPTION IS NOT CHECKED AT THE TIME OF COMPILATION
HENCE IT CANNOT BE HANDLED WITH TRY AND CATCH.....
 
0
Vijay
 
 
Answer
A checked exception is one, which a block of code is likely
to throw, and represented by throws clause.It represents
invalid conditions in areas outside the immediate control of
the program (invalid user input, database problems, network
outages, absent files).
In Java it is expected that a method 'throws' an exception
which is a checked exception.They are subclasses of Exception.
While unchecked exceptions represent defects in the program
(often invalid arguments passed to a non-private method).
According to definition in The Java Programming Language, by
Gosling, Arnold, and Holmes,"Unchecked runtime exceptions
represent conditions that, generally speaking, reflect
errors in your program's logic and cannot be reasonably
recovered from at run time." They are subclasses of
RuntimeException, and are usually implemented using
IllegalArgumentException, NullPointerException, or
IllegalStateException
It is somewhat confusing, but note as well that
RuntimeException (unchecked) is itself a subclass of
Exception (checked)
 
0
Rakesh
 
 
Question
what do u mean by GUI framework
Rank Answer Posted By  
 Question Submitted By :: Vadhani24
I also faced this Question!!   © ALL Interview .com
Answer
GUI provide a "picture-oriented" or "Graphical" way of 
interacting with the system.They are easy to learn and 
use.Microsoft Windows which supports GUI.As of today,all 
operating systems provides a Graphical user 
Interface.Application use the elements of GUIs that come 
with the operating system and add their own elements.The 
elements of a GUI include windows,drop-down menus, 
buttons,scroll bars,iconic images.
 
0
Mita Swain
 
 
Question
what do u mean by GUI framework
Rank Answer Posted By  
 Question Submitted By :: Guest
I also faced this Question!!   © ALL Interview .com
Answer
It provides you the better look & feel.UI is desgned by awt 
and swing component however swing component GUI is more 
powerfull than awt.Through the GUI user can intract with 
easily.
 
0
Arshad Ahmad
 
 
Question
when we right click on the JTable using mouse it works 
properly but how to right click on JTable in java using 
keyboard what should be the code for the same.....?

Thanks
Nitin
Rank Answer Posted By  
 Question Submitted By :: Nitin
I also faced this Question!!   © ALL Interview .com
Answer
public void mouseClicked(MouseEvent e)
	{
		if(e.getButton()==e.BUTTON3)
    JOptionPane.showMessageDialog(null, "Mouse right
click");     

}

With the help of above u can easily get when you right click
on jtable
 
0
Santro
 
 
Question
what is the diff's between swing and applet?
Rank Answer Posted By  
 Question Submitted By :: Guest
This Interview Question Asked @   Patni
I also faced this Question!!   © ALL Interview .com
Answer
Swing is a light weight component whereas Applet is a heavy 
weight Component..Applet Does not require main 
method ,instead it needs init method.
 
0
Jeena Joy
 
 
Answer
Swing is a set of classes under JFC that provide 
lightweight visual component , enable creation of 
attractive GUI. But Applet is heavyweight component and 
needs web browser or tool known as AppletViewer.

Applet have no main method, but swing have.
 
0
Bindhu
 
 
Answer
swing is a light wight component.
 
0
Manikandan
 
 
Answer
Component
Swing :Swing is light weght Component
Applet : Applet is heavy weight Components

Look and feel 
Swing: Using UIManager swing have look and feel according 
to user view u can change look and feel 
Applet: Applet Does not provide this facility 

Compile 
Swing : swing uses for stand lone Applications ,Swing 
have   main method to execute the program
Applet : Applet need HTML code for Run the Applet 

Swing : uses MVC Model view Controller 
Applet : not 

Swing : swing have its own Layout ..like most popular Box 
Layout
Applet : Applet uses Awt Layouts..like flowlayout

Thread 
Swing :Swing have some Thread rules 
Applet :There is no any rule
 
0
Sidhu
 
 
Answer
Swing : heavy weight
Applet : light weight
 
0
Imlepakshi
 
 
Answer
Apple :to execute Applet programe we should need any one 
browser like Appletviewer,web browser.
Because Applet using browser container to run and all 
action control with in browser container

swing :to execute swing no need any browser By which we can 
create stand alone application
But Here we have to add container and maintain all action 
control with in frame container


Applet : we dependent on brower to execute and action


swing : own 

simply Instance problem
 
5
Karthik
 
 
Answer
applet: the components of applet are from underlying 
operating system .
swing : Swing creates its own component.
 
0
Madhavsingh
 
 
Question
What is the difference between AWT & Swing?
Rank Answer Posted By  
 Question Submitted By :: Guest
This Interview Question Asked @   Deshaw , Bebo
I also faced this Question!!   © ALL Interview .com
Answer
AWT are heavy weight components while Swing are light 
weight components.
 
1
Guest
 
 
Answer
AWT are heavy weight components while Swing are light 
weight components.

Light weight components have transparent pixels where as 
heavy weight is always opaque.

Light weight components are non-rectangular.Heavy weight 
components are rectangular
 
0
G.lakshmi
 
 
Answer
AWT are heavy weight components while Swing are light 
weight components
 
0
Sanjeev
 
 
Answer
AWT are heavy weight components whereas swing is a light 
weight component because the swings are not platform 
specific.
 
0
Tina
 
 
Answer
Most of the issues related to mixing AWT and Swing 
components are related  to the mixing of so-called 
heavyweight and lightweight components.  A heavyweight 
component is one that is associated with its own  native 
screen resource (commonly known as a peer). A lightweight 
component is one that "borrows" the screen resource of an 
ancestor  (which means it has no native resource of its 
own -- so it's "lighter").

(Lightweight component support was introduced in JDK1.1, 
and you can  read more about it in the 

We generally don't recommend mixing Swing and AWT 
components because  there are significant benefits in 
sticking with programs that are written  entirely in Swing 
(and thus use only lightweight components).
Some of the benefits of using Swing components are: 
 	More efficient use of resources: Lightweight 
components are  really "lighter" than heavyweight 
components. 
 	More consistency across platforms because Swing is 
written  entirely in Java. 
 	Cleaner look-and-feel integration: You can give a 
set of components  a matching look-and-feel by implementing 
them using Swing. 
Despite the benefits of using Swing components exclusively, 
a developer  may sometimes have to mix AWT components and 
Swing components in the same  program (even when migration 
is not to blame). For example, such mixing  may be required 
when a Swing version of a particular AWT component is  not 
yet available.
Because there's sometimes no alternative to mixing 
heavyweight and lightweight  components, we have provided a 
few options in Swing to make a certain  level of component-
mixing possible. However, as anyone who has tried this  
approach knows, there are some practical limitations to 
this approach

There are some significant differences between lightweight 
and heavyweight  components. And, since all AWT components 
are heavyweight and all Swing  components are lightweight 
(except for the top-level ones: JWindow, JFrame,  JDialog, 
and JApplet), these differences become painfully apparent 
when  you start mixing Swing components with AWT components.
 
0
Harivardhan.a
 
 
Answer
The classes contained in the java.awt package provide a
basic capability to create graphical user interfaces, but
the scope of the tools contained in java.awt is limited.
Furthermore, the actual implementation of the components is
done in a language other than Java, and the look and
behavior of the components is somewhat dependent on the
runtime platform's native environment. AWT components might
act slightly differently on a UNIX system than they would on
a PC.

The Swing classes are the next-generation (Java 2) GUI
classes. They provide a number of new components including
trees, tables, and tooltips, etc. Swing components are
written entirely in Java...

You can read more about swing here :
www.roseindia.net/java/example/java/swing/
 
0
Hemz
 
 
Question
what are the root classes of  all classes?
Rank Answer Posted By  
 Question Submitted By :: Lml_1216
I also faced this Question!!   © ALL Interview .com
Answer
API(applicaton programming interface)
 
1
Dreams
 
 
Answer
Object is the root class of all classes
 
4
Aishwarya
[Infotrack]
 
 
Answer
object class :)
 
0
Jack
[Infotrack]
 
 
Answer
Object class is a base class of all java classes

in frame work(api) level clsses are root classes of all 
clasees
 
0
Aravam Siva
[Infotrack]
 
 
Question
What is the use of JTree?
Rank Answer Posted By  
 Question Submitted By :: Guest
I also faced this Question!!   © ALL Interview .com
Answer
JTree is one of component which is used to display the 
items in tree view.
 
4
Ashokmail.java@gmail.com
 
 
Answer
Jtree is a tree wich is used to disply the items in tree 
view.
 
0
Nagesh
 
 
 
Back to Questions Page
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com