286 Posted Topics
I have an error when I shorten 3 lines of code to one. How come this code works [CODE] import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.util.Vector; public class Draw extends JPanel implements KeyListener, Runnable, ActionListener{ Vector<Wall> walls = new Vector<Wall>(); Vector<Enemy> enemy = new Vector<Enemy>(); Player p = new … | |
Re: use a for loop, and have an answer variable that is set to 1. then decrement the for loop, and then multiply the number in the for loop to the number in the answer, and once you are done return the answer. | |
Re: posting empty methods as your attempt will not get you any replies. please try something, and then post the code if it doesn't work. If you are stuck look through the api, and see what you can find. | |
Re: you need to indent everything inside the brackets for example [CODE] bracket1{ inBracket1{ variableInBracket1 } variableBracket1 } [/CODE] so your code should look like this [CODE] public class printCards { public static void main (String []args) { int x = 0; // keeps count of how many card final int … ![]() | |
Re: try removing the this in the switch statement. | |
Re: try using the different Math funcions that are implemented into java [CODE] Math.round(); Math.random(); [/CODE] | |
Re: There is no get text method for a JButton. assign the text as a variable, and then just use that to print out, and set the text on the JButton | |
Re: you could use something like this to get an idea. As a starter you will start at the lower end of the scale. [url]http://www.payscale.com/research/CA/Job=Software_Engineer_%2F_Developer_%2F_Programmer/Salary[/url] | |
Re: The second example [URL="http://download.oracle.com/javase/tutorial/uiswing/components/textfield.html"]here[/URL] is a search through the text. all you would need to do is read the .txt file and store it as a string. then display it in the text field to search through. | |
I am wondering what the difference is. So far what I think is correct is that software engineering is more user oriented, and less efficiency oriented, while computer science is more computer orientated, and focuses on using memory the most efficient way. This is important in bigger projects such as … | |
I got this error, when the bullet collides with the enemy. [CODE] 341, 458 null 341, 458 null 341, 458 null 341, 456 java.awt.Rectangle[x=340,y=75,width=50,height=50] 341, 456 java.awt.Rectangle[x=325,y=45,width=50,height=50] 341, 456 java.awt.Rectangle[x=479,y=15,width=50,height=50] 341, 454 java.awt.Rectangle[x=340,y=76,width=50,height=50] <CUT THIS OUT. ABOUT 1000 LINES LIKE THE ONES ABOVE> 305, 352 java.awt.Rectangle[x=222,y=36,width=50,height=50] 305, 352 java.awt.Rectangle[x=299,y=6,width=50,height=50] 341, … | |
It will soon be time for me to choose where to go to post secondary. I am wondering what schools people suggest preferrably in Ontario, Canada. I plan to go for Software/Video Game development/programming (because of my lack of artistic ability), Web Development, and Mobile development. I will accept any … | |
Re: if you assigned a variable called inputSum and then called the average method with the parameter inputSum then you could do the same thing, except you wouldn't need to add your numbers in the average method. | |
Re: you would need the number of pennies added in the brackets | |
If I have a himachi server running is there a way to send a file into a specific folder on a different computer without them having the client? For a file transfer like program that the recipient does not need to download? | |
Re: make the previousInput equal to the result, and then reuse it when you do another calculation previousInput = 3 currentInput = 2 Sign = * previousInput = result = 3*2 = 6 next operation previousInput = 6 currentInput = 1 sign = - previousInput = result = 6-1 = 5 | |
Re: try [CODE] Image bg = new ImageIO(new File ("stewie.jpg")); [/CODE] | |
I am making hearts, and I cannot seem to add all the cards to the deck. here is my code [CODE] import java.lang.reflect.Array; import java.util.Vector; public class Hearts { String cards[][] = {{"Spade ", "Heart ", "Club ", "Diamond "}, {"A","2","3","4","5","6","7","8","9","10","J","Q","K"}}; Vector <String> deck = new Vector<String> (); String player1[] … | |
Re: Use println to see if all of your code is executing. also you have super.paintComponent(g); in both of your codes. make sure that they are not interfering with each other. maybe try calling one paint from the other. | |
I have an array of cards. It looks like this [CODE] String cards[][] = {{"Spade", "Heart", "Club", "Diamond"}, {"1","2","3","4","5","6","7","8","9","10","J","Q","K"}}; [/CODE] how would I get the suit and the "rank" of the card. I have tried [CODE] System.out.println (cards[1][5] + " of " + cards [1]); [/CODE] but that gave me … | |
Re: maybe try reading this [url]http://en.wikipedia.org/wiki/ElGamal_encryption[/url] What I know of encryption so far is that it uses matrices to hide the message. for example [ [ = one large [ lets say your encryption matrix is [1 2] [a b] [3 4] [c d] your decryption matrix would be 1r(ad-bc) [d … | |
Re: If you just wanted to test it out you could make a desktop os like running XP in a VM. It would involve all of the difficulties of making it boot up os, but it would still be impressive. Then later you would only need to make minor changes to … | |
I am trying out something new and I am wondering if this is valid and is not working because of some other code glitch. Graphics class: [CODE]import java.awt.*; import javax.swing.JPanel; public class Drawing extends JPanel{ KeyCommands kc = new KeyCommands (); public void startGraphics (){ System.out.println ("Adding KeyListener"); addKeyListener (kc); … | |
Re: couldn't you do [CODE] public double (double number1, double number2){ return (Math.pow(number1, number2)); } [/CODE] | |
I am trying to do basic animations with images, and I am wondering how I could get a smaller image from a larger one without going through and editing it. I made a sprite [URL="http://translate.google.com/translate?hl=en&u=http%3A%2F%2Fwww.famitsu.com%2Ffreegame%2Ftool%2Fchibi%2Findex1.html"]here[/URL] and downloaded the image. As you see in the thumbnail the animation is from all … | |
I have this laptop, and whenever I press the power button it lights up. Then when the windows loading screen would pop up, it is just a pure black screen (no line for the bios boot up). And then it freezes there. I managed to turn it on today, and … | |
I am taking data management this year, and we are currently learning about matrixes. I know they are used to encrypt things, and the teacher even used it as an example. my problem is the following. We are only learning how to encrypt and decrypt using a 2x2 matrix. That … | |
Re: readInt and readLine (except this could be numbers as well maybe use a for loop to see if each character is a letter) | |
Re: I made a snake game as well so if you would like to inspect my code after you fix yours to see how you could improve efficiency, just message me. | |
Re: if you are using if statements then I would suggest you store the last value in each textfield then you compare them to see if they are not equal (has been changed) then you can recalculate the rest of the values using the one you used in the if statement. … | |
I am just learning how to use sockets, and I have managed to get my server to send a message to my socket, but when I try to send a message from my socket to my server I get an error. Here are my codes Server: [CODE] package BasicNIO; import … | |
![]() | Re: maybe have it declared and set separately [CODE] int j; j = 1; [/CODE] |
Re: gender is a string use .equals (); put the "m" into quotes inside the brackets to compare the two strings | |
Re: The previous post was right about the first error. For the second one try this code [CODE] Phone application = new Phone(); application.runPhone(); [/CODE] then add a method in your phone like so [CODE] public void runPhone (){ Phone p = new Phone (); } [/CODE] That may fix the … | |
I am making a website and the header is not displaying properly in chrome. It only shows a couple of rows of pixels and then it stops. [URL="agnes-fitness.com"]Here[/URL] is the site. Another smaller problem is that if you refresh a couple of times in ie the header will be stretched. … | |
I am making a website and I have a little problem with it on IE and opera, but IE is the bigger issue. I have 2 images the first one is what it looks like on IE and the second one is what it is supposed to look like. What … | |
I get this error when I run my applet on a website [CODE] Java Plug-in 1.6.0_26 Using JRE version 1.6.0_26-b03 Java HotSpot(TM) Client VM User home directory = C:\Users\Adam ---------------------------------------------------- c: clear console window f: finalize objects on finalization queue g: garbage collect h: display this help message l: dump … | |
I have a css menu that changes sizes for no apparent reason. This is my whole css code [CODE]style.css: body { background: url('Images/testBackg.jpeg') 50% 50% no-repeat; } #images{ margin-top:10px; margin-bottom:10px; } #labelId { float:left; } #inputId { float:right; } #contactForm { max-width:50%; min-width:50%; } #headerWrap { margin-left: auto; margin-right: auto; … | |
I have made a simple java program that gets a user to fill out a form, and then checks if all the parts were filled out. I am now having trouble with how to send the file in an email to a set users email account. How could I do … | |
I am not sure where this could go, but I believe this is the most appropriate forum. I am wondering how to cast a number to a character in actionscript. I have the key code and I would like to cast it as a character so that I can then … | |
Re: cout<<i is c++ not Java if you need to have the conditions of 1 - 100 [code] for (int i = 1; i <= 100; i++){ // loops from 1 - 100 if (i <=35){ // checks if it is between 1 and 35 System.out.println (i); // prints out the … | |
Re: I have in a couple of comments in some areas, but they are generic. you can delete them if you wish. I have already released my code on thetechgame.com. Anyways here is the main part of the code the frame portion is separate. [CODE] package snakeColored; import javax.swing.*; import java.awt.event.*; … | |
Re: you want to use graphics. You also want to implement MouseMotionListener, and KeyListener, which are both located in java.awt.event. I suggest you look through the API docs to find out how to make a JFrame, and how to set the layout. But the combo box and JFrame are located in … | |
Re: you don't actually need anything in your for statement. It will result in an infinite loop though, unless you use a break statement, like the OP used. | |
I have this problem, that whenever I set the frame size using the setSize () method the size inside the frame is actually smaller, because the frame size is included in this dimension. My question is how would I make it so that the inside of the frame is the … | |
I am trying to export a project using eclipse, and the Images that I have in a separate folder do not export. I have tried to use [icode]image = new ImageIcon (Toolkit.getDefauleToolkit ().getImage("Image/image.png"));[/icode] and [icode]image = new ImageIcon (ImageIO.read (new File ("Image/image.png")));[/icode] and neither of them worked. It works when … | |
I am trying to save an image with this line [CODE]ImageIO.write(image, "JPG", new File(fileDestination.getText()));[/CODE] but it is giving me an error. [CODE] java.io.FileNotFoundException: C:\Users\Adam (Access is denied) at java.io.RandomAccessFile.open(Native Method) at java.io.RandomAccessFile.<init>(Unknown Source) at javax.imageio.stream.FileImageOutputStream.<init>(Unknown Source) at com.sun.imageio.spi.FileImageOutputStreamSpi.createOutputStreamInstance(Unknown Source) at javax.imageio.ImageIO.createImageOutputStream(Unknown Source) at javax.imageio.ImageIO.write(Unknown Source) at screenCapture.CaptureScreen.actionPerformed(CaptureScreen.java:111) at javax.swing.AbstractButton.fireActionPerformed(Unknown Source) … | |
Re: The messages.length returns an int. It tells you how many messages you have. If you replace the 5 here [CODE]System.out.println("Message " + (int)(5*Math.random()));[/CODE] with your max value passed into the method you will not have to constantly update that number, as it will always be passed in with the new … |
The End.