单选题Given an ActionEvent, which method allows you to identify the affected Component?()APublic class getClass()BPublic Object getSource()CPublic Component getSource()DPublic Component getTarget()EPublic Component getComponent()FPublic Component getTargetCo

题目
单选题
Given an ActionEvent, which method allows you to identify the affected Component?()
A

 Public class getClass()

B

 Public Object getSource()

C

 Public Component getSource()

D

 Public Component getTarget()

E

 Public Component getComponent()

F

 Public Component getTargetComponent()


相似考题
更多“单选题Given an ActionEvent, which method allows you to identify the affected Component?()A  Public class getClass()B  Public Object getSource()C  Public Component getSource()D  Public Component getTarget()E  Public Component getComponent()F  Public Component”相关问题
  • 第1题:

    本题的功能是在文本域面板中添加一个带有行数的面板。窗口中有一个文本域,在文本域的左侧有一个带有数字的面板,该面板上的数字指示着文本域中的行数。

    import javax.swing.*;

    import javax.swing.event.*;

    import java.awt.*;

    public class java3 extends JFrame

    {

    public static JTextPane textPane;

    public static JScrollPane scrollPane;

    JPanel panel;

    public java3()

    {

    super("java3()");

    panel=new JPanel();

    panel.setLayout(new BorderLayout());

    panel.setBorder(BorderFactory.createEmptyBor-

    der(20,20,20,20));

    textPane=new JTextPane();

    textPane.setFont(new Font("monospaeed",

    Font.PLAIN,12));

    scrollPane=new JScrollPane(textPane);

    panel.add(scrollPane);

    scrollPane.setPreferredsize(new Dimension(300,

    250));

    setContentPane(panel);

    setCloseOperation(JFrame.EXIT_ON_CLOSE);

    LineNumber lineNumber=new LineNumber();

    scrollPane.setRowHeaderView(lineNumber);

    }

    public static void main(String[]args)

    {

    java3 ttp=new java3();

    ttp.pack();

    ttp.setVisible(true);

    }

    }

    class LineNumber extends JTextPane

    {

    private final static Color DEFAULT_BACK-

    GROUND=Color.gray;

    private final static Color DEFAULT_FORE-

    GROUND=Color.black;

    private final static Font DEFAUl。T—FONT=new

    Font("monospaced",Font.PLAIN,12);

    private final static int HEIGHT=Integer.MAX_

    VALUE-1000000;

    private final static int MARGIN=5;

    private FontMetrics fontMetrics;

    private int lineHeight;

    private int currentRowWidth;

    private JComponent component;

    private int componentFontHeight;

    private int componentFontAscent;

    public LineNumber(JComponent component)

    {

    if(component= =null)

    {

    setBackground(DEFAULT_BACKGROUND);

    setForegroun"DEFAULT_FOREGROUND);

    setFont(DEFAULT FONT);

    this.component=this;

    }

    else

    {

    setBaekground(DEFAULT_BACKGROUND);

    setForeground(component.getForeground());

    setFont(component.getFont());

    this.component=component;

    }

    componentFontHeight=component.getFontMet-

    rics(component.getFont()).getHeight();

    componentFontAscent=component.getFontMet-

    ries(component.getFont()).getAscent();

    setPreferredWidth(9999);

    }

    public void setPreferredWidth(int row)

    {

    int width=fontMetrics.stringWidth(String.val-

    ueOf(row));

    if(currentRowWidth<;width)

    {

    currentRowWidth=width;

    setPreferredSize(new Dfimension(2 * MARGIN

    +width,HEIGHT));

    }

    }

    public void setFont(Font font)

    {

    super.setFont(font);

    fontMetrics=getFontMetrics(getFont());

    }

    public int getLineHeight()

    {

    if(hneHeight= =0)

    return componentFontHeight;

    else

    return lineHeight;

    }

    public void setLineHeight(int lineHeight)

    {

    if(hneHeight>;0)

    this.lineHeight=lineHeight;

    }

    public int getStartOffset()

    {

    return component.getlnsets().top+component-

    FontAscent;

    }

    public void paintComponent(Graphics g)

    {

    int lineHeight=getLineHeight();

    int startOffset=getStartOffset();

    Rectangle drawHere=g.getClipBounds();

    g.setColor(getBackground());

    g.fillRect(drawHere.x,drawHere.Y,drawHere.

    width,drawHere.height);

    g.setColor(getForeground());

    int startLineNumber=(drawHere.y/line-

    Height)+1;

    int endLineNUmber = startLineNumber+

    (drawHere.height/lineHeight);

    int start=(drawHere.Y/hneHeight)*line-

    Height+startOffset;

    for(int i=startLineNumber;i<;=endLineN-

    umber;i++)

    {

    String lineNumber=String.valueOf(i);

    int width=fontMetrics.stringWidth(lineNumber

    );

    g.drawstring(lineNumber,MARGIN+current-

    RowWidth-width,start);

    start+=lineHeight:

    }

    setPreferredWidth(endLineNumber);

    }

    }


    正确答案:
    第1处:scrollpane.setPreferredSize(newDimension(300,250))第2处:setDefauhCloseOperation(JFrame.EXIT_ON_CLOSE)第3处:LineNumberLineNumber=newLineNumber(textPane)【解析】第1处Java是大小写敏感的;第2处设置窗口关闭方式应使用setDefauhCloseOperation()方法;第3处从下面的publicLineNumber(JComponentcomponent)可以看出LineNumber()需要JComDonent型参数。

  • 第2题:

    class super {   public float getNum() {return 3.0f;}   }   public class Sub extends Super {   }   Which method, placed at line 6, will cause a compiler error?()

    • A、 Public float getNum() {return 4.0f; }
    • B、 Public void getNum (){}
    • C、 Public void getNum (double d){}
    • D、 Public double getNum (float d) {retrun 4.0f; }

    正确答案:B

  • 第3题:

    Which two allow the class Thing to be instantiated using new Thing()?

    • A、 public class Thing { }
    • B、 public class Thing { public Thing() {} }
    • C、 public class Thing { public Thing(void) {} }
    • D、 public class Thing { public Thing(String s) {} }
    • E、 public class Thing { public void Thing() {} public Thing(String s) {} }

    正确答案:A,B

  • 第4题:

    下列代码正确的是哪项?() 

    • A、 public class Session implements Runnable, Clonable{   public void run ();public Object clone () ; }
    • B、 public class Session extends Runnable, Cloneable {  public void run() {/*dosomething*/}       public Object clone() {/*make a copy*/} }
    • C、 public abstract class Session implements Runnable, Clonable {       public void run() {/*do something*/}       public Object clone() {/*make a copy*/}        }
    • D、 public class Session implements Runnable, implements Clonable {       public void run() {/*do something*/}       public Object clone() {/*make a copy*/}       }

    正确答案:C

  • 第5题:

    public class Score implements Comparable {  private int wins, losses;  public Score(int w, int 1) { wins = w; losses = 1; }  public int getWins() { return wins; }  public int getLosses() { return losses; }  public String toString() {  return “<“ + wins + “,“ + losses + “>”; }  // insert code here  }  Which method will complete this class?() 

    • A、 public int compareTo(Object o) {/*mode code here*/}
    • B、 public int compareTo(Score other) {/*more code here*/}
    • C、 public int compare(Score s1,Score s2){/*more code here*/}
    • D、 public int compare(Object o1,Object o2){/*more code here*/}

    正确答案:B

  • 第6题:

    Which two demonstrate an “is a” relationship?()   

    • A、 public interface Person { }  public class Employee extends Person { }
    • B、 public interface Shape { }  public class Employee extends Shape { }
    • C、 public interface Color { }  public class Employee extends Color { }
    • D、 public class Species { }  public class Animal (private Species species;)
    • E、 interface Component { }  Class Container implements Component ( Private Component[ ] children;  )

    正确答案:D,E

  • 第7题:

    Given an ActionEvent, which method allows you to identify the affected Component?()  

    • A、 Public class getClass()
    • B、 Public Object getSource()
    • C、 Public Component getSource()
    • D、 Public Component getTarget()
    • E、 Public Component getComponent()
    • F、 Public Component getTargetComponent()

    正确答案:B

  • 第8题:

    多选题
    Which two demonstrate an “is a” relationship?()
    A

    public interface Person { }  public class Employee extends Person { }

    B

    public interface Shape { }  public class Employee extends Shape { }

    C

    public interface Color { }  public class Employee extends Color { }

    D

    public class Species { }  public class Animal (private Species species;)

    E

    interface Component { }  Class Container implements Component ( Private Component[ ] children;  )


    正确答案: E,B
    解析: 暂无解析

  • 第9题:

    单选题
    Which method must be defined by a class implementing the java.lang.Runnable interface? ()
    A

     void run()

    B

     public void run()

    C

     public void start()

    D

     void run(int priority)

    E

     public void run(int priority)

    F

     public void start(int priority)


    正确答案: A
    解析: 暂无解析

  • 第10题:

    单选题
    下列代码正确的是哪项?()
    A

     public class Session implements Runnable, Clonable{   public void run ();public Object clone () ; }

    B

     public class Session extends Runnable, Cloneable {  public void run() {/*dosomething*/}       public Object clone() {/*make a copy*/} }

    C

     public abstract class Session implements Runnable, Clonable {       public void run() {/*do something*/}       public Object clone() {/*make a copy*/}        }

    D

     public class Session implements Runnable, implements Clonable {       public void run() {/*do something*/}       public Object clone() {/*make a copy*/}       }


    正确答案: A
    解析: 暂无解析

  • 第11题:

    多选题
    Which the two demonstrate an “is a” relationship?()
    A

    public interface Person {}  Public class Employee extends Person {}

    B

    public interface Shape {}  public interface Rectangle extends Shape {}

    C

    public interface Color {}  public class Shape { private Color color; }

    D

    public class Species {}  public class Animal { private Species species; }

    E

    interface Component {} Class Container implements Component {private Component [] children;


    正确答案: A,C
    解析: 暂无解析

  • 第12题:

    多选题
    Which three demonstrate an “is a” relationship?()
    A

    public class X {  }     public class Y extends X { }

    B

    public interface Shape { }     public interface Rectangle extends Shape{ }

    C

    public interface Color { }     public class Shape { private Color color; }

    D

    public interface Species { }     public class Animal { private Species species; }

    E

    public class Person { }    public class Employee {      public Employee(Person person) { }

    F

    interface Component { }     class Container implements Component {   private Component[] children; }


    正确答案: E,B
    解析: 暂无解析

  • 第13题:

    阅读下列函数说明和C++代码,将应填入(n)处的字句写在对应栏内。

    [说明]

    在销售系统中常常需要打印销售票据,有时需要在一般的票据基础上打印脚注。这样就需要动态地添加一些额外的职责。如下展示了Decorator(修饰)模式。SalesOrder对象使用一个SalesTicket对象打印销售票据,先打印销售票据内容,然后再打印脚注。图5-1显示了各个类间的关系。以下是C++语言实现,能够正确编译通过。

    [图5-1]

    [C++代码]

    class Component{

    public:

    (1) void prtTicket()=0;

    };

    class SalesTicket:public Component{

    public:

    void prtTicket(){

    cout<<"Sales Ticket!"<<endl;

    }

    };

    class Decorator:public Component{

    public:

    virtual void prtTicket();

    Decorator(Component *myC);

    private:

    (2) myComp;

    };

    Decorator::Decorator(Component *myC)

    {

    myComp=myC;

    }

    void Decorator::prtTicket()

    {

    myComp->prtTicket();

    }

    class Footer:public Decorator{

    public:

    Footer(Component *myC);

    void prtTicket();

    void prtFooter();

    };

    Footer::Footer(Component *myC): (3) {}

    void Footer::prtFooter()

    {

    cout<<"Footer"<<endl;

    }

    void Footer::prtTicket()

    {

    (4) ;

    prtFooter();

    }

    class SalesOrder{

    public:

    void prtTicket();

    };

    void SalesOrder::prtTicket()

    {

    Component *myST;

    myST=new Footer( (5) );

    myST->prtTicket();

    }

    (1)


    正确答案:virtual
    virtual

  • 第14题:

    Which three demonstrate an “is a” relationship?() 

    • A、 public class X {  }     public class Y extends X { }
    • B、 public interface Shape { }     public interface Rectangle extends Shape{ }
    • C、 public interface Color { }     public class Shape { private Color color; }
    • D、 public interface Species { }     public class Animal { private Species species; }
    • E、 public class Person { }    public class Employee {      public Employee(Person person) { }
    • F、 interface Component { }     class Container implements Component {   private Component[] children; }

    正确答案:A,B,F

  • 第15题:

    A JavaBeans component has the following field:  11. private boolean enabled;  Which two pairs of method declarations follow the JavaBeans standard for accessing this field?()

    • A、 public void setEnabled( boolean enabled) public boolean getEnabled()
    • B、 public void setEnabled( boolean enabled) public void isEnabled()
    • C、 public void setEnabled( boolean enabled) public boolean isEnabled()
    • D、 public boolean setEnabled( boolean enabled) public boolean getEnabled()

    正确答案:A,C

  • 第16题:

    class One {   public One foo() { return this; }  }  class Two extends One {  public One foo() { return this; }  }  class Three extends Two {   // insert method here  }  Which two methods, inserted individually, correctly complete the Three class?()

    • A、 public void foo() { }
    • B、 public int foo() { return 3; }
    • C、 public Two foo() { return this; }
    • D、 public One foo() { return this; }
    • E、 public Object foo() { return this; }

    正确答案:C,D

  • 第17题:

    Which the two demonstrate an “is a” relationship?()

    • A、 public interface Person {}  Public class Employee extends Person {}
    • B、 public interface Shape {}  public interface Rectangle extends Shape {}
    • C、 public interface Color {}  public class Shape { private Color color; }
    • D、 public class Species {}  public class Animal { private Species species; }
    • E、 interface Component {} Class Container implements Component {private Component [] children;

    正确答案:B,E

  • 第18题:

    1. class super {  2. public float getNum() {return 3.0f;}  3. }  4.    5. public class Sub extends Super { 6.   7. }   Which method, placed at line 6, will cause a compiler error?()  

    • A、  Public float getNum()   {return 4.0f; }
    • B、  Public void getNum ()  { }
    • C、  Public void getNum (double d)   { }
    • D、  Public double getNum (float d) {retrun 4.0f; }

    正确答案:B

  • 第19题:

    Given the ActionEvent, which method allows you to identify the affected component?()

    • A、 GetClass.
    • B、 GetTarget.
    • C、 GetSource.
    • D、 GetComponent.
    • E、 GetTargetComponent.

    正确答案:C

  • 第20题:

    单选题
    Given the ActionEvent, which method allows you to identify the affected component?()
    A

     GetClass.

    B

     GetTarget.

    C

     GetSource.

    D

     GetComponent.

    E

     GetTargetComponent.


    正确答案: D
    解析: 暂无解析

  • 第21题:

    单选题
    class super {   public float getNum() {return 3.0f;}   }   public class Sub extends Super {   }   Which method, placed at line 6, will cause a compiler error?()
    A

     Public float getNum() {return 4.0f; }

    B

     Public void getNum (){}

    C

     Public void getNum (double d){}

    D

     Public double getNum (float d) {retrun 4.0f; }


    正确答案: C
    解析: 暂无解析

  • 第22题:

    多选题
    A JavaBeans component has the following field:  11. private boolean enabled;  Which two pairs of method declarations follow the JavaBeans standard for accessing this field?()
    A

    public void setEnabled( boolean enabled) public boolean getEnabled()

    B

    public void setEnabled( boolean enabled) public void isEnabled()

    C

    public void setEnabled( boolean enabled) public boolean isEnabled()

    D

    public boolean setEnabled( boolean enabled) public boolean getEnabled()


    正确答案: C,D
    解析: 暂无解析

  • 第23题:

    单选题
    public class Score implements Comparable {  private int wins, losses;  public Score(int w, int 1) { wins = w; losses = 1; }  public int getWins() { return wins; }  public int getLosses() { return losses; }  public String toString() {  return “”; }  // insert code here  }  Which method will complete this class?()
    A

     public int compareTo(Object o) {/*mode code here*/}

    B

     public int compareTo(Score other) {/*more code here*/}

    C

     public int compare(Score s1,Score s2){/*more code here*/}

    D

     public int compare(Object o1,Object o2){/*more code here*/}


    正确答案: B
    解析: 暂无解析

  • 第24题:

    单选题
    Given an ActionEvent, which method allows you to identify the affected Component?()
    A

     Public class getClass()

    B

     Public Object getSource()

    C

     Public Component getSource()

    D

     Public Component getTarget()

    E

     Public Component getComponent()

    F

     Public Component getTargetComponent()


    正确答案: B
    解析: 暂无解析