32,204 Topics
| |
I want to add a selectable image to a PadDraw() of a JFrame container. So how can I do it? I've got a idea that it can be done by JLabel, but I think it's not selectable. So, how can I add that? | |
The book I'm using says it should look something like this [CODE] import java.io.*; public class main { public static void main(String[] argv) { String fil = "CormeOn.bat"; FileWriter fw = null; try { fw = new FileWriter(fil); } catch(FileNotFoundException fnf) { System.out.println("Yea...."+fnf); } catch (IOException e) { e.printStackTrace(); } … | |
I am stuck in this code. I have to print results every 30 tosses for 500 total tosses. I made the 30 but in the loops. And also percentages are showing as 0 Help or hints would be much appreciated. [CODE]import java.util.Random;// program uses class Random public class CoinTossing { … | |
how can i check a given string to form a palindrome or not for(i=0;i<str.length();i++) { if(str.charAt(i)==str1.charAt(i) } } | |
I would like to know when NullPointerException comes in java. any help would be appreciated. | |
In high school I learned Pascal and C++. Everything from hello world to search trees, to graphical battleship with AI. Now I'm a freshman in college and in my CS1 class we are using Java, but after 2 months we are just now on arrays. Basically I was just hoping … | |
Hello, I have a weird problem while running my project. I use netbeans and here's my code and the problem is explained after the code. [CODE]/* * NetworkingView.java */ package networking; import org.jdesktop.application.Action; import org.jdesktop.application.ResourceMap; import org.jdesktop.application.SingleFrameApplication; import org.jdesktop.application.FrameView; import org.jdesktop.application.TaskMonitor; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.Timer; import javax.swing.Icon; import … | |
lets say i have 8 deck of cards how to put all of that inside a array do i have to make a multidimensional array for each deck??? | |
Hi, I would like to know the code used for java to clear the screen as we do in c# using [COLOR="red"]Console.clear();[/COLOR] is it possible in Java aswell? If yes, what code should i use? | |
hi i started coding battle ship when i was done i noticed that the user and computer always misses, even if they hit, i dont know what i did wrong [CODE]import java.util.Scanner; public class Battleship { public final static String USER = "user"; public final static String COMPUTER ="computer"; public … | |
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, … | |
I have the following code to generate an array of random numbers. How can I get it to print the array like [5,89,76,34,2] instead of printing down. I don't think it is actually printing the array just the numbers. [code] import java.util.Random; public class RandomIntArray { private int[] numbers; public … | |
calculate value of PI from the infinite series Ï€ = 4-4/3+4/5-4/7+4/9-4/11 +..... write a class with two data members aproxivalue(double value ) and percision ( integer value ) where precion is the number of terms of the series used to compute the value of approxivalue : 1- default constructor permits … | |
Hey, Is there a way to get the keycode from a char? I tried using KeyEvent.getKeyCode() but the KeyEvent class didn't have a constructor so it was freaking out. I've been searching for 2+ hours already and nothing. My goal is to have a char, convert it to keycode, and … | |
Hello everyone, I need some help understanding some concepts and possibly with my logic on this problem. We are supposed to create a program that asks users for their name, id, and grade average. The set is supposed to be where the exception is thrown. When the user enters their … | |
I'm using ArrayList. But the problem is that the indexOf function is not working in a for loop. It's showing 0 for all the elements or objects. Code goes like that for a FOR loop : [CODE]for(or_data or : counts.or_gates) { if (or.isHit(x, y)) { mutual=counts.or_gates.indexOf(or); set_move_cursor(); or.addX(dx); or.addY(dy); System.out.println("Got … | |
Here is the assignment criteria : Implement exception handling to validate user input as was described in class. You need to at least catch type mismatch exception. No late or by emailed homework will be accepted. We are to have a student enter their name, id and grade. The name … | |
Hello I was working through a Netbeans tutorial : [URL="http://java.sun.com/developer/technicalArticles/java_warehouse/single_jar/"]http://java.sun.com/developer/technicalArticles/java_warehouse/single_jar/[/URL] I am having a problem understanding adding my properties and xml dependencies contained in an xml dir in my project (Please find screen print of dir) I jar my app and it can not find these files or dir. java … | |
I am building a Circuit Editor using Java. I'm now at very first stage. Now I'm building a simple editor like Paint. I've implemented a drawing-pad where you can draw straight line and continue the line until you click an right click, by a "WIRE" Button click in the frame. … | |
I'm having to design a program in java to get the radius from the user than print back the diameter, circumference and area using that radius I'm not sure where I'm going wrong in this [CODE] import java.util.Scanner; public class Circle { private static void circleInfo() { float radius; public … | |
Does anyone now of a regular expression that will omit words in a string while replacing others? | |
I am doing a project like a car gallery system and need to ask for help... Suppose I want to create a class call [COLOR="Red"]"Brand"[/COLOR], it is basically just to store the brand name, a brief description, and also need to give it a picture. Says: Toyota, it is a … | |
I'm running to compiler error while I'm trying to use Enum to create a program that display a deck of cards. The compiler mistake is "Cannot find symbol", but I did call the constructor and use method call to call the method in card class. It still give me compiler … | |
Hey guys, I'm bit of a noob so please bear with me. I'm trying to open a lot of urls in internet explorer at once. About 40 urls. I have an array of my urls and I'm using the following code: [CODE] for (int i = 0; i < urls.length; … | |
can anyone tell me how to [B][U]setOwner[/U][/B] as well as the [B][U]fileKey[/U][/B] for the particular file........ i've retrieved the metadata information but can't able to set values..... [CODE="java"] import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.nio.file.attribute.AclFileAttributeView; import java.nio.file.attribute.BasicFileAttributes; import java.nio.file.attribute.UserPrincipal; /** * * @author user */ public class … | |
Hey guys. I am getting a fair amount of errors when trying to create this menu. I am not sure whether or not I am going about it correctly. Without further adieu: [CODE]package assignment.pkg2; import java.util.Scanner; public class Assignment2 { public static final int MAX_NUM = 10; public static void … | |
I have an assignment to reverse the sequence of coins in a purse. I cannot use any methods from the Collections or Arrays Class. I have the following code but have no idea what to do from here to get the purse contents to reverse. [code] import java.util.ArrayList; public class … | |
I have an assignment to create a class Purse and print the coins in the purse, reverse the sequence of the coins, transfer the contents of one purse to another, and compare to see if two purses have the same contents. I have the following code but the transfer is … | |
So I have to create a guessing game to be played between 2-5 players. That part wasn't very difficult. I am however having LOTS of trouble with the try...catch statement. I have to have to make the program have a try catch so it doesn't throw an error if the … | |
[INDENT]:icon_lol:Suppose there is a (method) [U]call stack[/U]; An [B]exception[/B] has occured in a deep level but not handled there yet; So the corresponding [I]finally block[/I] at that level is executed first and then [B]it[/B] is thrown to be propagated up through the [U]call stack[/U] and at each step if [B]it[/B] … |
The End.