jgrasp

drawingPanel color change with displacement

烈酒焚心 提交于 2020-01-19 17:43:06
问题 I'm using JGrasp, and in drawingPanel , I'm trying to create a ball that changes colors as it moves across the screen. Right now, I've got: for (int i = 10; i<=i; i++) { Color c = new Color(i*i, 0, 0); pen.setColor(c); My full simplified code is: import java.awt.*; import java.util.*; import java.awt.Color; public class BallSample { public static final int SIZE = 30; public static final int HALF = SIZE / 2; public static void main(String[] args) { Scanner console = new Scanner(System.in);

Hot to stop the program from crashing after a String is entered instead of an int

白昼怎懂夜的黑 提交于 2020-01-05 08:10:23
问题 How do I stop this from crashing when a String is entered instead of an int? Here is what i have. I've tried looking up some tutorials but I still couldn't figure it out. Thanks for the help guys. When a String is entered i need it to tell the user to enter an int import java.util.Scanner; public class TaxCalc { public static void main(String [] args) { Scanner keyboard = new Scanner(System.in); int dependents = inputInt("Enter number of dependents: ", keyboard); int pigs = inputInt("Enter

changing jvm heap size - jgrasp

*爱你&永不变心* 提交于 2019-12-23 05:17:14
问题 I know how to increase java heap size on command line using flag -Xmx, I need to run my program in jgrasp, how do I increase the heap size for my program in that IDE? System.out.println("---->"+Runtime.getRuntime().maxMemory()); prints ---->66650112 on adding flag -Xmx256m the heap size still print the same number 回答1: Even when you pass -Xmx256m , it doesn't mean that the JVM is going to allocate that amount right away. -Xmx specifies the max heap. The JVM will wait to allocate more heap up

“Cannot Open a.exe” Error in C++

守給你的承諾、 提交于 2019-12-20 03:19:17
问题 I'm trying to compile my C++ program, but when I press the "Build" button, it displays the following error message: c:/gnat/2010/bin/../libexec/gcc/i686-pc-mingw32/4.3.6/ld.exe: cannot open output file a.exe: Invalid argument collect2: ld returned 1 exit status This is not the first time it has done this. It seems to do this most when I have been editing the same project a lot and building it often, almost as if something has been flooded, or overloaded, or something. I had fixed it before, I

Java - Sorting a 2D Array by Row Sum

廉价感情. 提交于 2019-12-13 16:09:49
问题 Trying to write a method that swaps the rows of a 2D array in order of increasing row sum. For example, if I have the following 2d array: int [][] array = {4,5,6},{3,4,5},{2,3,4}; I would want it to output an array as so: {2 3 4}, {3 4 5}, {4 5 6} Methodology: a.) take the sums of each row and make a 1D array of the sums b.) do a bubble sort on rowSum array c.) swap the rows of the original array based on the bubble sort swaps made d.) then print the newly row sorted array. Here's my code so

How do i know if a Jcheckbox is checked?in GUI [closed]

偶尔善良 提交于 2019-12-13 08:17:27
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 6 years ago . can you tell me in details how do i know if a jcheckbox is checked or not? method isSelected didn't work with me it gives me an exception while running { Sandwich = new JButton("Tall"); contentPane.add(Tall); Sandwitch.setBounds(350, 110, 90,40); //in main Sandwitch.addActionListener(this); } ..... public void

G++ Not found, I've already tried 3 different compilers

霸气de小男生 提交于 2019-12-12 22:30:29
问题 I can compile C code no problem using MinGW but for some reason I can't compile C++. I already tried other compilers, cygnus and cygwin. I'm using JGrasp. Here's the error feed: ----jGRASP wedge2 error: command "g++" not found. ---- This command must be in the current working directory ---- or on the current PATH to use this function. ---- PATH is ";C:\Program Files\Common Files\Microsoft Shared\Windows Live; C:\Program Files (x86)\Common Files\Microsoft Shared\Windows Live C:\windows

When creating a jar file how do I retain the existing classpaths to other jar files?

被刻印的时光 ゝ 提交于 2019-12-11 05:23:35
问题 I recently completed a college Java assignment. The assignment utilised various other jar files, e.g. mysql connector. When I created a jar file from the Java programs in the project the connections to these other jar files were lost. I tried various different combinations when creating the jar file and once included the mysql connector, but to no avail. I didn't expect this to work as my research had shown that usually only sound effects and images are classed as acceptable additional files.

Converting number to word

时光怂恿深爱的人放手 提交于 2019-12-08 14:24:12
问题 I would like to get some help on converting an integer to word. I am very new to Java, i kind of have an idea of what i think im going to be doing but need some help with it. The code should print the words of number from 0-999 and once -1 typed in the scanner the program should stop. Like this: Please type a number between 0 and 999: 1 ONE Please type a number between 0 and 999: 11 ELEVEN Please type a number between 0 and 999: 122 ONE HUNDRED AND TWENTY TWO Please type a number between 0

Java, Return true if array contains duplicate values

泪湿孤枕 提交于 2019-12-08 09:37:39
问题 I am trying to have a method (duplicates) return true if a given array called x (entered by user in another method), contains duplicate values. Otherwise it would return false. Rather then checking the entire array, which is initialized to 100, it will check only the amount of values entered, which is kept track of with a global counter: numElementsInX. What is the best way to accomplish this? public static boolean duplicates (int [] x) I am prompting for user data like so: public static void