7,116 Posted Topics

Member Avatar for Fumomo

Way back in LayoutDemo, when you create the two panels, you can send the Test instance a reference to the to OrderDetails instance (use a public set... method in Test that accepts an instance of OrderDetails as parameter and stores a copy of it. Now your Test instance can access …

Member Avatar for JamesCherrill
0
740
Member Avatar for lacoffo

I would pass the PrintWriter as a parameter to all the WriteData methods. So it's created and closed in the same place as the loop (eg your Main program).

Member Avatar for lacoffo
0
261
Member Avatar for jeffrey o

String[] result; declares a String array variable, but it doesn't create String array, so it's just a null pointer at this stage. When you try to use it you get as null pointer exception. You must also create an empty String array to store values into with a result = …

Member Avatar for javaAddict
0
232
Member Avatar for scarletfire

1. The Comparator interface requires two methods (check out the Comparator API JavaDoc). Does your code compile? [QUOTE]a new Constructor for the Club class that takes the Comparator<Player> parameter.[/QUOTE] Your constructor takes another Club as parameter, so obviously not right. This part of the exercise is actually a lot smaller …

Member Avatar for JamesCherrill
0
115
Member Avatar for anaana

If you push the letters on to a stack the first letter will be at the bottom of the stack and the last letter will be at the top. Now if you pop them off the stack you will get the last letter first, and the first letter will be …

Member Avatar for JamesCherrill
0
198
Member Avatar for shyla

All it's saying is look for any variables or methods that are the same in all the subclasses and move those into the superclass so they only appear once. Each of the subclasses will inherit them all from the superclass, so there's no need to duplicate them in every subclass.

Member Avatar for JamesCherrill
0
297
Member Avatar for jeffmummey@sbcg

Is this an applet or an application? They are started in different ways. What is the exact "proper java command" you are using?

Member Avatar for sirlink99
0
169
Member Avatar for Maelst0rm

Who told you not to use JButtons? If it was your teacher then you have no choice, but if it was someone else then I would disagree. A grid of buttons (or JLabels) would be a perfectly sensible implementation. So, if you're stuck with one panel... you have the mouse …

Member Avatar for JamesCherrill
0
774
Member Avatar for newbieha

You have 2 nested loops, which will get you every possible combination of name & id. But what you want is just the matching name & id for the same student - something like [CODE]for i = 0 to (number of students) list.add (new Student(studentName.get(i), studentID.get(i)) ... for (Student s …

Member Avatar for JamesCherrill
0
89
Member Avatar for chinee

You are thinking of a random access RW file, presumably for in-place updating, but for the size you have here it would be much easier to just read the whole file into a suitable collection/class structure at startup, and write the whole thing back out (overwriting the file) at shutdown. …

Member Avatar for JamesCherrill
0
131
Member Avatar for charchar88

In your decomnpress I would stay with boolean operations as in encode,and forget the arithmetic. ie Delete lines 29/30 - this is definitely going to mess up any values starting with a 1 bit (ie sequences beginning with G or T - eg second test case) replace sequence[i]%4 with sequence[i]&3 …

Member Avatar for charchar88
0
253
Member Avatar for chinee

A team is a Team, and an int is an int. You are trying to assign the value 0 to an instance of Team, ditto compare it to an int, and add 1 to it. You should be using an int to index your array in yourt loop. ps The …

Member Avatar for chinee
0
128
Member Avatar for niranga

From the EditorPane you can get its EditorKit, and from that you can get the Document itself. You can add a DocumentListener to the Document to be notified of all changes the user makes. Send those via the Socket connection. At the other end you can insert (or remove) the …

Member Avatar for JamesCherrill
0
279
Member Avatar for coolbeanbob

That's the right approach, but you should not use hex constants as in Niuranga's code. The JavaDoc for KeyEvent has the following warning: [QUOTE]WARNING: Aside from those keys that are defined by the Java language (VK_ENTER, VK_BACK_SPACE, and VK_TAB), do not rely on the values of the VK_ constants. Sun …

Member Avatar for niranga
0
1K
Member Avatar for techie929
Member Avatar for JamesCherrill
0
98
Member Avatar for warlord902

I've never tried this, but the nodes in JTree are rendered by default using JLabels. You can put multi-line text in a JLabel by using simple HTML, so maybe you can use HTML to get multi-line nodes? Try a node with text like this: <HTML>line 1a<BR>line1b<?HTML> you never know... Just …

Member Avatar for warlord902
0
1K
Member Avatar for turt2live

You re-load the image from file every time you draw it. That's wh yit's slow. Read the file and create the buffered image once, at startup.

Member Avatar for turt2live
0
279
Member Avatar for muteki

list.get(1) returns the HashMap that is in position 1 in the ArrayList. When you print that HashMap you get its default output, which is a list of the key=value pairs in the HashMap {id=2, pass=muteki, user=muteki} list.get(1).get(1) gets the first HashMap then calls get(1) on that HashMap. Now check out …

Member Avatar for khamsinh
0
4K
Member Avatar for Majestics

Assuming, for the moment, that this isn't any kind of copyright violation, even if you add a "Save" button, what will it do when pressed? Will you need to access the internal data of the app so you can save it? If so, it may be easier to re-write the …

Member Avatar for mKorbel
0
189
Member Avatar for Tarkenfire

Check out how a switch works - you haven't quite understood it properly... [url]http://download.oracle.com/javase/tutorial/java/nutsandbolts/switch.html[/url] The critical sentence on that page is [QUOTE]The switch statement evaluates its expression, then executes all statements that follow the matching case label.[/QUOTE] Have a look at the first example on that page. Can you see …

Member Avatar for Tarkenfire
0
114
Member Avatar for jaxber

[QUOTE]Also, 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] Nobody here will do this for you. Make a start and …

Member Avatar for JamesCherrill
0
252
Member Avatar for sciprog1

Despite appearances that ian't a file. The .class operator is used with a named class to get the Class Object representing that class. So DefaultWeightedEdge.class returns an instance of class Class representing the DefaultWeightedEdge class. It's passed as a parameter to a method to tell the method what kind (class) …

Member Avatar for sciprog1
0
217
Member Avatar for TheBadger

Your description isn't enough to go on really - eg what is the purpose of the Menubehaviour interface and where is that implemented (etc)? Anyway, there's nothing wrong with adding Actionlistener(s) to your menu items in the View class. The actionPerformed method(s) can then immediately pass responsibility to the appropriate …

Member Avatar for JamesCherrill
0
88
Member Avatar for jrp370

Mattox is right. It's probably a problem in your run configuration. In particular check that your "main class" is MailClient in the run configurations dialog. [QUOTE]see if ... its just eclipse being a pain [/QUOTE] The usual way that Eclipse is a "pain" is because it insists on helping you …

Member Avatar for jrp370
0
119
Member Avatar for sj5536

.net and Java have very similar capabilities. The important difference is that .net is very much tied into Windows and gives a "perfect" Windows look and feel, but doesn't run on Linux (other than thru cludges with Wine) or Mac. Java apps are portable across all desktop platforms, but always …

Member Avatar for mKorbel
0
123
Member Avatar for toferdagofer

Looks like Exceptions being thrown and chained inside AGI - is the is Asterisk interface? If so, you will probably get an answer from their support forum.

Member Avatar for JamesCherrill
0
188
Member Avatar for jfountai

A couple of observations: 1. You have 3 consecutive try/catch structures. If the first one fails you log the error - good - but then go on to try to access the file anyway. It would be better to put all that IO code in a single try/catch so that …

Member Avatar for jon.kiparsky
0
174
Member Avatar for unrealj

Here's an overview of the norml way to structure this kind of code. You already have most of the bits, but in the wrong order! Make BattleShip a non-abstract class so you can create an instance of it. Don't extend anything, just let it be what it is - the …

Member Avatar for unrealj
0
186
Member Avatar for pooran.c

for(int j =1;j%8!=0 ... why not just for(int j =1;j<8 ... if(j==3){System.out.println("");} looks very wrong, and is why you are getting extra line breaks. Remove it and the formatting is OK apart from the very first line. I suspect the mystery thing you are doing with "some" at the start …

Member Avatar for pooran.c
0
164
Member Avatar for kukuruku

It tests curIndex to see if it's valid as an index for appObj.array. If it's not valid then the method sets the display to blank, after which it can't do any more so it returns directly to the caller. If it's valid then it goers on to set the display …

Member Avatar for RunTimeError
0
105
Member Avatar for Kuroshi

RMI provides a high-level interface for remote method invokation (via sockets, of course) so the server can "directly" call methods on the client (and v.v.), but there's quite a learning curve if you don't need all its facilities. Sending a String or int to invoke specific functions is a pretty …

Member Avatar for Kuroshi
-1
1K
Member Avatar for pooran.c

To do that you must convert the ints to Strings. You can use the toString(int i) method in the Integer class.

Member Avatar for pooran.c
0
245
Member Avatar for jackmaverick1

add is't static because you add a JThingy to an instance of JFrame, not to the class JFrame. Here the normal template for stuff lkike this [CODE]public class Main extends JFrame { ImageIcon ic1=new ImageIcon("12471.jpg");//12471 is an image :) JLabel lab1=new JLabel(ic1); ... public static void main(String []args) { new …

Member Avatar for JamesCherrill
0
151
Member Avatar for sakurayana

we can add "no indentation" to that as well. Stephen: have you upgraded your crystal ball to 1.6u22 yet? I hear that there are problems with temporal leakage in the future vision support.

Member Avatar for jwenting
0
145
Member Avatar for newbieha

Your current code has a single variable "button" that you use to create all 5 buttons. Nothing wrong with that, although sooner or later you will want to use an array of buttons as per mKorbel. Anyway, after exiting your setup loop "button" is left referring to the last button, …

Member Avatar for newbieha
0
108
Member Avatar for ckwolfe

Not sure I understand the whole of your requirement, but If PlotExpression needs a value for stringFunction in order to work, and especially if that value is unlikely to change within one instance of PlotExpression, then passing it as a parameter to the constructor would be the obvious way to …

Member Avatar for JamesCherrill
0
139
Member Avatar for jackmaverick1

The problem is that you don't have all the needed ones. Or, possibly, you have found a bug in the Java compiler that not one of the thousands and thousands of users have discovered in the last 2 decades. So, less self-confidence and more careful code reading.

Member Avatar for jackmaverick1
0
94
Member Avatar for Naruto1

You have loops that look like this one: [CODE]for (i = 0; i<sportEvent.length; i ++) { System.out.println(sportEvent[i].getTitle());[/CODE] but there is no guarantee that the array is full of actual data, eg if you have an array of size 8, and have entered 6 records, the last two slots in the …

Member Avatar for Naruto1
0
701
Member Avatar for liphoso

Look to me like you need to print some blanks in front of the numbers.

Member Avatar for dononelson
0
128
Member Avatar for chinee

Teams = new [32]; (etc) You have to say what it is that you have a new 32 element array of, eg myCharArray = new char[32]; ps Next time, don't just post bits of the compiler error message, post all of it INCLUDING the source code line number where the …

Member Avatar for chinee
0
2K
Member Avatar for TinyBelly

Do you mean that you want to pass the value of one radio button (boolean selected/not selected) OR do you want to pass info about which radio button was selected in a button group? These are different options, that have different solutions.

Member Avatar for mKorbel
0
1K
Member Avatar for SilentHunter13

The only thing on that line that could be null is connectionToFirePlaceDB (easily checked by printing this variable immediately before that line). Which makes connectionToFirePlaceDB = DriverManager.getConnection("jdbc:odbc:FirePlace"); the prime candidate for where the problem starts. Especially since the idiot who coded this chose to catch any errors from the getConnection …

Member Avatar for JamesCherrill
0
228
Member Avatar for TinyBelly

P:ut a print statement at the start of the ActionPerformed to see if it's being called. If so, it's an error inside the logic of that method.

Member Avatar for JamesCherrill
0
211
Member Avatar for MWE_QUE

Vector<Question> questionList; ... out.writeObject(questionList); This will need the Question class to be declared as " implements Serializable ". As it only has Strings and an int, there's no need to do anything else

Member Avatar for MWE_QUE
0
1K
Member Avatar for harinath_2007

Read the JavaDoc for the SwingWorker class. The introductory section explains a bit about EDT and has a sample code that shows how to use a progress bar with a long-running process.

Member Avatar for JamesCherrill
0
109
Member Avatar for I<LateNupurGuha

What is it with you and all these text decorations? Anyway. Q1 answer No. Q2 answer Yes

Member Avatar for Chaster
0
147
Member Avatar for softswing

Without the code or the full details of the Exception we can only guess. But in general an OutOfMemoryError happens because (a) you have a ginormous amount of data in memory or (b) your code is stuck in a loop creating the same objects over and over again (more likely)

Member Avatar for JamesCherrill
0
248
Member Avatar for TinyBelly

5-6 lines down in the stack we see at ticketReservation.<init>(ticketReservation.java:114) at bookAngels.actionPerformed(bookAngels.java:163) the line numbers don't match the code you posted, so you need to look at the constructor for ticketReservation line 114 and see which variable is null.

Member Avatar for stephen84s
0
147
Member Avatar for bibiki

Windows? There is a system environment variable CLASSPATH that contains a list of all the places (paths) where Java must look to find classes. Either your jars go in one of those places, or add the path to where they are on to the CLASSPATH.

Member Avatar for mKorbel
0
130
Member Avatar for yunus2807

[QUOTE]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] ps: This is an incredibly badly designed exercise. Using a "series of arrays" is as far from good Java design …

Member Avatar for JamesCherrill
0
160

The End.