1,678 Posted Topics
Re: It can do a lot more if you use the web development forums. | |
Re: I don't know what the name of your class is, but I do think I know why you are getting static reference errors. You are in a static method, main (look at the declaration of the method - it says static), and you are probably trying to put things into … | |
Re: Yes, it is possible. It is actually pretty easy. Before you get into it though, I'd recommend that if you have different sized panels, you do not use cardlayout, as I tried this, and it is very difficult to resize them. [url]http://java.sun.com/docs/books/tutorial/uiswing/layout/card.html[/url] Use this link to learn how to do … | |
Re: You managed to make the try catch block. Now all you have to do is System.out.println(variable nexocentric told you to output). Debugging is a very important part of programming, so you need to learn to do it. Debugging tools are very helpful, but I personally prefer print statements. If you … | |
Re: What are you having trouble with? You said you're having trouble storing things in a list, but I see from your diploma code where you add the thing to the TreeSet that you are doing this fine. An ArrayList works the same way. Going off of JavaAddict's earlier example, ArrayList<People> … | |
Re: For testing whether or not a Character is a digit, you can use the Character class's method isDigit(). So, for example, [CODE=Java] String s = stdin.readLine(); for(int i = 0; i < s.length(); i++){ if (s.charAt(i).isDigit()){ System.out.println("It's a digit!"); } } [/CODE] But for your purposes, if you don't want … | |
Re: The problem is 1. You didn't post your [I]properly formatted[/I] code in code tags so it is hard to read your code. 2. You never explained what you want to be output. What is the content that should be in the file? Is it an array of ints, called myInts? … | |
Re: Personally I wouldn't listen to anyone who pastes code at you and doesn't explain it at all, but that's just me. I don't understand what you mean by "median of three", care to explain? | |
Re: [url]http://java.sun.com/j2se/1.4.2/docs/api/java/awt/Graphics.html[/url] This class^ pretty much has all the methods you need. drawRect and drawOval or fillRect and fillOval are probably the ones you will use. What you need to do is shown here: [url]http://java.sun.com/docs/books/tutorial/2d/geometry/primitives.html[/url] . I can never remember when you're supposed to override the paintComponent method instead of the … | |
Re: I don't really understand you, no. But if you're trying to do different chats then you need to use separate threads.... | |
Re: Just increment an int until it is less than a certain value or something if you don't want to take Vernon's advice. int i = 0; do{ i++; } while(i<10000000) | |
Re: Yeah, I think the clever code is called a runtime error. I'm no expert though. | |
Re: I'm sure there is a better way to do this, but for lack of any other responses right now, why don't you use the substring method and the equals method to determine whether something matches the pattern? | |
Re: You are reading from and writing to the same file. After you are finished reading everything from it, delete the file, [I]then[/I] write to the file. Then tell me if you are still having problems. Without reading the PrintWriter documentation, it seems like it is just appending the new text … | |
Re: I remember a discussion about this on Daniweb before. You might want to do a search for it. But I'm pretty sure the only way to do what you want is to read the file, delete it, and write what you want the file to be back to the same … | |
Re: By any chance do you go to umbc . . ? This just looks somewhat similar to a program they typically have students do (although the one they do is a lot more complicated, but that could be because you just started or omitted code, etc). Could also just be … | |
I'm using netbeans and I have a problem. I'm using a card layout to flip between multiple windows. Two of these windows are wider than the others, and this cannot really be helped. Ideally, it would be best to design each window so that they are all the same size, … | |
Re: You can do all of this in one class if you really want to, but there is no need to do so - you can just as easily do it the way you have things set up. The way to make a button do something when it is clicked is … | |
Re: I think he wants to do something more like int total = 0; //where array is an array of strings for (int i = 0; i < array.length; i++){ total+=Integer.parseInt(array[i]); } | |
Re: It seems like you would have to do a few things to compare two Infinite Integers. 1. Does one have more nodes than the other? If so, the one with more nodes is greater, since each node holds 3 numbers. 2. Do they have the same number of nodes? If … | |
Re: [QUOTE=bahr_alhalak;854624] 1)What is the difference between an instance data field and a static data field?? [/QUOTE] [URL="http://java.sun.com/docs/books/tutorial/java/javaOO/classvars.html"]You need to look things up on your own.[/URL] :) | |
Re: To "delete" stuff from the text file, you have to read in the entire file, while deciding what you do and don't want in it, then write the output (the stuff you [I]do[/I] want in the text file) back to the same file. You can do this one of two … | |
Re: You need two methods because there are two independent patterns in that picture. The first pattern is the one that looks like: * ** * And the second pattern is the one that switches between printing 4 stars and 8 stars. All you need for the first method is something … | |
Re: Is there any reason you extended Applet and not JApplet? Just curious; I have no idea if it matters or not. | |
Re: I don't know if this is relevant or not, since looking at your code, I see nothing really. But to switch the item in the combo box you'd just use jComboBox.setSelectedItem(index). And your method would obviously have to check the array to make sure you're in bounds, then flip to … | |
Re: [QUOTE=compscinerd69;854102]The programming assignment is to implement a class Purse. A purse contains a collection of coins. Each coin object must contain its name. You should not put a limit on the number of coins that a purse can hold. This program should provide the user with the ability to display … | |
How can I check if an event is user generated? When the user clicks on a combo box and changes the displayed/selected content, I want the code in the itemStateChanged method to be executed. But I only want this code to be executed if the method call was due to … | |
[CODE=Java]java.util.Vector<EmergencyContacts.ContactInfo> contacts = Application.getPatient().readEmergencyContacts().readContactInfos(); for (int i = 0; i < contacts.size(); i++){ EmergencyContacts.ContactInfo info = contacts.get(i); } public Vector<ContactInfo> readContactInfos(){ return contacts; } private Vector<ContactInfo> contacts = new Vector<ContactInfo>(); [/CODE] As you can see, it returns a Vector of ContactInfo. Why would I be getting an error saying, "Exception … | |
Re: You cannot compare Strings using '==' you must use the String class's equals method. if(titlelisting.getSelectedValue()=="OxbridgeBaby") | |
Re: We don't do problems for you, we help you do them. Ask a more specific question. If you just want the code I'm sure you will find it all over the internet anyway. This isn't exactly an original problem. | |
Re: Yes, but that still isn't a question, it is a project description. In order to help you without doing your project for you, we need to know specifics about what you're having trouble with, where in the code, what you've attempted, what isn't working, etc. "What isn't working" is usually … | |
Re: To do it with netbeans, you add one JTabbedPane to a JPanel or JFrame. Then I think you add JPanels to that JTabbedPane, and it automatically makes these JPanels into tabs. To flip between the tabs, you click them on the side where it has the listing of all your … | |
Re: You can use the removeElementAt method to remove the last item. To know where the last item is, your program can either keep track of the size of the Vector, or you can use the Vector class's size() method. [url]http://java.sun.com/javase/6/docs/api/java/util/Vector.html[/url] | |
Re: Yeah, if you want a hello world program, I'll do it for $5 | |
Re: char dash = phoneNumber.charAt(1); Why do you seem to think the character at that index is 1? That will only be the case if you enter it in the form 1-whatever. Since you determined that your '-' is at phoneNumber.indexOf("-"), the next part of your phoneNumber is going to be … | |
Question directed at JamesCherill specifically, (and anyone else who can answer it) I've never had [I]too[/I] much trouble with communicating between the model and the view, in an application that only has a model and a view. However, looking at the observer pattern (at the bottom) of this [URL="http://leepoint.net/notes-java/GUI/structure/ui-model-communication.html"]link[/URL], I … | |
Re: Yes, read it in as a String and print it out. ? | |
Re: If you were to make this Friend into a Java class, would it implement Professor? | |
Re: It depends on what programs you are running and what is taking up your RAM. Vista definitely isn't using more than a gig, so I would say it is probably bad. But like I said. . it depends what you are running. | |
Re: I'm hardly an expert, but have you tried programmatically "clicking" the menu item again after the JPanel is set visible? That might make it appear on top again. Worth a try anyway, although even if it works, there is probably a better solution. I ran into a similar problem but … | |
Re: Use the String class's toCharArray method, putting the entire String into a character array. Then you can check each index to make sure the correct thing is at the index. For the indexes that contain numbers, you can use the Character class's isDigit method. There is also a more elegant … | |
Re: No, certainly do not try any software provided by anyone with 5 posts, especially when there is a solution which involves nothing except the OS. In other words use Jbennet's solution. | |
Re: When you have GUI applications, they usually should run on the [URL="http://java.sun.com/docs/books/tutorial/uiswing/concurrency/dispatch.html"]Event Dispatch Thread[/URL]. The EDT is what James is talking about when he says the Swing thread. Since you are waiting for a connection on the EDT, you are blocking the thread, since a Thread can only do one … | |
Re: Yes- you do need to use good design to become a good programmer. However, don't let that article discourage you. I think you said you just started programming - a chat application is not something most people who just started programming would have much of a chance at completing successfully. … | |
Re: I don't know how insistent you are on using whatever field you're using now, but one example of how you can display a number without the commas: [CODE=Java]import javax.swing.*; public class FormatField { public static void main(String[] args){ JFrame frame = new JFrame(); JPanel panel = new JPanel(); frame.add(panel); JFormattedTextField … | |
Re: So if they type in $PART2, you WANT it to print error postfix expression? edit: It probably isn't working because you didn't prompt the user for input before the second loop. So it says while(scanner.hasNext()), but you never prompted the user (using a println statement), so it never entered that … | |
Re: if(letter == "$PART2") You can't test a String's contents by using '=='. It only works for primitive types, String is an Object. Use the String class's equal method | |
Re: Location start = getStart(), current; You should check that that line is doing what you want it to. |
The End.