import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import static java.
lang.
Math.
*;
class MyPanel
extends JPanel { int w, h, h1, hh;
int x0, y0, a, b;
public MyPanel() {
this.w = 500;
this.h = 250;
this.h1 = 25;
this.hh = 50;
}
double y = y0;
for(int tt=0; y>0; tt++) {
double t = tt / 50.d;
double x = x0 + t * a;
y = y0 + t * b - t * t * 9.8 / 2;
g.fillOval(w/2+(int)x, h-hh-(int)y, 2, 2);
}
}
@Override
public void paint
(Graphics g
) { super.paint(g);
g.drawLine(0, h-hh, w, h-hh);
g.drawLine(w/2, h1, w/2, h-hh);
_throw(g);
}
}
MyPanel p;
public MyFrame() {
this.setSize(600, 300);
this.
setDefaultCloseOperation(JFrame.
EXIT_ON_CLOSE); this.setResizable(false);
this.
btnThrow = new JButton("投げる"); this.txtX0.setText("150");
this.txtY0.setText("100");
this.txtA.setText("-20");
this.txtB.setText("10");
this.p = new MyPanel();
p1.add(l1);
p1.add(l2);
p1.add(txtX0);
p1.add(l3);
p1.add(txtY0);
p1.add(l4);
p1.add(l5);
p1.add(txtA);
p1.add(l6);
p1.add(txtB);
p1.add(btnThrow);
p1.add(p);
getContentPane().add(p1);
this.btnThrow.addActionListener(this);
}
p.
x0 = Integer.
parseInt(txtX0.
getText()); p.
y0 = Integer.
parseInt(txtY0.
getText()); p.
a = Integer.
parseInt(txtA.
getText()); p.
b = Integer.
parseInt(txtB.
getText()); p.repaint();
}
}
public class P72_019 {
public static void main
(String[] args
) { new MyFrame().setVisible(true);
}
}
aW1wb3J0IGphdmEuYXd0Lio7CmltcG9ydCBqYXZhLmF3dC5ldmVudC4qOwppbXBvcnQgamF2YXguc3dpbmcuKjsKaW1wb3J0IHN0YXRpYyBqYXZhLmxhbmcuTWF0aC4qOwoKY2xhc3MgTXlQYW5lbCBleHRlbmRzIEpQYW5lbCB7CiAgICBpbnQgdywgaCwgaDEsIGhoOwogICAgaW50IHgwLCB5MCwgYSwgYjsKCiAgICBwdWJsaWMgTXlQYW5lb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ZChsNSk7CiAgICAgICAgcDEuYWRkKHR4dEEpOwogICAgICAgIHAxLmFkZChsNik7CiAgICAgICAgcDEuYWRkKHR4dEIpOwogICAgICAgIHAxLmFkZChidG5UaHJvdyk7CiAgICAgICAgcDEuYWRkKHApOwogICAgICAgIGdldENvbnRlbnRQYW5lKCkuYWRkKHAxKTsKICAgICAgICB0aGlzLmJ0blRocm93LmFkZEFjdGlvbkxpc3RlbmVyKHRoaXMpOwogICAgfQoKICAgIEBPdmVycmlkZSBwdWJsaWMgdm9pZCBhY3Rpb25QZXJmb3JtZWQoQWN0aW9uRXZlbnQgZSkgewogICAgICAgIHAueDAgPSBJbnRlZ2VyLnBhcnNlSW50KHR4dFgwLmdldFRleHQoKSk7CiAgICAgICAgcC55MCA9IEludGVnZXIucGFyc2VJbnQodHh0WTAuZ2V0VGV4dCgpKTsKICAgICAgICBwLmEgID0gSW50ZWdlci5wYXJzZUludCh0eHRBLmdldFRleHQoKSk7CiAgICAgICAgcC5iICA9IEludGVnZXIucGFyc2VJbnQodHh0Qi5nZXRUZXh0KCkpOwogICAgICAgIHAucmVwYWludCgpOwogICAgfQp9CgpwdWJsaWMgY2xhc3MgUDcyXzAxOSB7CiAgICBwdWJsaWMgc3RhdGljIHZvaWQgbWFpbihTdHJpbmdbXSBhcmdzKSB7CiAgICAgICAgbmV3IE15RnJhbWUoKS5zZXRWaXNpYmxlKHRydWUpOwogICAgfQp9