问题 问答题

【说明】
下面是一个Applet程序,其功能是建立一个图形用户界面的窗口,包括一个文本显示区和一个按钮,点击按钮,可以在文本区已有的文本基础上追加显示10条"Welcome to China"信息,并且文本区由滚动条控制文本的上下滚动。
程序运行结果如图4所示。
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
/*
<appletcode="ex5_6.class" width=800 height=400>
</applet>


*/
public class ex5_6 extends JApplet
JButton jb=new JButton("Add Text");
JTextPane jtp=new JTextPane();
public void init()
jb.addActionListener(new ActionListener())
public void actionPerformed(ActionEvent e)
for(int i =1;i < 10;i++)
(1) +" Welcome to China!\n";


Container cp= (2)
cp.add(new JScrollPane(jtp));
cp.add( (3) );

public static void main (String[] args)
ex5_6 obj5_6=new ex5_6();
String str=obj5_6.getClass().toString();
if(str.indexOf("class")!=-1)
str=str.Substring(6);
JFrame frm=new JFrame(str);
frm.addWindowListener(new (4)
public void windowClosing(WindowEvent we)
System.exit(0);

);
(5) .add(ex5_6);
frm.setSize(300,400);
frm.setVisble(true);


ex5_6.htm|
<HTML>
<HEAD>
<TITLE>ex5_6</TITLE>
</HEAD>
<BODY>
<appletcode="ex5_6.class" Width=800 height=400>
</applet>
</BODY>
</HTML>

答案

参考答案:(1)jtp.setText(jtp.getText() (2)getContentPane()
(3)BorderLayout.SOUTH,jb
(4)WindowsAdapter() (5)frm.getContentPane()

解析: 本题主要考查Applet和swing结合进行图形用户界面设计的综合应用。解题关键是掌握swing的基本构件JTextPanel,JButton, JScrollPanel的用法,掌握BorderLayout布局管理器的使用方法,以及熟练掌握最基本的对象概念。本题中,JTextPanel的2个基本的方法,set- Text()和getText()的功能,熟悉这2个功能,则很容易就能将错误改正;应该是通过BorderLayout布局管理器在窗口的最下方添加一个 JButton对象,需要清楚程序中每个对象所对应的类。

单项选择题

When we think of leadership, we often think of strength and power. But what are these really, and how do they operate
Leadership today is not about forcing others to do things. If this is even possible, it is short term, and tends to backfire. If you order someone to do something against their will, they may do it because they feel they must, but the anger they feel will do more harm in the long term. They will also experience fear.
Fear causes the thinking brain to shut down, making the person unable to function at his or her best. If they associate you with this emotion of fear, they will become less functional around you, and you will have succeeded in not only shooting yourself in the foot, but possibly making a very good employee or partner unable to perform effectively. Fear has no place in leadership.
The way we influence people in a lasting way is by our own character, and our understanding and use of emotion. We can order someone to do something, which may be part of the workday; or we can employ them at the emotional level, so they become fully devoted to the projects and provide some of their own motivation. Today’s workplace is all about relationships as a human being as well as a worker. Everyone produces just a bit more for someone they like. Leaders understand the way things work. They know the paycheck is not the single most motivating factor in the work life of most people.
The true strength of leadership is an inner strength that comes from the confidence of emotional intelligence—knowing your own emotions, and how to handle them, and those of others. Developing your emotional intelligence is the single best thing you can do if you want to develop your relationships with people around you, which is the key to the leadership skills.

To positively influence employees a leader should first of all ______.

A. provide better suggestions
B. develop his own personality
C. give his employees a pay raise
D. hide his own emotion of fear

多项选择题