- Strength to Increase Rep
- +0
- Strength to Decrease Rep
- -0
- Upvotes Received
- 7
- Posts with Upvotes
- 7
- Upvoting Members
- 6
- Downvotes Received
- 2
- Posts with Downvotes
- 1
- Downvoting Members
- 2
46 Posted Topics
![]() | Re: Stringbuffer has a reverse method [url]http://java.sun.com/j2se/1.4.2/docs/api/java/lang/StringBuffer.html[/url] Im not sure I understand completly what you want to do though There is also a method in String called charAt(int pos) which returns the char at the given position |
Re: In drawCircle g is null. That is why you get null pointer exception and that is also why nothing is being drawn. You need to get the graphics from the Panel which is pressed. You can get this info from the event, e.getSource(); which returns an object. Type cast this … | |
Re: In your code you have the wrong comparisson: m.equals(methodObj) should be m.getName().equals(methodObj) since m contains "public void bla bla()" And when you invoke the method you need to invoke it with an instance of the class, e.g: m.invoke(new Counter(), count); I think :) | |
Re: Hi, I'm pretty sure the problem is when you create a new TestPage. Look at line 56 (and also line 84): new TestPage(quesNo++); The ++ operator increments quesNo AFTER this operation. If you want to increment it before use ++quesNo instead. | |
Re: Hi, you can use java.awt.Rectangle, however I don't think you can draw these directly using drawRect(). But you can use the x, y, width and height of your rectangles and draw. By using rectangles you can ask each rectangle if they contain a point (mouse x and y for instance). … | |
Re: I suggest you not to ignore possible exceptions | |
Re: Hi, do you mean something like this: [CODE] query1 = new JRadioButton("for uploading of file"); query1.setLayout(new FlowLayout()); query1.add(new JTextField("textfield")); query1.add(new JButton("Button")); [/CODE] | |
Re: inputArr is null, you must create the array before you use it. e.g. [CODE] inputArr = new String[8]; [/CODE] | |
Re: Isn't this because of timezones? I think you might need to adjust. Something like: [CODE] TimeZone tz = TimeZone.getDefault(); long gmtAdjust = tz.getDSTSavings()/1000; [/CODE] But I'm not really sure though... | |
Re: at Screen.restoreScreen(Screen.java:37) points to this line: dv.setDisplayMode(null); According to API: [CODE] Throws: IllegalArgumentException - if the DisplayMode supplied is null, or is not available in the array returned by getDisplayModes UnsupportedOperationException - if isDisplayChangeSupported returns false [/CODE] You should get an IllegalArgumentException though, but I think this line is a … | |
Re: Hi, I can't see any faults in your code, so my guess is that the program is unable to find the image. If your folder structure looks like this: .\src\sess31\myownapplet.java then place the image like this: .\src\image.gif or specify the location in the path. Hope this helps! | |
Re: Hi, you get the wrong result because you have the print out before the recursive call. [code=java] if(n > 0) { triangle(n-1); for(int i = 0; i < n; i++) { System.out.print("*"); } System.out.println(""); } } [/code] What happens here is that you do not print anything until you've reach … | |
Re: I think that you can write a server/client solution to get it to work. The client connects to the server which returns the content of the database. I did something like that when I needed my applet to read from a database, but I don't remember all the details. | |
Re: Hi, This is one way to do it: 1. Loop through the array and for all 0's assign its value to -1 2. Store the number of elements that is to be removed, so you know the length of the new array. 3. Create a new array and copy all … | |
Re: I think there is a method called setFullScreen(boolean value) that you can use. | |
Re: Loop through a string and for every char that is a whitespace increment a counter. | |
Re: I think you have a little design flaw. The result is not always the first input, and I think that is what is causing the problem. I am not completly sure though. Try to rethink your design with a piece of paper and a pen. | |
Re: Hi, you should really use code tags when posting code, it is way to hard to read without... Anyway, the errors I've spotted are: [code=java] private String[] keys = ("7", "8", "9", "/", "4", "5", "6","*", "1", "2", "3", "-", "0", "C", "=", "+"); [/code] When initializing arrays you should … | |
Re: Hi, J2ME does not have all the standard libraries that J2SE has. PrintWriter and BufferedReader doesn't exist in J2ME. Maybe you can use DataInputStream and DataOutputStream instead? You can do a quick search on google to get loads of tutorials and examples. Hope this helps | |
Re: Hi, Check this: [url]http://www.j2ee.me/javame/reference/apis/jsr118/javax/microedition/lcdui/Display.html#setCurrent%28javax.microedition.lcdui.Displayable%29[/url] It says that the setCurrent() call can be delayed. It also says: "If the application calls setCurrent() while a system screen is active, the effect may be delayed until after the system screen is dismissed.", so try to do: [code=java] /* "minimize" */ setCurrent(null); /* Set … | |
Re: Hi, you need to import java.io.*, and also surround with a try/catch clause. You can also use Scanner to read input. [code=java] Scanner sc = new Scanner(System.in); sc.nextLine(); sc.close(); [/code] | |
![]() | Re: I think you need to refactor a bit. Refreshing the form will be hard since all the variables are stored inside the constructor, even the input from the user. Declare all the forms and the arrayOfBooks as global, and then use the actionevent listener to fire an update of the … ![]() |
Re: I didn't read your code very carefully, but this sounds like a problem I experience from time to time. You need to close the file when you're done writing to it. Otherwise you will just create it, but it will remain empty. | |
Re: You can use LinkedList or Stack: [url]http://java.sun.com/j2se/1.4.2/docs/api/java/util/LinkedList.html[/url] [url]http://java.sun.com/j2se/1.4.2/docs/api/java/util/Stack.html[/url] [code] LinkedList<String> fifo = new LinkedList<String>(); fifo.add("First"); fifo.add("Second"); fifo.add("Last"); System.out.println(fifo.poll()); System.out.println(fifo.poll()); System.out.println(fifo.poll()); Stack<String> lifo = new Stack<String>(); lifo.add("First"); lifo.add("Second"); lifo.add("Last"); System.out.println(lifo.pop()); System.out.println(lifo.pop()); System.out.println(lifo.pop()); [/code] gives: [code=java] First Second Last Last Second First [/code] Or did you want to implement one yourself? | |
Re: Hi, Check the PIM API [url]http://developers.sun.com/mobility/apis/articles/pim/index.html[/url] I haven't tried anything like it myself though. | |
Re: The graphs I've created has been done with JFreeChart, I think it works pretty good for my needs. I found this link however that might help you: [url]http://www.codemiles.com/java/a-moving-graph-sortof-widget-build-using-swing-t373.html[/url] It is done in swing | |
Re: Hi, I think the constructor in class dvdInv is incorrect, loose the void [code=java] public dvdInvGui() { } [/code] Methods has returns types, constructors does not | |
Re: 10 = is an integer 010 = is an octal (base 8) So 010 = 1000 in binary 1000 0100 ------ 1100 = 12 I think this is how it works at least :) | |
Re: Ignore my post, peter_budo is correct :) | |
Re: Hi, when you create your array you give it the length of all the characters in the string you're analyzing, but you're not initiaing it, so it contains only null (s2[0] = null, s2[1] = null etc) since string is an object. In the last for-loop you're calling method compareTo() … | |
Re: Hi, how much realism do you want to add? I mean, real formulas or just something that looks good and works fine for your purpose? If you just want to slide the character a little distance you can perhaps use a constant slide value, and then use Sinus. Something like: … | |
Re: Get the inputs from the user and form the first 2 numbers in the fibonacci sequence, then populate the rest in a loop by sumarizing the previous two numbers. (3+8=11, 11+8=19, 19+11=30 etc) In order to decide whether a number is odd or not, you can use %(modulus)2. E.g. 5%2 … | |
Re: You're missing an import statement for FileOutputStream, other than that, I can't spot any errors with this code. I think you'll have to explain a bit more about when you get this error. In what context are you using it? | |
Re: If you're using eclipse you can choose to add them as external jars. Right click the project and select build path-> configure build path -> (Libraries tab) add external jars. | |
Re: Please correct me if I am wrong, but I don't think it is possible to send files via the serial connection, but you can use bluetooth or obex for that. What kind of file do you want to send? If it is a simple text file you can send the … | |
Re: Im not sure I understand your question, but anyway... First of all, it looks like you're sleeping the main thread, which will cause your application to freeze for a number of seconds. I might be off here but do you want to fire a new thread for each button but … | |
Re: You need to have support for JSR-75. You're phone most likely has support for it, but you might want to make sure. On my device (Sony Ericsson) the filesystem is reached through "file:\\\c:\path" and the memory card is reach through "file:\\\e:\path". | |
Re: There are some tools that can be used for that, google for jar to exe or something similar. Can't you use a jar file? I use eclipse and fatJar is working fine for me when I have dependincies. Here is an intressting article on that subject: [url]http://www.excelsior-usa.com/articles/java-to-exe.html[/url] | |
Re: Im not sure what you are asking for, but this is how you create an inner class: [code=java] public class MyClass { public MyClass() { // Constructor for MyClass } private class MyInnerClass { public MyInnerClass() { // Constructor for inner class } } } [/code] I usually use inner … | |
Re: In order to understand that I think you need to know what a sequencer is, when you know that, the statement should be fairly obvious: You get the default sequencer. [url]http://java.sun.com/j2se/1.5.0/docs/api/javax/sound/midi/Sequencer.html[/url] | |
Re: I hope I understand your question correct: You can set the tab size to zero. Right click your project and press properties. Expand Java Code Style and select Formatter. Click "Enable project specific" and press the 'edit' button. Here you can change the tab size of the indent. You need … | |
Re: This should help you out: [url]http://www.devx.com/tips/Tip/14510[/url] Just add a pop-up message when the if evaluates to false, and you're good to go! Good luck | |
![]() | Re: There is no match because you keep incrementing i only. Example: if you have the word Banana and want to find all a's: In the first iteration the string 'B' is compared to 'a' and evaluates to false, the second iteration (d has remainded unchanged thus is 0 still) is … |
Re: Javac is an exe file which resides in your jdk folder. (C:/Program/java or similair) You can either write the full path to it and the the classes you want to compile or add the path (it´s in the bin folder) to your environment variables (Right click My Computer->properties->advanced->environment variables: path) … | |
Re: Hi, I think it is because you don't have the correct fonts intstalled. It is the same thing with "\u0626" (which is an arabic character if I'm not misstaken). Try to find and install some language pack including the required font. | |
Re: With this: java.util.Date bdate = java.sql.Date.valueOf("1990-07-21"); you can get the value of a string, so get the value of the input from the user. Then you can use this value to get the day (represented as an integer): bdate.getDate() . Thats pretty much it, if you want the output to … |
The End.