7,116 Posted Topics

Member Avatar for comSysStudent

line 4 looks the wrong way round - java syntax is variable = formula; You have formula = variable;

Member Avatar for ejosiah
0
147
Member Avatar for r0n

Have a look at: [url]http://java.sun.com/docs/books/tutorial/uiswing/components/formattedtextfield.html[/url]

Member Avatar for javaAddict
0
131
Member Avatar for HappyGoTyping

PoNoN1=N1+"(POSITIVE)"; You declared PoNoN1 as int, but you probably wanted String. ps: Java convention is the start all variable names with a lower case letter.

Member Avatar for BestJewSinceJC
0
108
Member Avatar for Krstevski

ps [CODE]if (some boolean expression) { return true; } else { return false; }[/CODE] is just the long way to say [CODE]return (some boolean expression);[/CODE]

Member Avatar for JamesCherrill
0
117
Member Avatar for JRabbit2307
Member Avatar for javaAddict

It's common practice in the Java API to make "utility" methods static, so that makes it OK for me.

Member Avatar for javaAddict
0
127
Member Avatar for ssDimensionss

Forgive me if I have misunderstood here, but it looks to me like you are trying to get an actual Object to put into the array - hence clone and new. Arrays don't hold Objects. Just like variables, they hold [B][I]references [/I][/B](pointers) to Objects. So if you have found a …

Member Avatar for JamesCherrill
0
89
Member Avatar for Ghost

Sorry guys, but this is a terrible example of programming. We have endles code repeated 9 times because the author dosn't know about arrays. We have if/then/else/else... constructs running on for hundreds and hundreds of lines. We have nearly 1800 lines of code with just one single comment. We have …

Member Avatar for JamesCherrill
-2
133
Member Avatar for Ranek

The whole "enter 1 or 2" thing is part of the UI, so I would put that logic in the UI class. Ie, if the user enters 1, Main should call PoundEuro, if its 2 call the other one (or vice versa?).

Member Avatar for Ranek
0
4K
Member Avatar for domenzup

I wouldn't waste a single millisecond worrying about char/Stringdouble conversion CPU usage. Whatever you do will be a fraction of 1% of the CPU used by the OS doing the socket operations. You don't need to do the conversion to int and back; just send the double in text format …

Member Avatar for domenzup
0
1K
Member Avatar for locked_twilight
Member Avatar for locked_twilight
0
951
Member Avatar for shroomiin

Since you can't return an error code from a constructor, you could throw an Exception if the parameter(s) are not acceptable: [CODE]class X { public X(int value) throws Exception { if (x<0) throw new Exception("Parameters must not be negative"); ...[/CODE]

Member Avatar for Jocamps
0
122
Member Avatar for TigerGirl

Write a small test case. If the answer's right across a few different test cases, your code is good! (It looks OK to me.)

Member Avatar for TigerGirl
0
107
Member Avatar for sxk

You declared your rectange & triange classes as "abstract". That means they cannot be instantiated. Becuase these are classes that you want to use to create rectange & triange objects, they should not be declared abstract.

Member Avatar for javaAddict
0
120
Member Avatar for Mcdermid

Google [I] java read text file[/I] then google [I]System.out.println[/I]

Member Avatar for Jocamps
0
84
Member Avatar for alkeshtech

[url]http://gafter.blogspot.com/2007/07/internal-versus-external-iterators.html[/url]

Member Avatar for JamesCherrill
0
123
Member Avatar for low1988

[QUOTE]So ,it is all about convert the string into char[/QUOTE] Not exactly. charAt is about extracting a particular single char from a String. The chars in a Java String are numbered from 0 to (length of String -1). charAt(n) gives you the char in position n in the String. So …

Member Avatar for low1988
0
708
Member Avatar for Zero-Method

Are you required to use a 2D array? If not, the Java way to do this is to create a class Address, with fields for first name, second name, address. Then you just have a simple 1D array of Address objects. Even better, if you have the choice, would be …

Member Avatar for JamesCherrill
0
89
Member Avatar for javed123
Member Avatar for balumohan2
0
152
Member Avatar for Deva.VG

Read the file into an Image, then use the PixelGrabber class to extract the pixels as an array of alpha/r/g/b ints. This gives you the image data after it has been decoded from jpeg/tiff or whatever.

Member Avatar for JamesCherrill
0
76
Member Avatar for Xessa

Have a look at SimpleDateFormat, it allows you to format dates according to your locale and your own format specification. It works with Date objects, rather than Calendars, so use the getTime() Calendar method to get the correponding Date.

Member Avatar for Xessa
0
161
Member Avatar for DARK_BYTE

[CODE]Employee[] empArr = new Employee[5]; ... for( i = 0; i < empArr.length; i++ ) ... empArr[i].setEid( in.nextInt());[/CODE] You create an array of 5 elements that can be used to hold Employees, but this does not populate the array with actual Employees. So when you try to use empArr[0] there's …

Member Avatar for DARK_BYTE
0
151
Member Avatar for whiteyoh

whiteyoh: Using an array is dumb. It's fixed size, and you have a variable number of CDs. You should use an ArrayList. I gave you this advice, and sample code yesterday. OK, you don't want my involvement, I'm outta here. Good luck anyway.

Member Avatar for Ezzaral
1
492
Member Avatar for whiteyoh

Its often a good idea in a class like this to create a static Collection that holds all the instances that have been created. This allows you to loop through all the instances counting, totalling value, searching for particular artists etc. Something like [CODE]private static ArrayList<CD> allCDs = new ArrayList …

Member Avatar for whiteyoh
0
287
Member Avatar for whiteyoh

