7,116 Posted Topics

Member Avatar for paycity

You could add a layer instance variable to the cube class, then in the paintComponent (not paintComponents, not paint!) method sort the cubes on the layer variable before painting. Or Keep another list of cubes, this one in layer order. Shuffle the list when you want to change a cube's …

Member Avatar for paycity
0
1K
Member Avatar for exi
Member Avatar for exi
0
241
Member Avatar for bharath54321

Without knowing what you want to do with later, it's impossible to decide what is the best approach. However, my instinct is to create a PropertyNode class that has a List of properties (Strings?) as an instance variable. I would then read the whole file and create a map of …

Member Avatar for jwenting
-1
177
Member Avatar for burningflower

OK, so you had a problem, but you've fixed it, and now you have another error, but you haven't told us what it is. You have at least two sections of code, but we don't know how you fitted them together. So what you have to do is start again …

Member Avatar for JamesCherrill
0
101
Member Avatar for I<LateNupurGuha
Member Avatar for kesh1000

Vector and ArrayList are almost identical (Vector methods are synchronised but ArrayLists are not). They each hold a simple ordered list of items. HashTable is a completely different thing; it maps keys to values. The decision whether to use Vector/ArrayList or HashTable depends on whether the data has to be …

Member Avatar for jwenting
0
158
Member Avatar for alonewolf23

You have 2 arrays to fill up, but you only have one variable i to keep track of both - so if you have 4x econ they go into EconArray[0-3] then if there's a 1st it goes into FirstArray[4] not FirstArray[0]. You need two variables corresponding to the 2 arrays …

Member Avatar for alonewolf23
0
1K
Member Avatar for Amillia89

Yes. Package the compiled .class files into an executable jar. When you double-click the jar the program will run. Just Google "executable jar" for the details

Member Avatar for Amillia89
0
203
Member Avatar for chester1908

You can get the source of the event from the ActionEvent itself eg e.getSource() - this will be the particular button that was pressed.

Member Avatar for chester1908
0
416
Member Avatar for GlenRogers

This isn't very clear - but do you mean that those details are fields of a class you defined (eg Album) and when you print it you get some hex? If so, that's the default toString() method that your class has inherited from Object, and what you need to do …

Member Avatar for JamesCherrill
0
587
Member Avatar for chakebubu

AFAIK external processes started using the ProcessBuilder class run independently of what you do with your Java app once they are started.

Member Avatar for JamesCherrill
0
95
Member Avatar for sheylashy

The while on line 7 looks wrong to me. This is a recursive solution, it shouldn't need another loop. I would expect a simple if. You'll probably want a better print on line 32, since array is an array.

Member Avatar for JamesCherrill
0
412
Member Avatar for bharath54321
Member Avatar for JamesCherrill
0
138
Member Avatar for CrazyPixel
Member Avatar for JamesCherrill
0
294
Member Avatar for ganesh641
Re: java

The language reference makes it clear that primitive types (int, boolean, char, float etc) are not Objects, so you may draw conclusions from that if you wish.

Member Avatar for Sadun89
1
120
Member Avatar for lacoffo

So... it looks like the 2 parts to your system need to know about each other - or at least ButtonPanel needs to have access to the instance of GamePanel so it can call its methods. One way is to pass the instance of GamePanel to ButtonPanel in ButtonPanel's constructor. …

Member Avatar for lacoffo
0
857
Member Avatar for arshi9464

1. x=0; is an assignment statement that can only be used in a method or constructor, so you can't just have it in your class like that. You can use an initialiser as in int x = 1; 2. Making the object of the class dabba in the dabba class's …

Member Avatar for arshi9464
0
109
Member Avatar for hao90

reads files images/img1.gif images/img2.gif images/img3.gif etc and uses them to create graphical icons that can be displayed in a JLabel

Member Avatar for JamesCherrill
0
120
Member Avatar for jackmaverick1

Hi jackmaverick Not being able to do a switch on Strings is a well known shortcoming of Java and (at last!) its fixed in Java 7 - which will be out later this year. You can switch on a single char because a Java char is a numeric type (16 …

Member Avatar for JamesCherrill
0
95
Member Avatar for TheWhite

[CODE=JAVA] String stamp = "2011-03-23 00:43:07"; SimpleDateFormat dfZone = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss z"); Date dZulu = dfZone.parse(stamp + " UTC"); System.out.println(dfZone.format(dZulu)); // uses UTC dfZone.setTimeZone(TimeZone.getDefault()); System.out.println(dfZone.format(dZulu)); // uses local time zone dfZone.setTimeZone(TimeZone.getTimeZone("PDT")); System.out.println(dfZone.format(dZulu)); // uses West Coast zone[/CODE]

Member Avatar for JamesCherrill
0
5K
Member Avatar for sumprit
Member Avatar for sumprit
0
143
Member Avatar for jackmaverick1

Yup. [ICODE]System.in[/ICODE] is the console input stream. It's common practice to use this with the Scanner class to handle some basic parsing of the input... [CODE]Scanner sc = new Scanner(System.in); String s = sc.nextLine(); or... int i = sc.nextInt(); // etc etc - see API doc for details of all …

Member Avatar for sourabh17
0
200
Member Avatar for coderN

There was a thread on exactly this problem here a few weeks ago - you should be able to track it down without too much problem.

Member Avatar for JamesCherrill
0
42
Member Avatar for iShrne

@dononelson has already given a good answer to this "iterate through your doubly-linked list and add each element to a java.util.LinkedList". Do you have methods in your DLL to (a) get the first element and (b) get the next element? (If not, your implementation is incomplete.) You can use those …

Member Avatar for JamesCherrill
0
152
Member Avatar for kvskchaitanya

In a fraction of the time it took to post that you could have Googled [ICODE]resultset swing table[/ICODE] and got any amount of sample code and discussions.

Member Avatar for kvskchaitanya
0
169
Member Avatar for Alpdog14

The usual convention for compareTo is that it takes 1 param and compares that to the current object ("this").

Member Avatar for JamesCherrill
0
183
Member Avatar for fyezool

[url]http://download.oracle.com/javase/tutorial/getStarted/cupojava/win32.html[/url]

Member Avatar for Sadun89
0
133
Member Avatar for pythonbegin
Member Avatar for JamieC90

Your load code looks OK to me at a quick scan, but there's a big problem with what you do next. You create a new local variable FirstYears (NB should be firstYears), read the file into it, then end the method - at which point FirstYears goes out of scope …

Member Avatar for JamieC90
0
842
Member Avatar for MrHardRock

If your indentation is right then you increment fcnum inside 2 nested loops without ever resetting it, so its hardly surprising that it eventually gets >9 and is no longer a valid index for a 10 element array.

Member Avatar for JamesCherrill
0
241
Member Avatar for terexberd

You can download the source code for Java SE from the Oracle web site under the JRL (Java Research Licence*) - although there are restrictions if you live in country that's not on the approved list. [url]http://download.java.net/jdk6/source/[/url] * The JRL is a license that was created specifically for universities and …

Member Avatar for terexberd
0
213
Member Avatar for chinee

if(value !=null) value is an int, and can never be null. Only Object references can be null.

Member Avatar for chinee
0
152
Member Avatar for kris0r

The ArrayList class has a [ICODE]boolean contains(Object o);[/ICODE] method that returns true if the ArrayList already contains this Object, so you can use this for your [ICODE]if(newurl is not in visitedarray)[/ICODE] test. The test used to see if Object o is already in the ArrayList is o.equals(any element in the …

Member Avatar for mKorbel
0
514
Member Avatar for kukuruku

You can test the value (see previous post) and if it's out of range you can throw a new Exception [CODE]throw new Exception("value out of range");[/CODE]

Member Avatar for mKorbel
0
106
Member Avatar for Skyelher

OK, we don't have the full picture here. You declare goodWords as a raw type - which gives a warning when compiled. Ditto your iterator. Line 5 has a case error, and doesn't compile. You then assign the return value of iterGoodWords.next(), which is type Object, to a String, which …

Member Avatar for Skyelher
0
172
Member Avatar for mkab

How about something like... [CODE] public void mitosis() // duplicates all the cells in this Organism... ArrayList<Cell> temp = new ArrayList<Cell>(cells); // need temp copy of cells because cells will be modified in the loop cells.clear(); // We could just add 1 copy, but removing the originals and // adding …

Member Avatar for mkab
0
234
Member Avatar for tunlinaung
Member Avatar for stupidbumbum

First work out how you would do it by hand. Write down what that process is. Then finally translate it into Java code.

Member Avatar for jon.kiparsky
0
91
Member Avatar for snehalj

[QUOTE]to keep DaniWeb a student-friendly place to learn, don't expect quick solutions to your homework. We'll help you get started and exchange algorithm ideas, but only if you show that you're willing to put in effort as well.[/QUOTE] So what have you done so far?

Member Avatar for mKorbel
0
98
Member Avatar for snehalj

[QUOTE]to keep DaniWeb a student-friendly place to learn, don't expect quick solutions to your homework. We'll help you get started and exchange algorithm ideas, but only if you show that you're willing to put in effort as well.[/QUOTE] So what have you done so far?

Member Avatar for jwenting
0
317
Member Avatar for brothman

Please show the code for DisplayWindow (or at least the constructor that is called on line 12), and the code for the FileTree constructor ditto. If either of those causes (directly or indirectly) a call to refresh() then this will happen before any value is assigned to window on line …

Member Avatar for JamesCherrill
0
166
Member Avatar for iwannalearn

int a[] (or int[] a ) defines a variable a that is a reference (like a pointer) to an array of ints. It's initial value is "null" - ie it does not contain an actual reference new int[5] allocates memory in the heap for an array of 5 ints so …

Member Avatar for lisaroy1
0
156
Member Avatar for rohit2

Have a look at the KeyListener interface in the API doc - it allows you to respond to individual keys being pressed and/or released.

Member Avatar for mKorbel
0
186
Member Avatar for xxmp

No, it's not. What is it that you want to achieve? - there may be other ways to get the desired result.

Member Avatar for JamesCherrill
0
116
Member Avatar for MWE_QUE

The error message (Exception) tells you exactly what kind of error it is, and exactly which line it happens on. Without that info its very hard to debug. Please post the full text of the error message

Member Avatar for MWE_QUE
0
145
Member Avatar for forhacksf

Rather than Google, you first point of reference should be the JComboBox API documentation, where you will find the following... public int getSelectedIndex() ... Returns an integer specifying the currently selected list item, where 0 specifies the first item in the list; or -1 if no item is selected or …

Member Avatar for JamesCherrill
0
253
Member Avatar for anumash

"Doesn't run" Do you mean when you try to execute it nothing happens? Or does it throw a runtime Exception? Or does it give a wrong result, and if so, what's the difference between the expected and actual result. But anyway, line 9 you lose all the text before the …

Member Avatar for sam.udo
0
150
Member Avatar for programing

[ICODE]static_cast< int >( 'A' );[/ICODE] This isn't part of the standard Java language or API, but it is valid C++ You can cast a char to int in Java with the following syntax [ICODE](int) someChar[/ICODE] eg [ICODE]System.out.println('A' + " = " + (int ) 'A' ); // prints A = …

Member Avatar for programing
0
175
Member Avatar for turt2live

The principle is easy - on each "tick" of your clock add a small downwards increment to the Y velocity. This simulates the effect of gravity accelerating things downwards. Eg if you start with an upwards velocity it will slowly reduce to zero and then go negative. You may also …

Member Avatar for turt2live
0
313
Member Avatar for Yuri_0129

Making the buttons work has nothing to do with which LayoutManager you use. Regardless of layout you use an ActionListener to make a method that will execute when the button is clicked. Google ActionListener for loads and loads of examples of how to set this up.

Member Avatar for Yuri_0129
0
130

The End.