How do we trigger painting from within the application (not system-triggered)? T
ID: 3829400 • Letter: H
Question
How do we trigger painting from within the application (not system-triggered)? Throughout the life time of a Java applet, about how often init() is called? Fill in the blank to indicate the event listener you use based on our class note (ca sensitive) a. JButton _____ b. JCheckBox _____ c. JList _____ d. JSlider _____ e. JMenuItem ____ Explain the difference between implementing ActionListener and implementing ItemListener for JComboBox? What is the benefit of inheriting an event adapter instead of implemeting MouseListener or Key Listener? Describe how JMenu, JMenuBar, and JMenultem are related.Explanation / Answer
3ans)the init() method in applet is called axcatly once in his life time..init() is nothing but initialization of resources..when an applet is loaded the init method is called and all the resoureces recured for that applet to exceuted are loaded like images etc.
4ans)
a...JButton:Action Listener is responsible for to perform event when button is pressed..when button is pressed then Action Listener interface exceutes
Action Performed method.
JButton comes under Swing and Button comes under AWT(abstract window tool kit)
b....JCheckBox:ItemListener and ActionListener is used for JCheckbox.
c....JList:ListSelectionListener is used for JList
d....JSlider:ChangeLister interface is used to for JSlider ...Statechangedmethod() should be override
e...JMenuItem:ActionListener interface is used and actionperformed() metod need to be override.
5ans)difference between Action Listener and Item Listener..
purpose of Action Listener and Item Listener is same in the case of JCheckbox..
both have same functionlality..
J in JCheckbox states that it is a swing component..
itemlistener is triggered when we call setselection method() true..
ActionListener is triggered when we call action performed method.
6 ans)the advantages of inherting event adapter are;
it makes the classes to use again and again...reusable..
it provided added plugg tool kit to add extra for aplication development..
classes transpareancy can be increase
7ans)JMenu is a Swing componenet in java..it is used for creating a menu ..and jmenuitems are items that are need to be added in menu...the list of items which we want to view in menu should be created in jmenuitems and added to menu..
and menu bar is a top level window..
jmenubar object is used for displaying a menu in frame..the jmenu is a pulldown compoment which is displayed on jmenubar..and finally jmenuitems class adds a menu item
1ans)in AWT there are 2 types of painting operations
system trigger
application trigger
in system trigger painting the system request the component to render it s components.
in application trigger painting the component itself decides need of updates
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.