7,116 Posted Topics
Re: > This is what i have so far. Please don't think we are fools. We know where you copied that from, and so will your teacher after 15 seconds with Google. Copying someone else's answers is likely to get you an automatic fail of your course, and possibly being thrown … | |
Re: There are lots of people here who will freely give their time to help you become the best Java programmer you can be. There's nobody here who is interested in helping you cheat or doing your homework for you. DaniWeb Member Rules (which you agreed to when you signed up) … | |
Re: PrintWriter and PrintStream both implement a println method. Read their API doc for details. ps: Your last three posts are still not "Solved". What's the problem? | |
Re: It can't read the image file. Possibly because the file is invalid, but much more likely it's looking for it in the wrong place. Java's default folders are often a source of confusion. To see where Java is looking for a file (eg "images/image1.jpg") you can use something like this … | |
Re: JTextField will fit to the text in it when you pack() its container (more precisely: it updates its preferred size to fit the text, and the layout manager uses that). | |
Re: The message is not showing because you have not written any code to show it. In your catch block, instead of printing "wrong" you should print the exception. | |
Re: You don't seem to put anything in your scroll pane? `setLocationRelativeTo(null);` works OK. If it's centering the TL corner then it sounds like swing thinks your JFrame is empty when you execute that. Why do you want to set sizes explicitly in pixels? YOur app is going to look pretty … | |
Re: Holding a ref to an object that's in a list won't affect the list's reference count because the object does not have a reference to the list. Either you have a reference to the list itreslf that's still active, or maybe GC just hasn't got round to deleting it yet. | |
Re: I'm no regex expert, but my guess is that you can't, or, if you can, it's ludicrously complex. The real question is: why? Why not just run two simple replace commands with two simple regexs? | |
Re: If you have an em-dash then the file is not ASCII encoded! ASCII is a 7-bit code that includes only the english alphbet, numbers and a handfull of puctuation (not em-dashes), so any other characters will be unreadable when you specify ASCII as the character set. Simply leaving out the … | |
Re: Java support for media has beena shambles inthe past - JMF never worked properly. The good news is that JavaFX is now a standard component in all the current versions of JavaSE. JavaFX has excellent support for media. See this recent thread - especially the last two posts http://www.daniweb.com/software-development/java/threads/475808/how-to-play-mp3-files-in-java-using-eclipse | |
Re: How about thy multi-user chat/picture sharing thing? (Client/server, threads etc.) You can build that into something quite large & complex if you keep adding features. Start by designing a generic framework, then implement the specific app by building on that - that's like a lot of well-designed projects. | |
Re: What do you mean by "can't run it"? - YOu don't know how to, you try to run it but nothing happens, you run it and you get an error message (if so- -s aying what?)... ? | |
Re: Sorry, but yes, the answer *is* in the API doc! Just look for the addXxxListener methods (being alphbetical, they're conveniently near the beginnning of the summary list). Dopn't forget to look at the methods inherited from superclasse as well. Here's a great tutorial http://docs.oracle.com/javase/tutorial/uiswing/events/ and this page includes a table … | |
Re: You can use the `java.beans.Introspector` class to get the `BeanInfo` for your bean. Then use the `BeanInfo` to get the `PropertyDescriptors`. That gives you an array of all the properties, from which you can call `getReadMethod()` to get each of the bean's get methods. You can `invoke` those methods to … | |
Re: Congratulations on a really interesting question! I think the answer is that the load() method (line 9) satisfies both the requirements of the interface and the abstract superclass, so that's OK. | |
Re: Did you really mean to add the same JPanel both to another JPanel and an JFrame? You seem to have a BorderLayout on your frame (see 82) yet I found three places where you add a component to that frame without specifying a location (80, 81, 89 - duplicate). Sticking … | |
Re: Exactly which line does the error message point to? | |
Re: The loop at line 26 keeps calling selectJLabel. selectJLabel creates a new instance of the LabelListener class each time it's called. So you keep creating new instances until you run out of memory. There isn't enough info here to say how the program should be re-structured, but the while loop … | |
Re: What exectly do you mean by " how two exception handle"? As soon as your code throws an exception, the rest of the block stops executing, so you cannot throw two exceptions at the same time. ps. Your example code is perfectly legal, but also misleading. It's very odd to … | |
Re: ArrayStoreException extends RuntimeException, so it's unchecked IllegalArgumentException extends RuntimeException, so it's unchecked Simply.... if it extends RuntimeException or Error it's unchecked, otherwize it's checked. > The unchecked exception classes are the run-time exception classes and the error classes.The checked exception classes are all exception classes other than the unchecked exception … | |
Re: There's no such thing as a "compile time exception" in Java. There is no instance of that term anywhere in the Java language Specification. The compiler will check that your code handles "checked" exceptions, but all Exceptions are thrown at run time. Maybe you are reading something written by someone … | |
Re: No, they are package access by default, justlike ordinary methods. The error message refers to a constructor with a `long` parameter, but the only constructor takes an `int`. Creation or modification of Swing components should normally be done on the Swing thread. Sleeping during a constructor while changing a swing … | |
Re: The actual parameter that is passed to your paint method will be an instance of `Graphics2D` - which is a concrete subclass of `Graphics`. ps: If you previous posts have been answered then please mark them "solved" | |
Re: Your getters & setters seem OK. Was he referring to lines 86, 90, 94? Those are hard-coded values where presumably you are expected to prompt the user to input a value? Have you covered the use of Scanners in your class yet? | |
Re: OK. Nobody here thinks you are a cheater, so don't worry. People suggested that the "complete solution" that someone else posted could be an encouragement to cheat, but nobody suggested that you copied it. You're here to learn, so are we all. Let's just keep helping each other. JC | |
Re: This is a case where your first solution is good, and anonymous inner classes don't help. You could attach the color as an attribute of each radio button With Java 8 you just create a method rather than a class eg void changeColor(ItemEvent e, Color c) {... then use lambdas … | |
Re: Everything to do with Swing (eg painting the screen, running actionPerformed methods) happens on a single thread - the "Event Dispatch Thread", or "EDT", or "Swing thread". That means that once your actionPerformed method starts NOTHING else will happen in Swing, including no screen updates, until your method finishes. You … | |
Re: The problem is in the sequence of events... You check the inputs and set the boolean when the user clicks the button, but you check the value as part of your initialisation (line 27), which is before the user could possibly have entered anything or clicked the button. You will … | |
Re: When the compiler is compiling the Component class, its source code will have an `import java.awt.Color;` or somesuch as part of its definition. That tells the compiler that Component class needs to use the Color class, and the compiler generates all the necessary code. | |
Re: Access to a computer and the internet. Reasonable logical intelligence. Willingness to work. Time. | |
Re: > constructs a Rectangle object Read the API documentation for the Rectangle class - especially its constructors > calls to translate and grow should ... these two methods are also documented in the API documentation http://docs.oracle.com/javase/8/docs/api/java/awt/Rectangle.html ![]() | |
Re: Remember also that your class extends JApplet, and you inherit all JApplet's methods and can call them directly. | |
Re: Hi Mike, welcome back! Hope you're fully better now. Did you see the Oracle tutorial on client/serve sockets? It's definitive... http://docs.oracle.com/javase/tutorial/networking/sockets/index.html JC | |
Re: What exactly is your question? ps: You do not want to open a new database connection every time the user presses "next/suivant". Just do it once, as part of the initialisation. | |
Re: I know nothing of Opportunity, but for 10% chance you use Math.random() to get a random double >= 0.0 and < 1.0 Something like if (Math.random() < .10) // draw 2 cards else // draw one card | |
Re: You declare the parameter(s) of a constructor just like an ordinary method eg public CheckDate(String mmddyyyyString) { ... then call them passing parameters also like an ordinary method, eg CheckDate cd = new CheckDate(input.nextLine)); | |
Re: It's available from amazon.com at about half price (USD20). Personally I would avoid books, which are always out of date, and go with online materials. Oracle's "official" Java tutorials are excellent - not easy, but comprehensive and authoritative, and free. http://docs.oracle.com/javase/tutorial/uiswing/index.html | |
Re: Yet another good example of why not to use a null layout manager! Swing doesn't know how big the panel is because there's no layout manager to set it. If you use `setPreferredSize` to give the panel a size bigger than the scroll pane's viewport, the scroll buttons will appear. | |
Re: 1. You can use `b.remove(i)` to remove entries. Loop down from the end of the list to the beginning to avoid confusing your loop's indexing when you delete an entry 2. You can't use any ordinary iterator because they don't allow you to change the List while iterating. But... a … | |
Re: Yes, people here will help you. Explain what you have done so far and exactly what help you need. Remeber that nobody here will do the work for you, but they will help you to learn whatever you need to do it yourself. The more effort you put in, the … | |
Re: I can't see anything in the bytecode that would explain a speed difference, and caching at the RAM level isn't going to be relevant, so maybe this is a low-level hardware thing - pipelining and branch prediction at the CPU level maybe??? If you refactor that into a runnable program … | |
Re: That's far too vague. We need more information about what you have tried and exactly what problem(s) do you have. | |
Re: This depends on whether the value is a primitive (int etc) or an object. If it's an object then all your variables are pointers (references) anyway. | |
Re: This is a very specialist subject - it's possible nobodyhere has any experionce with jpos. The jpos web site links to a user group and a developer's forum - you'll probably have more luck there. | |
Re: 9: ... textField.toString() ... If textField is a JTextField or similar then this is a mistake. The toString() method gives you a String description of the text field object and all it's parameters. Use getText() to get the text that's displayed in the text field. | |
Re: The first computer I ever used was am IBM360/30 with 64k ram and a 3.6 meg hard disk. Programmed exclusively with punched cards. I was lucky, the people who went through IBM new employees training one month before me started with some machine that was programmed by moving plugs and … | |
Re: Exactly what code do you execute in the actionPerformed for your "next" button? | |
Re: Which line is the exception thrown from? | |
Re: In the first case all you are asserting about linksSet is that it is a Set. Anyone using linksSet will only be able to use Set's methods. Maybe later you will want to change the implemention eg to a TreeSet for some reason. By defining things that way you can … |
The End.