I have a game which is very simple: it is two images, and one needs to reach the other. Once it does, it resets. I have a class which holds the two images, and another which holds the game. My images class extends my game class. The problem I am having is that when I run the program, not one, but two frames appear. One is the perfect game, working perfectly, and the other is the game without images. I want the one that is the game without images to simply stop appearing. I believe it is appearing because my class that displays the image is extending the game class, but I can't not extend it because if I do I get a whole lot of bugs and errors.
How the recursion works. I tried to figure out writing down low, mid, high at each recursive call. But I seem to be making a mistake somehow. I don't understand where the values are returned to in
I am trying to make a for loop using an iterator that refers to an object of a class that hasnt been made yet. The class is called MyArrayList but it does not have a Main. A MyArrayList object is made externally so I am unsure how to refer it to the object from within the class. Is there a place holder I could use such as Object.Iterator() or something similar. I have created an inner class that implements the Iterator interface. Here is the code that I need to adjust to do this:
public class ListIterator<E> implements Iterator<E> { public myIterator() { Iterator it = MyArrayList.iterator(); while (it.hasNext()) { System.out.println(it.next()); } } }
I'm making a program that prints arrows of varying tail length, head width, and displacement.The shape algorithms are working properly, but the displacement isn't working. The first arrow has zero displacement, and the second one is supposed to be bigger and start the print at 10 spaces right and 5 spaces down from the default, but it's not working. I tried changing the displacement settings of the first arrow, and no changes happened, so I know that the positions aren't registering properly in general. How to pass the xAdj and yAdj (displacement) values? I think I have the empty space formula set up, but it's still not running.
Driver: public class Driver { //default values public static final int Arrow_Default_xAdj = 0; public static final int Arrow_Default_yAdj = 0; public static final int Arrow_Default_tail = 5; public static final int Arrow_Default_width = 5;
I was wondering what the easiest way would be to keep track of everytime someone makes a new post on reddit (social media site, for those who don't know). I want the program to keep track of the number of posts made with a counter, but that's the easy part. How do I set up a program to actually communicate with and monitor reddit's servers in this manner?
I am stuck trying to build a relatively "simple" GUI. The GUI should have one JComboBox that allows the user to pick from one of three locations. Then based on their choice, another JComboBox should be generated with another set of choices. The key is that the second ComboBox should have different choices depending on the selection made in the first one. So, in theory, the logic should be something like:
//create new JComboBox array of strings "locations" //create new JComboBox array of strings "costToTravelThere" //if user picks location 1 from the first ComboBox then add the second ComboBox with options specific to that first location else if user picks location 2 from first ComboBox then add the second ComboBox with options specific to that second locatoin
I understand how to do the basic stuff, like create the JFrame and the actual panels and ComboBoxes, etc. What I don't understand is how to implement the second ComboBox dependent on the first one. I'm not very experience with Listeners and such, and I'm sure that's a big part of this.
package com.Lists; public class EmployeeOffice implements EmpInterface { private double salary; private String name; private String postion; private double hoursWorked;
[Code] .....
So if i wanna sort this Generic class using comaparator what do i do... I cant find an answer to this... I wanna sort them on the basis of salary what to do ...
I wrote a code from our text book for Pong. Im trying to figure out how to fill the ball with color. Im also wondering how to speed the ball up once there is contact with the paddle. The initial speed is ok but once contact is made with the paddle, it slows down. Makes it too easy to play. Here is my code so far. As far as the game goes, it works and is good. Just wanted to add a couple customizations.
What I'm trying to do is basically draw a Rectangle outline through left-click and then dragging the mouse to the size one wants.
After one has created this rectangle, the user can change the color of the rectangle through clicking the 3 sliders found on the top in the program. Upon the change in color, the rectangle should change from "g.drawRect" to "g.fillRect" and use the desired color.
I have the basic outline of the program done, but working with the last part (the color and changing of the Rectangle type after changing the color)
Is there like a "then" command in Java? Like: after you've done x, do y. That would make this heaps easier.
Opoly works this way: The board is a circular track of variable length (the user determines the length when the game app runs). There is only one player, who begins the game at position 0.
Thus, if the board length is 20, then the board locations start at position 0 and end at position 19. The player starts with a reward of 100, and the goal of the game is to reach or exceed reward value 1000. When this reward value is reached or exceeded, the game is over. When the game ends, your program should report the number of turns the player has taken, and the final reward amount attained.
In Opoly the game piece advances via a spinner - a device that takes on one of the values 1, 2, 3, 4, 5 at random, with each of the five spin values equally likely.
Although the board is circular, you should draw the state of the board as a single "line", using an 'o' to represent the current player position, and * represent all other positions. Thus if the board size is 10, then this board drawing:
**o******
means that the player is at location 2 on the board.
Here are the other Opoly game rules:
If your board piece lands on a board cell that is evenly divisible by 7, your reward doubles.
If you land on the final board cell, you must go back 3 spaces. Thus if the board size is 20, the last position is position 19, and if you land there, you should go back to position 16. (If the position of the last cell is evenly divisible by 7, no extra points are added, but if the new piece location, 3 places back, IS evenly divisible by 7, then extra points ARE added).
If you make it all the way around the board, you get 100 points. Note that if you land exactly on location 0, you first receive 100 extra points (for making it all the around), and then your score is doubled, since 0 is evenly divisible by 7,
Every tenth move (that is, every tenth spin of the spinner, move numbers 10,20,30,... etc.), reduces the reward by 50 points. This penalty is applied up front, as soon as the 10th or 20th or 30th move is made, even if other actions at that instant also apply. Notice that with this rule it's possible for the reward amount to become negative.
Here is the driver class for the game:
import java.util.*; public class OpolyDriver{ public static void main(String[] args){ System.out.println("Enter an int > 3 - the size of the board"); Scanner s = new Scanner(System.in); int boardSize = s.nextInt();
[Code] ....
heres the methods:
REQUIRED CODE STRUCTURE: Your Opoly class must include the following methods (in addition to the Opoly constructor) and must implement the method calls as specified:
playGame - The top-level method that controls the game. No return value, no parameters. Must call drawBoard, displayReport, spinAndMove, isGameOver.
spinAndMove - spins the spinner and then advances the piece according to the rules of the game. No return value, no parameters. Must call spin and move.
spin - generates an integer value from 1 to 5 at random- all equally likely. Returns an integer, no parameters.
move - advances the piece according to the rules of the game. No return value, takes an integer parameter that is a value from 1 to 5.
isGameOver - checks if game termination condition has been met. Returns true if game is over, false otherwise. No parameters.
drawBoard - draws the board using *'s and an o to mark the current board position. Following each board display you should also report the current reward. No return value, no parameters.
displayReport - reports the end of the game, and gives the number of rounds of play, and the final reward. No return value, no parameters.
Im trying to make a tic tac toe game that you play against the computer using a random number generator and two dimensional arrays for the game board. Im not trying to make a GUI, the assignment is to have the board in the console, which I have done. I have run into a few problems with trying to get the computer player to correctly generate 2 integers and have those two integers be a place on the game board. Here is my code so far.
import java.util.Random; import java.util.Scanner; public class TicTacToe { private static Scanner keyboard = new Scanner(System.in); private static char[][] board = new char[3][3]; public static int row, col;
i am using a frame over which i am loading a dialog. The singleton dialog holds a progress bar. I have created my own swing worker. i am controlling the construct method of swing worker(which functions like doInBackground method).I am trying to call hidedialog from an external file. The dialog gets stuck sometimes. How do i solve it . It works fine on win7 but fails on win8.
I've just got a new computer and i tried to set the class path the way i did with windows xp but it's not working. This is what i have done. I added a Path variable to user variables and added C: Program Files (x86)Javajdk1.6.0_20/bin as the variable value. But when i got to command prompt and type javac HelloWorld.java it just tells me javac is not recognised as an internal or external command.
Also another problem is after trying this and it not working i tried to add a path to the system variables. I added a new path variable but i think once i did that it deleted the one that was already there. Is that going to mess up my computer? What the default path variable for windows 7 is?i've got the right destination as i typed cd to change directory and when i typed C: Program Files (x86)Javajdk1.6.0_20/bin it changed to that. And i noticed if i typed in the destination wrong its just made an error.
Cannot reinstall java on this windows xp. Get an error -1 and install didn't complete. There are no java versions installed and apparently no java control panel either.
I want to create a Web page which can monitor and display the status of Schedule Tasks setup on different remote machine. This Dashboard should also has the capability to re-run the schedule task.
I know that I can achieve this via Runtime class by running schtasks /Query and get all the details. But I just wanted to know if we have any other better way to do this.
I manage a small company through our bank's online system, that uses java, but I can't access it through any browser , they all give the same issue; after I choose the certificate file on my PC, nothing happens.
If i dual boot Ubuntu on my PC it works, so it's clearly something with the Windows installation.
Things tried :
- Reinstall Java, multiple times - Clean anything Java and Oracle related in my PC (except registry, I don't know how to fuzz with that) - Different browsers
Is it possible to edit hosts file in java program? I tried it but I'm getting "AccessDeniedException". I need to have permissions for it, but can i somehow set the permissions in java program for current user?
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, ) ....
I have an applet and start some process on Windows from applet. When I start this process just from another code(test), this code works fine and process runs from rt.exec() to proc.destroy(). When I use html call for applet - process runs only for 5 seconds every time (!!!) and then just alive, doesn't work, to proc.destroy(). This is really interesting for me (newbie in applets). I think, this issue caused by AccessController. I use Windows, medium Java security lever and applet is self-signed. It asks me to 'allow', applet works.Here's the code:
I'd like to know if there's a way to embed Windows Painter (mspaint.exe) in a browser. I'm not sure it's possible with Java and if it doesn't, any relevant reference to this subject.
In the image, the color of the frame of the window/JFrame is black. My question is that can we set the color of this frame, or is it just provided by the operating system and whatever color is default color of windows in an operating system will appear in our application?
I am talking about the frame, the boundary in the JFrame container which contains the close, maximize, and minimize buttons.
When I run the following code from Java HeadFirst, everything goes fine but along with one error ( i don't know is it an error or exception, or some other windows stuff). The code is
import javax.sound.midi.*; class ExceptionHandling { public static void main(String[] args){ ExceptionHandling o = new ExceptionHandling(); o.play();
[Code] ....
And what I got on cmd ( I am using Windows 7) :
Jaspreet javac ExceptionHandling.java Jaspreet java ExceptionHandling Jun 11, 2014 5:19:40 PM java.util.prefs.WindowsPreferences <init> WARNING: Could not open/create prefs root node SoftwareJavaSoftPrefs at root 0 x80000002. Windows RegCreateKeyEx(...) returned error code 5.
We got the sequencer
What is meant by code in blue? I know its some message from windows os and not from jvm. but i didn't understand it.