• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

some queries pl!

 
Ranch Hand
Posts: 153
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi all! here are some queries. pl try to solve these!
thanx.
ashok.
________________
[1]why does the following code not exit when run? for coming out, u need to press Ctrl C.
import java.awt.*;
public class MyClass {
public static void main(String args[]) {
TextArea ta = new TextArea();
}
}
--------------------------------------------
[2]True or False:
A given MouseEvent CANNOT be dispatched to both MouseMotionListener and MouseListener objects that have registered with the screen component.
-----------------------------------------------
[3]True or False:Only Frames can contain menu bars or pull-down menus.
-----------------------------------------------
[4]What is the target in an Event?
A. The Object() where the event came from.
B. The Object() where the event is destined for.
C. What the Object() that generated the event was doing.
-----------------------------------------------
[5] The following will add a Component 'comp' to a container 'c', if it's layout is governed by GridLayout 'g'?
g.addLayoutComponent("ComponentName",comp);
** can u pl explain the above method? it's from some mock-exam..i didn't get it.
-----------------------------------------------
[6] Can u pl tell what does the statement at //3 actually do(in a general way)?
import java.awt.*;
public class TestClass extends Frame
{
Button b = new Button("OK");
TestClass( )
{
add("South", b);
this.setSize(400, 400); //1
b.setVisible(true); //2)
this.getLayout().layoutContainer(this); //3
this.setVisible(true); //4
}
public static void main(String[] args)
{
new TestClass();
}
}
 
Ranch Hand
Posts: 2166
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi ashok,
really dificult questions. Real exam is much simpler!!!
[3]True or False:Only Frames can contain menu bars or pull-down menus.
THINK True. Applets dont has, Dialog dont has, Panel dont has.
[5]g.addLayoutComponent("ComponentName",comp)
FALSE
There is a method with this name in api-doc. But you add the specified component to the layout. Can't see any container.
[6] this.getLayout().layoutContainer(this); //3
The line does does not change anything.
getLayout() --> get Object of Type LayoutManager.
Should be the default Layout Manager of Frame, because you did not specify any.
Object_LayoutManager.layoutContainer(this) --> set Container Frame as layout Container.
Frame was allready the Container.
Correct me if i am wrong
SCJP Axel
 
Author & Gold Digger
Posts: 7617
6
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi both,
[1] I think (but I'm not sure) that since you use an AWT component, the GUI thread will be started and the main thread will only stop when the GUI thread stops.
Anyone comment on this please
[2] What is a screen component ??? Anyway ! If you have a MouseEvent object you can use it for both MouseListeners and/or MouseMotionListeners, I don't see why you could not ! Answer is False.
[3] True, only Frames may contain menu bars or pull-down menus ! setMenuBar only exists in the class Frame.
[4] I think the answer is B, the target is the Object to which the event is destined in other words the EventListener that registered with the event source to receive that kind of Event.
[5] The answer is true, since the question says that there is a container whose layout is governed by the GridLayout which is a LayoutManager. So adding some component to a LayoutManager owned by a container will effectively add the component to the container but after the LayoutManager has layed out all added components. Jana Griscti has good notes on this at the following address http://members.home.net/jgriscti/awt.html
[6] Frame is a container, so by executing line 3 it tells its LayoutManager that now it's the time to lay the components out and display them. So this.getLayout() will return the LayoutManager of the Frame (in this case an instance of BorderLayout) and then invoking layoutContainer(this) upon the instance of the layout will pass this container (i.e. the Frame) to the LayoutManager and lay it out so that the component (the button) will be displayed according to the BorderLayout policies !
If you feel something is not clear, let me know
Val
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic