7,116 Posted Topics

Member Avatar for MissJava

You declare [I]int Value[][/I] so [I] value[b][/I] on line 134 represents an int. ints (like booleans and floats) are "primitives", not Objects, so they do not have methods. That's why your code [I] Value[b].equals...[/I] gives an error - yuo try to call the equals(..) method on a primitive that does …

Member Avatar for JamesCherrill
0
7K
Member Avatar for betny

Assuming this error is around line 88 (and next time please post the line number with the error messages!) you define a 3-dimensional array,, but try to initialise it with data in the form of a 2-dimensional array. So when it looks inside the 2d array it expects to find …

Member Avatar for betny
-1
187
Member Avatar for ecclesiastes3:1

[QUOTE=Shubham266;1631548]you hv to take container class refernce like contaner c; // before constructor then c=getContentPane(); //in the starting of constructor c.add(start); /*after the buttons setbounds c.add(controls); c.add(credit);[/QUOTE] This code is obsolete. The need to add things to the content pane, rather than just the JFrame, was an annoyance in early …

Member Avatar for ecclesiastes3:1
0
300
Member Avatar for krovi

Google [I]java 1.5 whats new?[/I] and this is the very first hit: [url]http://download.oracle.com/javase/1,5.0/docs/relnotes/features.html[/url]

Member Avatar for JamesCherrill
-1
139
Member Avatar for krovi

Java has primitives, like int boolean float etc, and classes like Integer Boolean Float etc. You use the primitive when you just want a value, and the class when you want to use its more interesting methods. Before Java 1.5 you had to convert between the two explicitly, but now …

Member Avatar for JamesCherrill
0
49
Member Avatar for nera1981

By line 52 you have variables containing the id, name, category and price. At line 18 you have a constructor that takes id, name, category and price and creates a Products instance. So all you need to do is call the constructor passing the values.. easy peasy! ps: Each instance …

Member Avatar for nera1981
0
158
Member Avatar for AJG

When you subclass Tile you re-declare variables private Image tileImage; private boolean tilePassable; private int x,y; in each subclass. Now you have two versions of each variable, the subclass ones "hide" the inherited ones and you end up having to duplicate inherited methods to word with the duplicated variables. Simple …

Member Avatar for AJG
0
287
Member Avatar for warlord902

If I understand the question then, no. It's nothing to do with what language. If you put a new character into a file then either it overwrites an existing char or you have to move the rest up to make space for it.

Member Avatar for warlord902
0
2K
Member Avatar for jinglylime

print(anyObject) automatically calls anyObject.toString() to get a printable version. All objects inherit a version from the class Object, which shows the class name and a hex reference for the particular instance, eg "Deck@6612fc02". You can override toString in your own classes to print something more useful. You did this for …

Member Avatar for JamesCherrill
0
114
Member Avatar for sathya88

You define a whole load of menu items on lines 16-48, but in your follwing code instead of using those items you create new local variables (lines 61-66 etc), so whatever you do with those local variables has no effect on the instance variables that defined earlier. In particular, the …

Member Avatar for JamesCherrill
0
233
Member Avatar for SurrounD

Two ways: 1: Do some arithmetic using i and j the first row is 1,2,3,4 The second is 5,6,7,8 which is also 4+1, 4+2, 4+3, 4+4 The third is ... 8+1, 8+2 etc see the pattern? 2: you have a nested loop that you can use to access all the …

Member Avatar for SurrounD
1
144
Member Avatar for DarkPheonix

