7,116 Posted Topics
Re: You can download the source code for the classes in the Java SE API from the Oracle web site. | |
Re: So would I. The API doc doesn't use the term "marker" for it, so who says its a marker interface? | |
Re: So it can be accessed from outside its own package. See [url]http://download.oracle.com/javase/tutorial/java/javaOO/accesscontrol.html[/url] | |
Re: Like it says at the top of the page... [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] | |
Re: Java names are case-sensitive. Method names in the API begin with a lower case letter. Check your method names for capital vs lower case against the API reference. | |
Re: You have 689 uncorrected compile-time errors. Yet you say [QUOTE]It is strange that eclipse doesn't find any code to execute. How do you think I can possibly fix the issue?[/QUOTE] There won't be any code to execute until the compiler generates some. The compiler won't compile your code until you … | |
Re: You need to 1. Create a new XMLDecoder, passing an input stream as parameter then (and this is the bit you are missing) 2. Use the XMLDecoder's readObject() method to get the object itself. | |
Re: Short version: set your own default renderer for that cell or column using a subclass of JButton. Full version: [url]http://download.oracle.com/javase/tutorial/uiswing/components/table.html#renderer[/url] | |
Re: The problem appears to be in (String)yahooConnection.getContent() Check the API doc for this method - it returns an Object, in this case its an HttpInputStream object) and that kind of object cannot be simply cast to a String. (In fact it's not even a public class). You should probably be … | |
Re: [QUOTE=StuartMillner;1611917]thank goodness they overhauled collections... project lambda is pretty sweet too[/QUOTE] What are the changes to collections? I couldn't see anything in the release notes. AFAIK project lambda didn't make it into J7, but is still planned for J8. | |
Re: Sure, you can do that in Java, but unless there's something special you need to do why not look at a simpler solution such as an SQL database with form & report generation, or even Excel with a few macros? | |
Re: I don't understand your question. Look at the cases for 'A' and 'a' - they call a method optel() when the user chooses 'A' or 'a'. Isn't that "a normal choice"? | |
Re: abc a[]=new abc[4]; creates an array of reference variables that can refer to abc objects, but it doesn't populate those references with anything, so the initial values in that array are like {null, null, null, null}. You need to create four new abc instances for the four array elements, eg … | |
Re: [QUOTE=Majestics;1613064]My main aim is to provide a startup animation , so application before start produce a good effect on the user, like word, excel etc...[/QUOTE] You should have said that earlier. It's easy. Java 6 has a "splash screen" capability that displays an image while your app is loading, and … | |
Re: Those 3 terms are all very similar, and people will use them almost interchangeably. But here's my attempt to distinguish the main uses of them, while ignoring some of the more obscure exceptions: [B]Data [/B]is everything that's not executable code. It's the ints, booleans, bytes, Strings, arrays etc that a … | |
Re: You need to request that the new window comes to the front and gets the focus, eg page.toFront(); see this for more info: [url]http://download.oracle.com/javase/tutorial/uiswing/misc/focus.html[/url] | |
Re: Yes we can, but why should we? What have you done so far? Google search both those terms, read the excellent documentation that you will find, then come back here with any specific questions. | |
Re: Did you not read Norm's post re equals method? Or did you just decide to ignore it? | |
Re: Well, yes, Year is an array of 6 Strings, values is an array of 5 ints. What exactly do you want to do? It looks like you are trying to overwrite the initial String values with ramdom ints - does this make sense? Anyway, you can't put ints into an … | |
Re: This depends on the TableModel you are using. What is your table model? | |
Re: [QUOTE=NormR1;1612429]Using The index is the ONLY way to get elements out of an array.[/QUOTE] Or an enhanced for-each loop (may be easier)? | |
Re: [url]http://download.oracle.com/javase/tutorial/networking/sockets/clientServer.html[/url] | |
Re: Absolutely no difference at all. You can put those modifiers in any order. | |
Re: textJT array contains 6 text fields, but the clear code (line 157) only clears the first 3 | |
Re: [CODE]OutputSched; OutputSched = new OutputSched();[/CODE] The first line is just a class name on its own, the second tries to assign a new instance to an existing class name. Neither of these lines is valid Java. If you just want to create a new OutputSched then a simple [ICODE]new OutputSched();[/ICODE] … | |
Re: Your Vector does not seem to have any type associated with it, so it's assumed to contain Objects, so enu.nextElement() is seen as returning an Object. System.out.println is a bit cunning in that it secretly calls the toString() method on anything you try to print, so your enu.nextElement() gets converted … | |
Re: Suppose [I]f1=new FileInputStream(p[0]);[/I] fails. You will go to the catch block, print a message and continue. Eventually you get to [I]i=f1.read();[/I] but f1 will not have been initialised. That's the circumstance the compiler complained about. Now if you have a [I]return;[/I] in the catch block you will not continue after … | |
Re: DefaultListModel implements Serializable, so you can read/write one with a single Object I/O call, or use XMLEncoder/Decoder to write & read the whole contents as XML string data, also in a single call. | |
Re: If you're not using an applet (ie using a standard desktop app) then the applet restrictions don't apply. What you describe is straightforward. The hardest bit is how the clients get the server's IP address (unless you're happy to hard-code something). jwenting's security issues are still very real. | |
Re: Writing directly to an Excel file is possible but difficult. Why not write a simple text format file (eg comma or tab delimited) that Excel can import? That's really easy ![]() | |
Re: [I]while (strLine.length() >= 3)[/I] Once this loop has started, under what circumstances will it ever stop? | |
Re: A static variable has exactly one value, which is associated with the class itself. To access the variable you just need the class name. A non-static ("instance") variable has one value for each instance of the class that has been created. To access any one of those values you need … | |
Re: Use the join() method from the Thread class - it waits until the thread has finished. Plenty of examples on the web. | |
Re: [CODE]for (int x=0;x<3;textJT[x].setText(temp).x++);[/CODE]you probably meant[CODE]for (int x=0;x<3;x++) textJT[x].setText(temp);[/CODE]ps: many people would prefer[CODE]for (int x=0;x<3;x++) { textJT[x].setText(temp); }[/CODE] | |
Re: Redirect System.out Something like... [CODE]String fileName = "whatever.txt"; final boolean append = true, autoflush = true; PrintStream printStream = new PrintStream(new FileOutputStream(fileName, append), autoflush); System.setOut(printStream);[/CODE] | |
Re: What's missing in your code is all the e.printStackTrace(); statements in your catch blocks. Right now you could be getting any of those exceptions and you won't know. As a general rule you should NEVER have an empty catch in a new program unless you are very sure why you … | |
Re: Hi Majestics. Can you explain what this is about in terms that we all can understand? I'm completely baffled by the OP's version. | |
Re: Two comments: 1. [I]if (someCondition== true[/I]) is a bit silly. What's wrong with [I]if (someCondition)[/I] 2. [I]for (int i = somePositiveIntegerValue; i < 0; i--){...[/I] // eg your line 86 How many times will this loop execute (when will i<0 be true)? | |
Re: You are trying to read from some kind of input stream, but the data is in the wrong format. This can happen if the format for reading doesn't match the format in which it was written, or the stream hasn't been closed properly, or you try to read the same … | |
Re: If you want an application (not on a browser) then forget applets and servlets, as these are for browsers. Java GUI applications are normally built using the Swing classes that come with every Java installation. If the GUIs run on remote machines accessing a shared database server then you have … | |
Re: [url]http://java.sun.com/developer/technicalArticles/ALT/Reflection/[/url] See the sample code under heading "Creating New Objects" about 2/3 down the page. | |
Re: In your btOK ActionListener just create a String with the desired text in it and use the label's setText method to update it with that String. Use setHorizontalAlignment to centre a JLabel's contents inside the JLabel. To centre the JLabel in the window use a Layout Manager (see previous post). … | |
Re: Previous code is a good example of why an ArrayList is a better choice than an array for returning an unknown number of Objects - there's no need to size it, just keep adding Objects until they are all added. | |
Re: from the JComboBox documentation... [QUOTE]setSelectedIndex(int anIndex) Selects the item at index anIndex. setSelectedItem(Object anObject) Sets the selected item in the combo box display area to the object in the argument.[/QUOTE] | |
Re: Although you can in theory put pretty much anything you like on the clipboard, it can be difficult. You can use XMLEncoder to convert your Swing objects to a simple text String that is really easy to put on the clipboard, and XMLDecoder to re-create the object from the clipboard … | |
Re: You really don't need to do this all one char at a time. The String class has all the methods you need working with whole strings at a time, eg [QUOTE]indexOf(String str) Returns the index within this string of the first occurrence of the specified substring.[/QUOTE] as in [CODE]index2 = … | |
Re: It's a myth that Java is slow. The JRE is highly optimised and performs comparably to [I]ordinary [/I]C++ code. Only in the most performance-critical CPU-intensive tasks will you see any real benefit from [I]properly tuned[/I] C++ Have a look at [url]http://scribblethink.org/Computer/javaCbenchmark.html[/url] that was 2004, but the JRE has only improved … | |
Re: That's right. Java is only pass by value, regardless of whether parameters are primitive types or reference types. [QUOTE]When the method or constructor is invoked (ยง15.12), the values of the actual argument expressions initialize newly created parameter variables, each of the declared Type, before execution of the body of the … | |
Re: Your initial value for smallest is 0 - think that through. What result do you expect with that starting value? If you still don't get it post again and I'll give you a more explicit hint. ps: Please post all code in code tags in future. | |
Re: The exception message includes the exact line where it was thrown, ie Home1.<init>(Home1.java:32) what is the code at that line? |
The End.