hallo man hat mir gesagt das ich hier CenterPanel de fokus gebe..
doch kann mir jemand sagen wo ich das mache, und wie ich das unterlassen kann?
vielen dank für eure hilfe
doch kann mir jemand sagen wo ich das mache, und wie ich das unterlassen kann?
Java:
public class LayoutManager extends Applet
{
public void init() {
add(new LayoutManager_1());
}
}
class BirdsEyeView extends Canvas
{
public BirdsEyeView(int appletsize_x, int appletsize_y, int v1, int v2, int v3, int v4, double t,
int Radius, int radius, int kradius, int kRadius, int radiusComet, double ex_a_e,
double ex_b_e, double ex_a_m, double ex_b_m, double ex_a_s, double ex_b_s, int mittelP, int Schweif, int anzahlC, int xm, int ym, int xs, int ys,
int[] x, int[] y, double[] xd, double[] yd)
{
this.appletsize_x = appletsize_x;
this.appletsize_y = appletsize_y;
this.v1 = v1;
this.v2 = v2;
this.v3 = v3;
this.v4 = v4;
this.t = t;
this.Radius = Radius;
this.radius = radius;
this.kradius = kradius;
this.kRadius = kRadius;
this.radiusComet = radiusComet;
this.ex_a_e = ex_a_e;
this.ex_b_e = ex_b_e;
this.ex_a_m = ex_a_m;
this.ex_b_m = ex_b_m;
this.ex_a_s = ex_a_s;
this.ex_b_s = ex_b_s;
this.mittelP = mittelP;
this.Schweif = Schweif;
this.anzahlC = anzahlC;
this.x = x;
this.y = y;
this.xd = xd;
this.yd = yd;
System.out.println("b" + Schweif + anzahlC);
}
public void paint(final Graphics g)
{
/* das paint() der super-Klasse muss natürlich aufgerufen werden. */
super.paint(g);
Color braun = new Color(142,43,43);
g.setColor (braun);
g.fillOval (x[1] + appletsize_x/2 - 1, y[1] + appletsize_y / 2 - 1 -100, 2, 2);
}
}
class LayoutManager_1 extends Panel implements Runnable, KeyListener
{
// Initialisierung der Variablen
public LayoutManager_1()
{
bird = new BirdsEyeView(appletsize_x,
appletsize_y,
v1,
v2,
v3,
v4,
t,
Radius,
radius,
kradius,
kRadius,
radiusComet,
ex_a_e,
ex_b_e,
ex_a_m,
ex_b_m,
ex_a_s,
ex_b_s,
mittelP,
Schweif,
anzahlC,
xm,
ym,
xs,
ys,
x,
y,
xd,
yd);
setLayout(new BorderLayout());
// add the two canvases
Panel centerPanel = new Panel();
centerPanel.setLayout(new GridLayout());
Color farbebg = new Color(0,0,0);
bird.setBackground(farbebg);
centerPanel.add(bird);
add("Center", centerPanel);
setPreferredSize(new Dimension(appletsize_x,appletsize_y));
th.start();
addKeyListener(this);
}
public void keyPressed(KeyEvent event)
{
System.out.println(event.getKeyChar());
}
public void keyReleased(KeyEvent event)
{
}
public void keyTyped(KeyEvent event)
{
}
public void run ()
{
// Erniedrigen der ThreadPriority um zeichnen zu erleichtern
Thread.currentThread().setPriority(Thread.MIN_PRIORITY);
// Solange true ist läuft der Thread weiter
while (running)
{
t += 0.02;
System.out.println(t);
// Neuzeichnen des Applets
repaint();
//bird.repaint();
try
{
// Stoppen des Threads für in Klammern angegebene Millisekunden
Thread.sleep (20);
}
catch (InterruptedException ex)
{
// do nothing
}
// Zurücksetzen der ThreadPriority auf Maximalwert
Thread.currentThread().setPriority(Thread.MAX_PRIORITY);
if (th.interrupted())
{
break;
}
}
}
public void paint (Graphics g)
{
}
}
vielen dank für eure hilfe