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  Contact Us     Login  |  Sign Up                      
tip   To Refer this Site to Your Friends   Click Here
Google
 
Categories >> Software >> Java-Related >> Java-J2EE >> Swing
 
 


 

Back to Questions Page
 
Question
When i m clicking on next another frame is open but i want 
to hide the previous frame...........but it is not 
happening....still both frame are visible........how to 
make one frame to hide.......please help me.......
Rank Answer Posted By  
 Question Submitted By :: Anjani Kumar Jha
I also faced this Question!!   © ALL Interview .com
Answer
The best way to do in such condition is used the Card layout
so that you can easily process next previous function.

If you want to hide the frame, you can use like this

JFrame f1 = new JFrame("Frame 1");
JFrame f2 = new JFrame("Frame 2");

to hide f1, call f1.setVisible(false);
to show f2, call f2.setVisible(true);
 
0
Romesh Nongthombam
 
 
Answer
use dispose(); method
 
0
Anjani Kumar Jha
 
 
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
 
 
Answer
Yes we can do this . Because we can create an object at
runtime and  static block is also execute when a class is
loaded by  the class loader at runtime
 
0
Naresh Tuhania
 
 
Answer
Yes we can create a object in static block.
1- if there is no main method than it will compile easily but at run time it will throw exception 
//Exception in thread "main" java.lang.NoSuchMethodError: 
main
2- if we put main method inside the class then it will compile and run successfully and we will get object.
 
5
Kaushal Mittal
 
 
Answer
Yes we can create a object in static block
EX:-

public class Stobject
{
   static
  {
   Stobject st =new Stobject();
  }
Stobject()
{
System .out.println("object created");
}
  
public static void main(String k[])
{
  System .out.println("HAI");
 }
}
output:-
object created
HAi
 
0
Srinu
 
 
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
 
 
Answer
[Short answer: threads are lightweight, programs (aka
processes or tasks) are heavyweight. -Alex]

Lightweight and heavyweight processes refer the mechanics of
a multi-processing system.

In a lightweight process, threads are used to divvy up the
workload. Here you would see one process executing in the OS
(for this application or service.) This process would posess
1 or more threads. Each of the threads in this process
shares the same address space. Because threads share their
address space, communication between the threads is simple
and efficient. Each thread could be compared to a process in
a heavyweight scenario.

In a heavyweight process, new processes are created to
perform the work in parallel. Here (for the same application
or service), you would see multiple processes running. Each
heavyweight process contains its own address space.
Communication between these processes would involve
additional communications mechanisms such as sockets or pipes.

The benefits of a lightweight process come from the
conservation of resources. Since threads use the same code
section, data section and OS resources, less overall
resources are used. The drawback is now you have to ensure
your system is thread-safe. You have to make sure the
threads don't step on each other. Fortunately, Java provides
the necessary tools to allow you to do this.
 
0
Modi[achir Communication]
 
 
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
 
 
Answer
use setOpaque(false)
 
4
Kukku
[EliteKraft Software Solutions]
 
 
Answer
or more graphically u can use 
means it will give nice looks

setContainer(Image.NULL)
and then use, 
setOpaque(false)
then,
setWindowAdversity(new WindowAdversity(255,255,255))

all the best!!!!!!
 
0
Priya Gupta
[EliteKraft Software Solutions]
 
 
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
This Interview Question Asked @   TCS
I also faced this Question!!   © ALL Interview .com
Answer
setOpaque(false)
 
2
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.....
 
2
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)
 
3
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 , Invictus
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
 
 
Answer
swing:all classes start with J letter
applet:not

swing:componants added on container
applet:no componants addedon container

swing:u can provide tooltiptext to every componants using 
metod setToolTipText();
applet:not
 
0
Rani
 
 
Answer
Swing is lightweigt process and run through main() method 
in case of browser

Applet is heavyweight process and run within only browser 
or with the help of browser
 
0
Vidya Deshmukh
 
 
 
Back to Questions Page
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

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