japplet

How to code the projectile of a ball of different force and angle in Java Swing?

烂漫一生 提交于 2019-11-27 09:10:36
I have written the following function for projectile motion of different force and angle, but it doesn't work properly. Where have I gone wrong? I want something like the Angry Birds game. Code: public void shootBall(int timeCounter){ int gravity = 4; double time = timeCounter/40.0; int velocity = force_value; double radians = currentangle*Math.PI/180; ball.setX((int)((ball.getX()+10)*Math.cos(radians) + velocity*Math.cos(radians)*time)); ball.setY((int)((ball.getY()+10)*Math.sin(radians) + velocity*Math.sin(radians)*time - 0.5*gravity*time*time)); updateGame(); } I want the ball to be thrown

Applet not appearing full

◇◆丶佛笑我妖孽 提交于 2019-11-27 05:37:01
I just created an applet public class HomeApplet extends JApplet { private static final long serialVersionUID = -7650916407386219367L; //Called when this applet is loaded into the browser. public void init() { //Execute a job on the event-dispatching thread; creating this applet's GUI. // setSize(400, 400); try { SwingUtilities.invokeAndWait(new Runnable() { public void run() { createGUI(); } }); } catch (Exception e) { System.err.println("createGUI didn't complete successfully"); } } private void createGUI() { RconSection rconSection = new RconSection(); rconSection.setOpaque(true); //

JApplet creates a ball that bounces and gets progressively less high in Java

随声附和 提交于 2019-11-27 02:19:27
public class Circle extends JApplet { public void paint(Graphics g) { int x=100; int y=100; int diameter=50; int xResize=500; int yResize=500; super.paint(g); resize(xResize,yResize); g.drawOval(x, y, diameter, diameter); } } So I am trying to create a ball that bounces up and down and progressively gets smaller. I need to use the following code as a class that will set up my next class that will actually carry out the action. I know that I need to set up the current code that I have into constructors, instance variables and methods to create objects from but I can't seem to figure out how to

Embed a 3rd-party JApplet in a Swing GUI & pass it parameters

故事扮演 提交于 2019-11-27 02:06:34
There's a third-party applet that I'd like to embed in my Swing application. Basically, I'd like it to be just another panel. This applet makes use of many parameters, e.g. final String config_filename = getParameter(XXX); I've seen lots of documentation about how to send parameters values via HTML, but how do you do it via code (or perhaps property files)? Any help would be appreciated! Implement an AppletStub & set it as the stub of the applet instance. E.G. /* <applet code='ParamApplet' width='200' height='200'> <param name='param' value='foo'> </applet> */ import java.applet.*; import

Java - Applet simply not displaying?

跟風遠走 提交于 2019-11-26 23:38:03
问题 Okay, so I did a little applet tutorial, and I read that the init() method is required for an applet to run. And it does. At least in my IDE (Eclipse). The Applet Viewer has no problems running my applet, when I try to do the <applet> tag in HTML, nothing displays, but it acts as though something is there (text position is altered by the tag). Here is my applet: import java.awt.*; import javax.swing.*; public class Applet extends JApplet{ public void init(){ Label label = new Label("Hello!");

JApplet - super.paint(); causes flicker

做~自己de王妃 提交于 2019-11-26 22:13:22
问题 I'm writing a JApplet right now, and whenever I call super.paint(), the applet flickers. I am using double buffering (drawing to an image, and then rendering that image), but I think super.paint() is clearing the screen or something, defeating my double buffer. I know I'm supposed to use paintComponents(), but for some reason, when I call "currentScreen.Draw(g)," it won't show the screen's draw. Can anyone help me with this? public void paint(Graphics g) { super.paint(g);//Remove this and it

Simple animation using Thread.sleep() in ActionListener

为君一笑 提交于 2019-11-26 22:10:22
问题 I'm having trouble with this code I am using to create a roulette wheel. The goal is to spin the wheel when I click the "SPIN!" button. I have done this by creating a for loop that should change the status of the wheel from true to false, which changes the orientation. This, when done fast enough, should create the illusion of movement. THE PROBLEM I AM HAVING : is that my wheel is only repainting after the whole for loop is done, despite my placement of the repaint(). So, it only spins one

Converting a JFrame to a JApplet

こ雲淡風輕ζ 提交于 2019-11-26 22:09:22
问题 I have a JFrame application working nicely. However now I'd like to run it on the web as an Applet. This is what I've done: import MyPackage.*; import javax.swing.*; import javax.swing.event.*; import java.awt.*; import java.awt.event.*; public class MyName extends JApplet { public void init() { setSize(600,450); new MyName() } public MyName() { JShellFrame frame = new JShellFrame(true, null, null); frame.setVisible(true); } } How can I make an html file to run this applet? Also, I have an

JApplet creates a ball that bounces and gets progressively less high in Java

六月ゝ 毕业季﹏ 提交于 2019-11-26 12:33:29
问题 public class Circle extends JApplet { public void paint(Graphics g) { int x=100; int y=100; int diameter=50; int xResize=500; int yResize=500; super.paint(g); resize(xResize,yResize); g.drawOval(x, y, diameter, diameter); } } So I am trying to create a ball that bounces up and down and progressively gets smaller. I need to use the following code as a class that will set up my next class that will actually carry out the action. I know that I need to set up the current code that I have into

Applet not appearing full

我怕爱的太早我们不能终老 提交于 2019-11-26 11:38:40
问题 I just created an applet public class HomeApplet extends JApplet { private static final long serialVersionUID = -7650916407386219367L; //Called when this applet is loaded into the browser. public void init() { //Execute a job on the event-dispatching thread; creating this applet\'s GUI. // setSize(400, 400); try { SwingUtilities.invokeAndWait(new Runnable() { public void run() { createGUI(); } }); } catch (Exception e) { System.err.println(\"createGUI didn\'t complete successfully\"); } }