No one has voted on any posts yet. Votes from other community members are used to determine a member's reputation amongst their peers.
41 Posted Topics
Re: This is pretty simple code but I see some errors here and there. Are you trying to calculate the averages and grade in a seperate method or all in the main method? For the average calc method it should look like this: public static double calculateAverage(double Test1, double Test2, etc.) … | |
I just added a pause button to my game, using most of this code: [URL="http://msdn.microsoft.com/en-us/library/bb195026%28v=xnagamestudio.31%29.aspx"]http://msdn.microsoft.com/en-us/library/bb195026%28v=xnagamestudio.31%29.aspx[/URL] For some reason it changes the Window.Title to "[GameName] - Paused" and even though it's unpaused it still says paused in the title. I never told it to change the title so I guess it … | |
Re: What Jeff said. You'll need to read into getting input, declaring variables (such as a String array), using arrays, and outputting results. We won't do your homework for you. | |
I have a web project I've been working on in my free time using mostly jsp. It's currently set up so that if a user clicks the login button it takes them to a check-login servlet which will return whether it's a valid login or not through a session.setAttribute("loginstatus","Valid"). Everytime … | |
I made a basic JUnit test to set up this oracle database on my computer with hibernate. The database works and everything, but trying to hook it up to Hibernate is proving to be a challenge. My config file is below: [code] <hibernate-configuration> <session-factory> <!-- Database Connection Properties --> <property … | |
Re: This is why I'm glad my first java professor taught java with the console to start out | |
I'm not sure how it's done, but I need a link to change an attribute so that the main content page can get the attribute and then display the appropriate content. My following code does not work...and it always seems to include home.jsp no matter what (home is set from … | |
I'm completely new to JSP but not Java [CODE]<div> <%@ page import="java.util.*" %> <%= Date date = new Date(); out.println(date.getHours()+":"+date.getMinutes()+":"+date.getSeconds()); %> </div>[/CODE] All I need is [CODE]Hour:Minute:Second[/CODE]. (Edit: stupid emoticons) I'm getting this error on Date [CODE]Multiple annotations found at this line: - Syntax error, insert ")" to complete MethodInvocation … | |
Re: Try C# and XNA Game Studio. I'm building a simple 2D rpg game right now and it's not hard at all with a java background | |
I keep getting the IndexOutOfRangeException for my XNA game and after printing the indexes it stops at 600. Is that the max limit for arrays in C#? I'm trying to get all of the pixels from an 800x600 image into an array so I can test when a R:20 G:20 … | |
I have 2 classes. One get/set BlockData, and one main class that loads,draws,updates. I have a big list of public Texture2D types that I have in the main class. I need blockdata to be able to get the texture2d types for each block and send it back to main...but blockdata … | |
Re: I've always used Eclipse and I don't think it's hindered my ability to learn java at all | |
I just started teaching myself some basic things with this, but the simplest shit like strings seems impossible. Does anyone know any good sources, tutorials, or anything that might help me more? As an example...I wrote this code to tell when a control button was pressed: [CODE]//ProcessKeys int key; string … | |
I'm making a game in XNA. I need a player to move from block to block (40x40pixels) and I need to be able to set the speed that the player is able to move at. Right now, I have this code: Update Method - updates 60 frames per second or … | |
I'm creating a game with XNA, and having issues with Vector2 arrays. The code below will loop through each square on the grid for the game 40x40pixels. The first for loop getting the X coordinate and the second getting the Y coordinate. I'm getting the proper width and height (if … | |
Re: 4. Outputs all the numbers that when squared are between 1 and 10. So if firstNum is greater than 3 there won't be any numbers that when squared are between 1 and 10. for (int i=0; i<totalnumbers; i++){ squarednumber = number*number; if ((squarednumber>=1) && (squarednumber<=10)){ System.out.println(squarednumber); } } | |
Re: Loop up string tokenizer or split string | |
Re: You've already posted this and you really should figure out the GUI code for yourself instead of using Netbeans automatic thing. It's hard to read your code with all of Netbeans' weird jumbled up mess of stuff | |
Re: [QUOTE=JamesCherrill;1526131].jar files are just .zip files with some conventions about what's in them. A full description is on the Oracle java web site. You can edit them with your favourite zip file utility.[/QUOTE] Doesn't unzipping just show the .class files though? I'm curious how you decompile a class file back … | |
When I run my program, sometimes it shows up and sometimes it just shows a blank frame. Is this because it's having trouble loading the canvas/buttons and all that stuff...aka do I need a loading screen and how do I do one in java? | |
I have my code set up so I can 1)select what image and 2)the coordinates of the mouse click where the image is going to be placed. What it currently does it place the right image in the right coordiantes but if I click again somewhere else, it replaces the … | |
Re: Like a .png? Can't you just screenshot it? | |
Re: Your code a bit jumbled, but I'll just write out what's necessary for what you need. [CODE]File file = new File(filename); BufferedReader reader = null; try { reader = new BufferedReader(new FileReader(file)); String text = null; String savetext=null; while ((text = reader.readLine()) != null) { savetext += text } textarea.setText(savetext); … | |
Re: [url]http://www.rgagnon.com/javadetails/java-0205.html[/url] This might help, but I just wanted to say minecraft ftw | |
[CODE]PointerInfo a = MouseInfo.getPointerInfo(); Point b = a.getLocation(); int x = (int) b.getX(); int y = (int) b.getY(); System.out.print("Y: "+y); System.out.print("X: "+x+"\n");[/CODE] Right now I'm using this, but it gives me the coordinates relative to the entire monitor. Since you can move the program frame anywhere on the monitor, this … | |
Re: hexAdd[positionNum] = Integer.parseInt(diskScanner.nextLine()); Is this what you're looking for? | |
This is my first time trying to use KeyListener and I just need it to move an image over 20 px every time I press the right arrow key. After 400px, it should move down to the next line vertically 'playery.' For Some reason it prints out the console output … | |
Re: [CODE]String stringname = textfield.getText(); JOptionPane.showMessageDialog(null, stringname);[/CODE] | |
Re: [QUOTE]if they picked 10 for the first question ( how many questions they want) then i have to do the math game 10 times .. i cant figure that out ![/QUOTE] [CODE] for (i=0; i<10; i++){ //math game code } [/CODE] Also, do your random generators work? I usually add … | |
How do you determine what the main hard drive is? This is what I have: [CODE]filename="savefile2.txt";[/CODE] and this is pseudocode for what I want: [CODE]filename="MainDrive:/JavaProject/savefile2.txt";[/CODE] My problem with it is, what if C: isn't the name of a person's hard drive? F:\ for instance. And also, if the folder name … | |
Re: You need to use Scanner to scan for input from the console. Should be a quick google search. | |
Re: Make a variable to count the number of grades. You'll need a loop like this: [CODE]int gradecounter=0, aGrade, bGrade, cGrade, etc; while (input != null) { input = c.readLine(); gradecounter++; if (input>=90){ aGrade++; } //etc. } System.out.println("Total grades: "+gradecounter+ "A Grades: "+aGrades+"which is "+aGrade/gradecounter;[/code] Etc. Etc. Etc. | |
It's only reading every other line. It's supposed to print out: 28 80.0 22 1 2 2 3 1 3 But it's only reading: 80.0 1 2 1 [CODE]//Load button - #=daynum, $=wallet, @=inventory, &=employees, !=customers if (btn2.getText().equals("Load")){ int id=0; File file = new File("savefile1.txt"); BufferedReader reader = null; try … | |
I have a program with 2 panels, each with it's own class. LeftPanel and RightPanel. Whenever I click a button that does some calculations (like calculating total assets amount) in one of the panels, it doesn't update that info for the other panel. For example....I have this seperate class that … | |
Re: NetBeans or Eclipse. I use Eclipse and love it. I'm assuming you can understand the basics and just don't know java's capabilities and syntax. If you really want to jump straight into GUIs, do a google search for "java layouts" and "java swing." | |
I have a buying system set up in one class (the Right Panel class) and it's working great, but my text field for displaying money available is in the Left Panel class. When I click the buy button, it should subtract from the money amount and re-display the new money … | |
I'm fairly new to java, but I'm sure I've done this before and now it's not working right. What am I forgetting here? LeftPanel class [CODE]Inventory inventory; JTextField txtMoney = new JFormattedTextField([COLOR="Red"]inventory.getInvWallet()[/COLOR]);[/CODE] Inventory class [CODE] public class Inventory { public int invId = 0; public int invPrice = 0; public … | |
GridBagLayout question My main class holds frame and gets left and right panels from other classes [CODE] /** * Matthew Schrum * 11/14/2010 */ import java.util.Random; import javax.swing.JFrame; public class Sim { public static void main(String[] args) { //variables LeftPanel leftPanel = new LeftPanel(); RightPanel rightPanel = new RightPanel(); //GUI … | |
I'm trying to organize my frame so that I have two panels, one on the left and one on the right, sort of like a website design with buttons on the right and empty text area on the left. How in the hell is this accomplished? I've been screwing around … | |
I'm working on a really basic text editor to save and open txt files. On my text area setLineWrap, it's giving me a "misplaced constructs" and "delete token" for the period and (true) For why? [CODE]/**Matthew Schrum *11/18/2010 */ import java.awt.*; import javax.swing.*; import javax.swing.border.*; import java.awt.event.*; import java.io.File; import … |
The End.