7,116 Posted Topics
Re: 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 … | |
Re: 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). | |
Re: 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 = … | |
Re: 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 … | |
Re: 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 … | |
Re: 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. | |
Re: Is this an applet or an application? They are started in different ways. What is the exact "proper java command" you are using? | |
Re: 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 … | |
Re: 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 … | |
Re: 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. … | |
Re: 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 … | |
Re: 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 … | |
Re: 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 … | |
Re: 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 … | |
Re: add a MouseListener to your JLabel. Do what @cretaros said for details | |
Re: 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 … | |
Re: 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. | |
Re: 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 … | |
Re: 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 … | |
Re: 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 … | |
Re: [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 … | |
Re: 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) … | |
Re: 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 … | |
Re: 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 … | |
Re: .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 … | |
Re: 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. | |
Re: 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 … | |
Re: 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 … | |
Re: 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 … | |
Re: 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 … | |
Re: 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 … | |
Re: To do that you must convert the ints to Strings. You can use the toString(int i) method in the Integer class. | |
Re: 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 … | |
Re: 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. | |
Re: 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, … | |
Re: 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 … | |
Re: 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. | |
Re: 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 … | |
Re: Look to me like you need to print some blanks in front of the numbers. | |
Re: 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 … | |
Re: 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. | |
Re: 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 … | |
Re: 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. | |
Re: 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 | |
Re: 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. | |
Re: What is it with you and all these text decorations? Anyway. Q1 answer No. Q2 answer Yes | |
Re: 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) | |
Re: 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. | |
Re: 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. | |
Re: [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 … |
The End.