java - Trying to draw to applet in another class -


Hi is a beginner for Java programming and I'm trying to explain how a shape (oval) Drag from second to square in a Java applet (I'm sure this is probably a simple problem)

I want to attract the square with the applet:

  import java .awt. *; Import javax.swing.JApplet; Public Class Pulsatingballs Jeplette (Private Static Last Long Serial YearsUUID = 1L; Public Zero Init () {getContentPane (). SetBackground (Color.black); New Ball (20, 20);}}  

and ball class:

import java.awt.Graphics; public class ball pulsating ball {int x; int y; public ball (int y, int x) {this.x = X; y; y = y; repaint ();} public zero color (graphics g) {g.draw oval (x, y, 50, 50);}}

Try it out:

Applet:

  Public Class PulsatingBalls extended to JApplet {Private Static Last Long Serial VERSIONUID = 1 L; Private Last List  New Arrayist & Lt; ball & gt; (); @ Override Public Wide Init () {getContentPane (). SetLayout (new border layout ()); Last zipal jp = new zpinal () {@ Override protected zero paint blanket (Last Graphics } {SuperpintConant (G); g.setColor (Color.red); (Last ball B: balls) {BPaint (G); }}}; Jp.setBackground (Color.black); GetContentPane () Add (jp, BorderLayout.CENTER); Balls (New Ball (20, 20)). }}  

ball:

  public square ball {int x; Int y; Public ball (final end y, last int x) {this.x = x; this. Y = y; } Public Zero Color (Last Graphics G) {g.draw oval (X, Y, 50, 50); }}  

Comments

Popular posts from this blog

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -