japplet

How to stop repaint() flickering

China☆狼群 提交于 2019-12-29 09:30:11
问题 I am trying to make a program to java and i have the common problem with flickering. I have try many things to eliminate but all the same. while the oval that i paint is moving the japplet is flickering. i need your help to solve this problem. here is my code: import java.awt.Color; public class all extends JApplet implements Runnable { double x=0; double y=0; int m=0; int n=0; int f=30; int μ=0; Thread kinisi; JPanel panel; JFrame frame; private boolean running = false; private JTextField

Java applet Error … What is wrong?

你。 提交于 2019-12-28 06:53:11
问题 Java applet code package M257Applet import java.applet.*; import javax.swing.*; import java.awt.*; public class HellowApplet extends JApplet { public void init(){ Container cp = getContentPane(); JLabel lb = new JLabel("Hellowwwww"); cp.add(lb); } } html file <html> <head> <title>Applet</title> </head> <body> <APPLET CODE = HellowApplet.class WIDTH = 400 HEIGHT = 400 > </APPLET> </body> </html> Error Java Plug-in 1.6.0_22 Using JRE version 1.6.0_22-b04 Java HotSpot(TM) Client VM User home

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

帅比萌擦擦* 提交于 2019-12-28 03:05:18
问题 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) +

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

北战南征 提交于 2019-12-28 03:05:14
问题 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) +

How to add different actionlisteners to the same object

假装没事ソ 提交于 2019-12-25 11:55:45
问题 How do I add different actionlisteners to the p1 objects. I want the program to be able to set the textbar to the appropriate number when pressed with the appropriate button. Since they are not different variables I cannot simply use the code below(in my actionPerformed function), if (e.getSource() == button1){ txtField.setText("1"); } import java.awt.*; import java.applet.*; import java.awt.event.*; public class Telephone extends Applet implements ActionListener { TextField txtField; public

Why is my applet throwing an AccessControlException?

眉间皱痕 提交于 2019-12-24 16:35:06
问题 I am trying to build a Java applet, called game , which is something I have never done before (I've always just built standalone applications). My applet works fine when I test it in Eclipse, but when I try putting it on my website, I get the following error in the console: java.lang.reflect.InvocationTargetException at com.sun.deploy.util.DeployAWTUtil.invokeAndWait(DeployAWTUtil.java:116) at sun.plugin2.applet.Plugin2Manager.runOnEDT(Plugin2Manager.java:3541) at sun.plugin2.applet

Creating an animation using JApplet

泪湿孤枕 提交于 2019-12-24 14:28:00
问题 I am working on a Java program that uses a JApplet which makes a ball bounce up and down. I am able to paint the shape onto the JApplet and everything like that. I just can't seem to get it to move. I have looked into this and saw that I need to create a method that pauses the shape then clears it from the JApplet, changes coordinates, and then redraws the shape in the new area but for some reason it's just not working for me. Thank you in advance for the help. import java.awt.Color; import

How to set maximum available size for JApplet?

微笑、不失礼 提交于 2019-12-24 11:15:08
问题 I am porting my desktop Swing application to an applet. The following code works perfect for JFrame entity to set a maximum available window size, considering a task bar. GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment(); Rectangle bounds = env.getMaximumWindowBounds(); frame.setMaximizedBounds(bounds); frame.setPreferredSize(bounds.getSize()); frame.setLocation(0, 0); In Eclipse Run Configurations -> My Applet -> Parameters I can select Width and Height or if applet

How to set maximum available size for JApplet?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-24 11:12:31
问题 I am porting my desktop Swing application to an applet. The following code works perfect for JFrame entity to set a maximum available window size, considering a task bar. GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment(); Rectangle bounds = env.getMaximumWindowBounds(); frame.setMaximizedBounds(bounds); frame.setPreferredSize(bounds.getSize()); frame.setLocation(0, 0); In Eclipse Run Configurations -> My Applet -> Parameters I can select Width and Height or if applet

images are not showing up in paint component

馋奶兔 提交于 2019-12-24 10:06:42
问题 it gives me a black screen for setbackground, but it doesnt seem to read the images or draw them, some help would be appreciated, also if you could tell me the information pertaining to my code, i have trouble understanding general r vague answers, thanks. import java.awt.*; import javax.swing.*; import javax.swing.JComponent.*; public class Movie extends JApplet { private String movName1; private String director1; private int yearMade1; private Image movPic1; private String movName2; private