Most people have absolutely no idea just how much optimisation is applied to code after it enters the compiler and before the actual hardware memory locations in the runtime system get updated, so trying to double-guess the impact of a small code change is probably futile (but the answer will …

Member Avatar for DarkPheonix
0
895
Member Avatar for singh_soorma94

If you don't get 3 better contributions, feel free to use this. You should be able to run it. I wrote it as a quick check for how CPU usage scaled with number of sprites. I removed the comments as requested, but feel free to ask questions. J ps: It …

Member Avatar for sirlink99
0
161
Member Avatar for Majestics

You can subclass JToolTip to create a custom appearance etc, then subclass the control in question to override its public JToolTip createToolTip() method (inherited from JComponent) to return an instance of your customised JToolTip subclass.

Member Avatar for mKorbel
0
158
Member Avatar for sankarnarayanan
Member Avatar for Ezzaral
-3
33
Member Avatar for dhija22

The constructor defines its parameters as a String and two ints. When you call it you pass three Strings. "1" is a String, 1 is an int. ps Next time, please post the exact error message that you get. It makes our lives a LOT easier!

Member Avatar for dhija22
0
414
Member Avatar for thompsonSensibl

Basically you can't create a new variable name for each Person object like that. That's where the collection comes in. You need a collection of Person objects. At your stage it may be better to stick with a simple array of Persons to hold your collection; you can learn about …

Member Avatar for JamesCherrill
0
135
Member Avatar for superjj

Yes, it's possible to set the exact pixel position and size of every component in your GUI, but that's not a recommended solution. Java has a choice of layout managers to help you position and size your components so that they still look right even if the system font changes, …

Member Avatar for JamesCherrill
0
103
Member Avatar for thompsonSensibl

That's an "enhanced for-each loop" - a new feature in Java 1.5 It uses and array or any other collection (eg List) of things, and iterates thru them one at a time. In your case closest is an array of "P" objects, and the for loop is read as [CODE]for …

Member Avatar for peter_budo
0
144
Member Avatar for naffan

In checkCourse you continue to loop and re-set "matched" after finding a match, so it will only return true if the string matches the very last element in the array. You need to exit the loop as soon as you find a match. Assuming courseObjects[] is some kind of variable, …

Member Avatar for JamesCherrill
0
216
Member Avatar for Vongola_Takeshi

Are you sure it didn't open it? It looks like your button handler creates a new MyForm and makes it visible exactly like you do in main(...) - so the new MyForm will be identical to the existing one and sit exactly on top of it, so it looks like …

Member Avatar for Vongola_Takeshi
-1
9K
Member Avatar for dhija22

This is a duplicate of "help with me object and methods" thread. Maybe a mod. can shut it down?

Member Avatar for JamesCherrill
0
120
Member Avatar for PROgamer

Check the API reference. A JToggleButton is "An implementation of a two-state button. The JRadioButton and JCheckBox classes are subclasses of this class" A JButton is "An implementation of a "push" button."

Member Avatar for JamesCherrill
0
49
Member Avatar for vishal1949
Member Avatar for naffan

some observations: saveStudent 4: the "true" in the FOS specifies append mode, so that's why the file keeps growing. saveStudent 5: what's arrayStudent and why do you use it? Exception (non) handling. You seem determined to ignore IOExceptions. This is always a mistake. Catch them, and printStackTrace() the exception so …

Member Avatar for naffan
0
174
Member Avatar for muff1n

IMHO the official Java tutorials from Sun/Oracle are hard to beat. [url]http://download.oracle.com/javase/tutorial/uiswing/index.html[/url] There are other learning resources listed in the pinned topic at the head of the main forum page.

Member Avatar for muff1n
0
179
Member Avatar for nomin-ginger

You'll need a loop, executed (length of string)/5 times You can use the substring method in the String class to pick out 5 chars starting from an arbitrary start point... Try doing this once by hand on a piece of paper to understand the exact sequence of steps, then convert …

Member Avatar for sathya88
0
316
Member Avatar for abhinavM

[QUOTE=abhinavM;1627027]I want to create a new variable with each run of this while loop ... like str1(for 1st run),str2(for 2nd run) and so on [/QUOTE] Short answer: you can't create new variables names like that at runtime. That's what arrays are for - str[1]. str[2] etc. Why do you think …

Member Avatar for Majestics
0
12K
Member Avatar for kehayov

In your original code insert a print statement immediately after line 88 (in.read) to print the value of ch. Then you will be able to see exactly what's happening.

Member Avatar for JeffGrigg
0
163
Member Avatar for Aviras

I don't see anything fundamentally wrong with your current approach.I've used it myself more than once. It's just a bit fiddly getting the network setting right. Assuming your server is on a LAN sitting behind a NAT router: Open a firewall exception on the server PC to allow incoming connections …

Member Avatar for Aviras
0
287
Member Avatar for sathya88

things like dir are commands processed by cmd.exe - the windows command processor. You can explicitly run one of cmd's commands with the /C option, eg cmd.exe /C dir and you can use processbuilder to create a suitable process as in Process p = new ProcessBuilder("cmd.exe", "/C", "dir")

Member Avatar for JamesCherrill
0
8K
Member Avatar for mith_cool

You are OK about instance & class vars, instance variable are one per object created, class vars are one shared between all objects of that class. but the static keyword defines a class var. It's an instance var if it does NOT have the static keyword.

Member Avatar for JamesCherrill
0
177
Member Avatar for llemes4011

I can't speak about the C++ side, but Java TCP/IP is just plain old vanilla TCP/IP. I've had no problems using it to communicate with TCP/IP-based embedded systems that certainly are not Java.

Member Avatar for llemes4011
0
266
Member Avatar for sachinpkale

What OS are you using? Under Windows that should be [B]echo %PATH%[/B] ps: Have a look at the ProcessBuilder class in Java 1.5 and later - it's intended as a better replacement for Runtime.getRuntime().exec()

Member Avatar for JeffGrigg
0
175
Member Avatar for baby_c

Firstly, "run anyway" is a waste of time - if there are compiler errors then you need to fix those before attempting to run anything. Secondly, if you comment out lines of code from your algorithm then of course it won't work. Thirdly, make sure every catch block has an …

Member Avatar for JamesCherrill
0
382
Member Avatar for Whilliam

JavaDB is the SQL database packaged with JDK 1.6 and 1.7 It's the same database engine as Derby, but slightly differently packaged. You do [B]not [/B]need to download any part of Derby to use JavaDB under 1.6 or later; tt is automatically included and installed as part of the JDK. …

Member Avatar for Anuradha Mandal
0
192
Member Avatar for Jaydenn

Have a look at ByteArrayOutputStream. It's an OutputStream that writes the data directly to an in-memory self-expanding byte array, from which you can access the bytes directly.

Member Avatar for JamesCherrill
0
219
Member Avatar for sirlink99

A JFrame consists of a Content Pane surrounded by borders etc and, as you have observed, its size includes the (system-dependent) borders. To achieve your desired result, set the (preferred) size of the JFrame's Content Pane (access it via myFrame.getContentPane()) rather than the JFrame itself.

Member Avatar for JamesCherrill
0
149
Member Avatar for venktech

Override paintComponent, not paint. This restricts your (re)paint to the client area only. Do not override repaint, just call it when necessary. Do not call super.paintComponent in your paintComponent, because that's where the old content is being cleared. Just go ahead and paint the new stuff. For more details see …

Member Avatar for venktech
0
371
Member Avatar for akasekaihime

Didn't read all yuor code, but you cant do an implicit multiply with brackets, eg a(b+c) in Java. In Java that looks like a call to method a with parameter value b+c. You have to use an explicit multiply operator, a*(b+c)

Member Avatar for hfx642
0
168
Member Avatar for sathya88

Its for advanced debugging/tuning. You probably will never need it. [url]http://www.java-tips.org/java-se-tips/java.lang/how-to-use-verbose-option-while-running-a-java-applic.html[/url]

Member Avatar for JamesCherrill
0
64
Member Avatar for Scicluna

Short version: Storing passwords in plain text, regardless of database vs file etc is a no-no; it's just too vulnerable to exposure. A normal practice is to create the password, get its MD5 digest (easy in Java, just Google it) and store that instead. When the user next enters a …

Member Avatar for Tellalca
0
446
Member Avatar for Pytho

[QUOTE=Ezzaral;1622193]You could extend JLabel to maintain a reference to the object, in which case the listener could retrieve it directly from the clicked label...[/QUOTE] This would be the obvious strategy, but there's no need to extend JLabel to achieve it. Every swing component has a "client property" map where you …

Member Avatar for JamesCherrill
0
176
Member Avatar for arka.sharma

Suggest you have a look at the source code for ArrayList. My guess is that it allocates an array of some default size and adds elements until that's full, at which point it copies the existing data to a new larger array then releases the old one - thus giving …

Member Avatar for JamesCherrill
0
125
Member Avatar for stokotten

A statement like that needs to be inside a method (eg the constructor)* * yes,there are other places, but they're not in the Java 101 syllabus.

Member Avatar for Aviras
0
479
Member Avatar for phoenx

Do you mean that you want to animate the display of the numbers so they slide down out of sight and the next number slides down from the top? If so, you need to override paintComponent for the text fields and draw the text at an x,y position where the …

Member Avatar for phoenx
0
213
Member Avatar for ba.accounts

Stop thinking about 2d arrays. Java arrays are one-dimensional. It's just that the data type for a java array can itself be an array, so you can nest arrays within arrays (etc). It just so happens that a java array whose elements are arrays all of the same length looks …

Member Avatar for ba.accounts
0
2K
Member Avatar for anuj_sharma

Hi, JC here again. Could you be referring to my prior post? If so. thank you. In real life people use complex tools (UML modelling) to do this kind of thing, but for starters I would recommend keeping it simple and low-tech. I've used this technique many many times when …

Member Avatar for JamesCherrill
0
170
Member Avatar for Srin

I looked at your final version. Of course it won't compile, so can't be the code you actually ran. (That doesn't help diagnose you know, when the code you post isn't the code you had a problem with). Anyway, I fixed the missing semicolons and the static method references to …

Member Avatar for JamesCherrill
0
297
Member Avatar for ranu jain

Standard OO procedure: Go through the spec underlining all the important nouns to get possible classes, eg [U]Menu [/U] 1. Register a [U]customer[/U] 2. 3. park [U]car[/U] Register a [U]vehical [/U]for a customer 3. Issue a [U]pass [/U]for the customer Some will turn out to be unnecessary, and some will …

Member Avatar for ranu jain
0
380

The End.