I've got a problem with my home made game. When I created it as a JFrame application it runs smoothly, but when I tried to convert it to a JApplet the graphic is "lagging". I can see the graphics blinking/flashing .....
Here is the code:
public class FallingBalls extends JApplet implements KeyListener,
ActionListener {
// VARIABLES //
boolean gameOver;
boolean win;
// Buttons
JButton start, pause, restart;
// Character "The Runner" (32px x 32 px)
I've got a problem with my applet when I run it in a browser (firefox mainly but nothing else is working neither). First of all, the program is "unsigned" according to firefox security system, but I don't think that's where to problem lies. When I start the applet (as an html application) it says:
AccessControlException
Then it says: Access denied ("java.io.FilePermission" "bla, bla, bla (img source on my harddrive)" "read")
How do I get this to work? This is the picture I'm trying to implement: [URL]...
I just created an applet that I want to call from a html file.
The applet code looks like this (and works):
package jav12;
import java.awt.*; import javax.swing.*; public class Welcome extends JApplet { public Welcome(){ } public void init() { getContentPane().add(new Label("Yessss it works",Label.CENTER));
[Code] ....
When I click on the html file the content of the page is blocked and the applet isn't loaded. What can I do to fix this. I think it has something to do with rights. This is a crosspost to JApplet content blocked
I am developing a game where a player has to find a path in a maze. Right now the player can only click the buttons on the maze. I need an option to use the arrow keys.
I have picked up pieces from my code to illustrate my problem. Below is the code. If I call "AnyClass" in the "AppletClass" it works but when I call "MiddleClass" in the "AppletClass" and MiddleClass" calls "AnyClass" it does not work. In my project at www.hiredforoneday.com I call 4 panels in CardLayout before I call "AnyClass" which is the "Maze"
I am trying to make a japplet that has open, zoom in and zoom out buttons for pictures. I am not sure how to go about an open button that will read the file. I have the picture url hard coded in the file to open but would like an open button with a file/folder dialogue.
I'm not exactly sure what the draw button is supposed to do specifically, all i know is that it is supposed to draw both rectangles and ovals. The problem I am having is that when ever I click Draw Rectangle, it draws rectangles jusst the way I want but when ever I click Draw Oval, the program keeps drawing rectangles. I've tried repaint and clearRect methods but I did not manage to get them to work. I'm not sure what the problem is right here, I just cannot get it to work. Is there anything you guys can see that might be causing this? It's always good to have a different person look at it then myself. Also, I'm trying to implement a boolean for draw oval but I don't know where to put the if then.
public void init() { length = new JTextField(10); width = new JTextField(10); btnDraw = new JButton("Draw"); btnClear = new JButton("Clear"); btnDrawRectangle = new JButton("Draw Rectangle"); btnDrawOval = new JButton("Draw Oval");
So I'm trying to make an applet and I found that Thread.sleep() to simply delay is a bad idea.
I'm not sure how to use the Timer class to implement a same version of sleep() to delay 6 seconds. I am trying to do this in a for loop to delay before every loop. How can I implement this?
This code is after the init() method. For simplicity I didn't include. Assuming I did:
Timer t = new Timer(6000, null); public void actionPerformed(ActionEvent e) { try { URL rsUrl = new URL("http://rscript.org/lookup.php?type=namecheck&name=" + n1); BufferedReader br = new BufferedReader(new InputStreamReader(rsUrl.openStream())); for (count = 0; count < maxCount; count++) {
This is what he wants: He wants us to prompt the user to input x values and y values (that will be entered into an array when clicking one of the two buttons (this one will say: Add point)). When they click the second button (draw lines), it should take all the points and draw a line that connects all the points together using a method that we write. In the method we have to call the paint method up which the lines will be drawn. The lines drawn should be touching every point added. It shouldn't have parameters. It will also use Graphics painter = getGraphics(); We can't use frames either.
I have everything up until the method understood.
How to write a method that will draw a line from points inputted that is called up in the action listener when the second button (draw lines) is pressed.
I am developing an application to share my client screen with server, it is working well on swing. But i want to develop as web application, i am trying to using applet. But i am facing the fallowing problem..,
1) The Applet screen also open and project also running well on server mechine. But unable to see the client screen on the server.
2) The problem may be to display the JDesktopPane or JInternalFrame.
My working Server Code extends withe JFrame..Java Code:
This is a program that prompts a menu using the do-while iteration. If user input is not valid, the menu should be reprompted once. But when I run the code and enter an invalid value, the menu is prompted 3 times.
class Menu { public static void main(String args[]) throws java.io.IOException { char choice; do {
I just wrote a java program with eclipse that has to read many-many inputs from the user. I want to test it, but I really don't want to type it everytime again and again...
Can I just write all inputs in a text file and let eclipse read this file so instead of typing it again and again, Eclipse reads every line whenever it waits for a user input?
/home/t_bmf/Java/HelloWorld/src/helloworld :will contain a .java file /home/t_bmf/Java/HelloWorld/bin :will contain all .class file
Let say a have a code:
package helloworld; public class HelloWorld { public static void main(String[] arg) { System.out.println("Hello World"); } }
a command to compile this even outside the directory /home/t_bmf/Java/HelloWorld/src/helloworld javac -d /home/t_bmf/Java/HelloWorld/bin /home/t_bmf/Java/HelloWorld/src/helloworld/HelloWorld.java
This will generate a directory /home/t_bmf/Java/HelloWorld/bin/helloworld and file inside this is HelloWorld.class
To run this program I must be in directory /home/t_bmf/Java/HelloWorld/bin and using this command:
java helloworld.HelloWorld
Question:
I already how to run the HelloWorld.class, but I must be in helloworld /home/t_bmf/Java/HelloWorld/bin to run it. Is there's a way to run the class even when I am not in directory /home/t_bmf/Java/HelloWorld/bin? Let's say I'm in /home/t_bmf, can I still run the HelloWorld.class?
I'm getting back into the swing of things with Java after using I'm asked to utilize a simple GUI in order to take in the starting data, I cannot seem to get this to work. I'm getting this error Exception in thread "main" java.lang.NullPointerException
at java.awt.Container.addImpl(Unknown Source) at java.awt.Container.add(Unknown Source) at Input.buildPanel(Input.java:53) at Input.<init>(Input.java:27) at InputDemo.main(InputDemo.java:5)
We've got a java web app (running on a Solaris machine with Weblogic) and from time to time it stops working due to this error:
Java Code: java.net.SocketException: Too many open files mh_sh_highlight_all('java');
For what I've read we are somehow exceeding the established limit of file descriptors, and it seems that this may be caused for many reasons, not only open files that we forgot to close.
I am making a list of everything that may consume a file descriptor in the system mentioned above, so I can start reanalyzing the app... if needed, as I don't know if we're wasting them or if the limit is just insufficient.
I have a problem with running my hello world aplication. Here is the code.
public class HelloWorld { public static void mаin(String[] args) { System.out.println("Hello world!"); } }
It compiles fine. But I get an exception when I try to run it.Here is the error message I'm getting:
Exception in thread "main" java.lang.NoSuchMethodException: HelloWorld.main([Ljava.lang.String;) at java.lang.Class.getMethod(Class.java:1605) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:113)
I've been playing around with this for about an hour.
Java Code:
Runtime runTime = Runtime.getRuntime(); try { Process process = runTime.exec("notepad"); } catch (IOException e) { e.printStackTrace(); } mh_sh_highlight_all('java'); So that works. Notepad will open.
However, I'm trying to get other programs to open. Specifically, this program: C:Octave3.2.4_gcc-4.4.0inoctave-3.2.4.exe...However, using that in place of notepad doesn't work. I'm assuming that there is some sort of system variable that explains why simply typing "notepad" works? As if you type notepad into the run box, notepad will open. Soo does that snippet work by going through some sort of system variables?How would I go about opening other programs, such as the one I referenced above.
error: File .ServiceServerImpl.class does not contain type ServiceServerImpl as expected, but type serviceserver.ServiceServerImpl. Please remove the file, or make sure it appears in the correct subdirectory of the class path. error: Class ServiceServerImpl not found. 2 errors "
Here is the source code of the class file. Using Windows 8. I copied the .class file to the rmic.exe 's location later. didn't work either way. It is in a package called "serviceserver"
package serviceserver; import java.rmi.*; import java.rmi.server.*; import java.util.*; public class ServiceServerImpl extends UnicastRemoteObject implements ServiceServer { HashMap serviceList;
i have a program in UNIX directory /home/me/java/src
package bin; public class HelloWorld { public static void main(String[] args) { System.out.println("Hello World"); } }
I have manage to compile it successfully(class file will be in bin directory) using command below: javac -d /home/t_bmf/java/bin HelloWorld.java
My problem now is how would I execute the class in bin directory in UNIX? I already tried different ways on how to execute it as suggested in my internet research The one I tried is this:
java $CLASSPATH:.:bin/HelloWorld but I got this error message: Exception in thread "main" java.lang.NoClassDefFoundError: :/:bin/HelloWorld Caused by: java.lang.ClassNotFoundException: :.:bin.HelloWorld
The below method shows that a JOptionPane should display when the result is null, meaning it has not found what I was trying to look for. However only the if statement that finds the query runs:
public void find(Person person) { String query = "SELECT * from employee WHERE last LIKE'" + lastName + "'"; try { statement = connection.createStatement(); resultSet = statement.executeQuery(query);
I am working on a management gui for a program. I have implemented the start server button. But now I need to get something working so that when I press stop server the javaw.exe process which is running the the other jar file is stopped and ended.
The gui is going to be using a javaw.exe as well and I don't want to end the entire thing.
I just want to end the javaw.exe process that is running the other jar file.
This is my code for starting it:
JButton btnNewButton_2 = new JButton("Start Server"); btnNewButton_2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Runtime rt = Runtime.getRuntime(); try { Process pr = rt.exec("java -jar DEDServer_release.jar");
[Code] ....
I just need to figure out what to do to stop it now.
When i run a applet file in browser(IE, Chrome, Firefox) it gives a error of security risk and block the application from running. All browser are giving same error. Programme is running correctly in Myeclipse
I've just installed the last Java kit JDK plus netbeans and I've done my first project in Java. It is running perfect from command line<but is is difficult to execute each time from there my tests> but I couldn't run the jar file from windows with double click he jar file even I've spent 3 hour on google to find different methods (registry modifying, control panel/program running in windows, a patch file etc, ) ....