-
[简答题] import javax.swing.*; import java.awt.*;import java.awt.event.*;class MyScrollBar extends JscrollBar{public MyScrollBar(int init, int len, int low, int high){super(JScrollBar. HORIZONTAL, init,len,low,high);}}class MyWindow extends JFrame implements AdjustmentListener{private JTextField text;MyWindow(String s){super(s);MyScrollBar myBar=new MyScrollBar(10,10,0,255);Container con=this. getContentPane();con. setLayout(new GridLayout(2,1));this. setSize(200,100);this. setLocation(100,100);myBar.addAdjustmentListener(this);text=new JTextField("",20);con. add(text);con.add(myBar);this.setVisible(true);}public void adjustmentValueChanged(AdjustmentEvent e){MyScrollBar myBar=(MyScrollBar)e.getAdjustable();text.setText(""+myBar.getValue());}}public class Class1{public static void main(String[]args){MyWindow myWindow=new MyWindow("text5_4");}}
-
-
[简答题] 阅读下列程序,请写出该程序的输出结果。import java.applet.*;import java.awt.*;class Point{int x,y;Point(int xx,int yy){ x=xx;y=yy;}Point(Point p){x=p.x;y=p.y; }void m(int dx,int dy){x+=dx;y+=dy;}}class Circle extends Point{int r;Circle(Point p, int rr){ super(p); r=rr; }float c(){ return 3.14f*2.0f*r; }float a(){ return 3.14f*r*r;}}public class sample extends Applet{Circle yuan; Point d;public void init() {d=new Point(2,5);yuan=new Circle(d,10);}public void paint(Graphics g){g.drawString("yuan Circle"+(int)(yuan.c()*100.0)/100.0,5,20);g.drawString("yuan Area"+(int)(yuan.a()*100.0)/100.0,5,40);}}
-
-
-
-
-
-
-