Hi quuba: I went thru all this with him less than an hour ago - see topic "counting objects and totalling their values". He marked it solved, then asked exactly the same question. Good luck!

Member Avatar for VernonDozier
-1
101
Member Avatar for KimJack

toArray [B][I]does [/I][/B]work. There's something wrong with how you are trying to use it. Post your code.

Member Avatar for BestJewSinceJC
0
226
Member Avatar for Bloubul

Like it says right at the top: [I]Do not use Stock.setLayout() use Stock.getContentPane().setLayout() instead[/I] and... [I]at Stock.<init>(Stock.java:50)[/I]

Member Avatar for JamesCherrill
0
186
Member Avatar for Bloubul

I can't see where you add your fields to secondRow. One small point: when you catch an IOException you just exit. This will leave you with no information about what went wrong or where. You should do a printStackTrace for the exception before exiting so you know what happened.

Member Avatar for javaAddict
0
267
Member Avatar for KimJack

[QUOTE=masijade;1003243]... "\n" is platform specific and is not always guaranteed to get the effect you wanted.[/QUOTE] Just in case this matters: you can use [CODE]System.getProperty("line.separator");[/CODE] to get the line separator string appropriate to the current platform.

Member Avatar for anupam_smart
0
160
Member Avatar for Ajantis

[QUOTE]I keep getting some errors[/QUOTE] We need more information than this. [B][B]Exactly [/B][/B]what errors?

Member Avatar for quuba
0
175
Member Avatar for keekee
Member Avatar for feoperro

Have a look at JFormattedTextField in the API, if I understand your requirement properly, this may be the answer.

Member Avatar for feoperro
0
515
Member Avatar for einjelle

JAEquation = JAEq.getText(); JBEquation = JAEq.getText(); Is this second line a mis-type? (ditto for KAEquation = KAEq.getText(); KBEquation = KAEq.getText(); )

Member Avatar for einjelle
0
191
Member Avatar for sarath.koiloth

You can inherit from a single parent downwards as far as you want... A extends Object; B extends A; C extends B; etc Thus, by implication, C extends B, A, and Object. What you can't do is this: E extends F,G ie. extend from two parents at the same level. …

Member Avatar for JamesCherrill
0
133
Member Avatar for oneat
Member Avatar for javed123
0
119
Member Avatar for KirkPatrick

You can pass a reference to the main class into the constructors of the other classes, so that they can then call getter methods in the main class. Sharing the Strings themselves may be a bad idea - what happens when one of these values changes? Much better to use …

Member Avatar for KirkPatrick
0
281
Member Avatar for gururajb

No way will I try to plough thru your unindented listing without CODE=JAVA tags. However, from your problem description, you should be using a ThreadPool [url]http://java.sun.com/docs/books/tutorial/essential/concurrency/pools.html[/url]

Member Avatar for JamesCherrill
0
91
Member Avatar for Ramster

Simply: don't create a user interface. Your problem with keylogging will be getting at keyboard events when your app (which has no UI) doesn't have the keyboard focus.

Member Avatar for JamesCherrill
0
73
Member Avatar for jrosh
Member Avatar for JamesCherrill
0
71
Member Avatar for Gatayo
Member Avatar for localp

This works for me: [CODE=JAVA]qTree = new JTree(....); qPane = new JScrollPane(qTree, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); contentPane.add(qPane...);[/CODE]

Member Avatar for localp
0
3K
Member Avatar for Hidden_mistakes
Member Avatar for JamesCherrill
0
111
Member Avatar for KirkPatrick

[CODE]class DatabaseObject extends javax.swing.JPanel [/CODE] This rings all kinds of alarm bells! The normal way of doing things is to have a "database object" that encapsulates the data items and provides accessors, as well as methods for saving/retrieving them (possibly delageted). You then have a GUI object that takes a …

Member Avatar for KirkPatrick
0
99
Member Avatar for leverin4

[QUOTE]I think I run into problems with words like "dichlorodiphenyltrichloroethane". It's the longest word I have, with 31 letters. So it has 2, 147, 483, 648 combinations by itself.[/QUOTE] This suggests that you should not be creating an array with all the combinations if you don't have to; and you …

Member Avatar for JamesCherrill
0
118
Member Avatar for Raik.48

Of the various options proposed so far, the best to start with is quuba's to override the inherited toString() method in your class. As well as allowing you to simply say System.out.println(a); and get the expected rseult, this will also work if, for example, you want to display the value …

Member Avatar for Raik.48
0
144
Member Avatar for Moein.Enayati

This is why accessor methods are such a good idea. Your String should only be modifiable via a public set(...) method. That method can then take care of any side efects that are necessary. The "standard" Java approach is to use a Listener / Observer pattern; in this case the …

Member Avatar for ~s.o.s~
0
618
Member Avatar for axelle.eichner

Investigate and learn about the following: Loops, in particular loops that increment an integer variable The String class, in particular the charAt method Printing to System.out Give it a try, and when you get stuck come back here.

Member Avatar for javed123
0
148
Member Avatar for Xamas

array_of_rooms.room_status[i] = 0; should be array_of_rooms[i].room_status = 0; ie you index the array of rooms, not the status, which is not an array!

Member Avatar for VernonDozier
0
2K
Member Avatar for jrosh

[url]http://java.sun.com/docs/books/tutorial/uiswing/components/combobox.html#listeners[/url]

Member Avatar for majestic0110
0
277
Member Avatar for gururajb

Have a look at Thread Pools [url]http://java.sun.com/docs/books/tutorial/essential/concurrency/pools.html[/url]

Member Avatar for JamesCherrill
0
67

The End.