import java.awt.*; import java.applet.*; import java.lang.*; import ball2; public class ball3 extends ball2{ String stv0,stg,sta,sth,std,stt; TextField tfv0,tfg,tfa,tfh,tfd,tft; public void init(){ /* 初期設定 */ resize( size().width , size().height ); setBackground(Color.white); offs = createImage( size().width , size().height ); grf = offs.getGraphics(); tfv0=new TextField("",8); tfg=new TextField("",8); tfa=new TextField("",8); tfh=new TextField("",8); tfd=new TextField("",8); tft=new TextField("",8); sbv0=new Scrollbar(Scrollbar.HORIZONTAL,0,0,0,100); sbg=new Scrollbar(Scrollbar.HORIZONTAL,0,0,0,500); sba=new Scrollbar(Scrollbar.HORIZONTAL,0,0,0,90); Label mpv=new Label("Present_Value >>>>>>"); setLayout(new BorderLayout());//ボーダーレイアウトに Panel p1 = new Panel();//パネル作製(ボタン・スクロールバー) Panel p2 = new Panel();//パネル作製(高さ・距離表示) p1.setLayout(new GridLayout(4,3,3,0)); p1.add(Restart);//部品をパネルに貼り付け p1.add(Continue); p1.add(Stop); p1.add(tfv0); p1.add(tfg); p1.add(tfa); p1.add(sbv0); p1.add(sbg); p1.add(sba); p1.add(Normal); p1.add(Strobo); p2.add(mpv); p2.add(tfh); p2.add(tfd); p2.add(tft); add("North", p1);//パネルを上に貼り付け add("South", p2);//パネルを下に貼り付け Continue.disable(); Stop.disable(); Normal.disable(); } public void set(){ stv0="Initial_Velocity= "+String.valueOf(v0)+" [m/s]"; stg="Gravity= "+String.valueOf(g/10)+"."+String.valueOf(g%10)+" [m/(s*s)]"; sta="Angle= "+String.valueOf(a)+""; sth="h= "+String.valueOf(y0-y)+" [m]"; std="d= "+String.valueOf(x-x0)+" [m]"; stt="t= "+String.valueOf(t/10)+"."+String.valueOf(t%10)+" [s]"; } public void paint(Graphics g){ if (cho == 1) { grf.setColor(Color.white); grf.fillRect( 0 , 0 , size().width , size().height ); grf.setColor(Color.gray); for (xx=0;xx<= size().width ;xx=xx+x0) { grf.drawLine(xx,0,xx, size().height ); } for (yy=0;yy<= size().height ;yy=yy+x0) { grf.drawLine(0,yy, size().width ,yy); } grf.setColor(Color.black); grf.drawString("0",x0-10,y0+15); grf.drawString("100",x0-25,y0-100+5); grf.drawString("-100",x0-25,y0+100+5); grf.drawString("100",x0+100-12,y0+15); grf.drawString("200",x0+200-12,y0+15); grf.drawString("300",x0+300-12,y0+15); grf.setColor(Color.blue); grf.drawLine(0,y0, size().width ,y0); grf.drawLine(x0,0,x0, size().height ); grf.drawString("h",x0-10,y0-125); grf.drawString("d", size().width -15,y0+15); set(); tfv0.setText(stv0); tfg.setText(stg); tfa.setText(sta); tfh.setText(sth); tfd.setText(std); tft.setText(stt); grf.setColor(Color.red); grf.fillOval(x-r/2,y-r/2,r,r); } if (cho == 2) { if (t % 3 == 1) { grf.setColor(Color.red); grf.fillOval(x-r/2,y-r/2,r,r); } } g.drawImage(offs,0,0,this); } }