7,116 Posted Topics
Re: 1. Is the setIcon being executed? (put a print starement just before it to confirm) 2. Is the label big enough to display the icon? 3. Is the ImageIcon being read properly - new ImageIcon throws no exceptions and issues no errors if it fails, it just gives you anempty … | |
Re: > I cant get the paint part or the programme to work properly That's nowhere near enough info. Exact problem please. | |
Re: Yes, it is entirely possible. Sorry Nutster, your answer is completely wrong. Java has the ability to run external processes. In older versions of Java it used the Runtime class, modern versions use ProcessBuilder. You can start an external process and pipe its standard input and output and error streams … | |
Re: It's hard to know where to start with so little info about the problem. You say you "cannot get the radio buttons to work". What exactly does that mean? They don't appear, they don't change when you click them, your listener isn't called, your listener is called but doesn't do … | |
Re: Yes, you could. But you (and anyone reading the code) would need to know what each column in the array represented, whereas if they were different 1D arrays then their name would tell you what they were. For this reason, I think a 2D array is a bad idea. | |
Re: Line 8 seems to be the start of a method definition, but it's inside another method definition (starting line 5), which is illegal. Lin 18 you have name followed by type (eg i int) when it should be the other way round (eg int i) | |
Re: DaniWeb Member Rules include: "Do provide evidence of having done some work yourself if posting questions from school or work assignments" "Do not hijack old threads by posting a new question as a reply to an old one" http://www.daniweb.com/community/rules Please start your own new thread for your question and show … | |
Re: JTable's getValueAt(int row, int column) method returns the value in any cell, so you can loop thru any col you like getting the values and adding them up. | |
Re: A LayoutManager is how you do it - looks like there's some (small) error in how you have chosen the parameters, that's all. Are you specifying where in the layout the panels should be added? If you just add them they both go in the centre. ps: this is a … | |
Re: public void printBackward(int n) ... addLast(list1); printBackward(); count --; Despite the missing parameter that looks like an attempt at recursion to me :) | |
Re: You will need to put your images into the jar file. See this recent thread: http://www.daniweb.com/software-development/java/threads/431552/jar-problem-in-pictures | |
Re: You seem to be asking for two things: 1. Make the table wide enough to show all the text 2. Make the table fit in the frame without scrolling You can't have both when the text is long, so what is your *single* requirement? | |
Re: What do you want to happen in the second launch if it discovers that there is already an open window? Just exit? Request focus for the existing window and exit? Continue executing without a window and communicate somehow with the existing window? Something else (if so what)? | |
Re: This is the Java forum; your code is not Java. Is it JavaScript? If so there's a forum for that http://www.daniweb.com/web-development/javascript-dhtml-ajax/117 | |
Re: You have code to track the Rectangle defined by the mouse drag operation. I haven't checked that, but you also clear that Rectangle when the mouse is released, so then you are left with nothing. When the mouse is released, instead of clearing the variable, you can use that selection … | |
Re: The {} in this context define a literal array, as in int a = 1; int[] b = {1,2,3}; int[][] c = {{1,2,3},{4.5.6}}; // 2x3 "2D" array (array of arrays) so `{{1}}` defines a 2D array 1 row, 1 column, containing the single value 1. `{{1}}[0]` selects the first element … | |
Re: Mike. That's a very big question, and I doubt that anyone has the time to write a new document covering all those topics. You'll find loads of stuff on the web for beginners. Please chekc that out first, then come back with specific questions. J | |
Re: That's a queue of ints, where generics won't do anything for you. But suppose you have the same thing but you want to store any kind of info. Before generics you would make everything an Object, eg `private Object[] items = new Object[5];` Then if you wanted to store Strings … | |
Re: > i have to define compareTo method itself? > isnt it inbuilt function? Node is a class that you have created, so there's no way Java can know how you want to compare or sort its instances. Eg for a Person class you may want to compare/sort by family name/given … | |
Re: The fact that it works on localhost does seem to suggest a network problem such as firewall, but your code doesn't show your exception handling. Do you catch and `printStackTrace()` all possible exceptions? | |
![]() | Re: Your puzzle is defined in the String INITIAL_BOARD, which is hard-coded, but it would be easy to read those 9 lines of text from a text file instead. Then you can have any number of puzzles by just creating new files in a text editor. |
Re: No time to read the whole code now, but iut seems setcbo is called to update the cb after the delete, but in setcbo I can't see where you delete the original contents - mabe your updated stuff is just being added on the end? | |
Re: Hi stultuske. Mimi seems to have edited his/her post out, so your comment is left with nothing to refer to. With your agreement I'll delete both posts completely OK? | |
Re: Norm's answer was correct up to Java 1,5 Since then boxing and unboxing casts (ie between primitives and the appropriate wrapper class, eg char and Character) are explicitly defined and allowed in Java language spec: > 5.5 Casting Conversion > Casting conversion is applied to the operand of a cast … | |
Re: "won't work" tells us nothing. Next time post the *complete* text of your error messages. Anyway, your variables daily,weekly,quaterly,bianually,yearly are not initialised. | |
Re: Assuming you have a JRE on the target machine you just have to copy the jar onto it and double-click the jar for your program to execute. Do you have any resources outside your jar that the program needs to run (eg database)? | |
![]() | Re: How often do you call that update method, and from where (thread/loop/timer?)? Do you really keep adding key listeners every time you update the position? ![]() |
Re: You havr a nunber of options - redraw ther background is one, put the robot in it's own swing component is another. [This tutorial](http://docs.oracle.com/javase/tutorial/uiswing/painting/index.html) is essential reading, not too long, and will give you the info you need. | |
Re: Pseudo code can be a useful tool for explaining algorithms etc, but by doing that you have still deprived the OP of the chance to learn how to solve the logical problem for themselves. Follow Norm's frequent approach of getting the OP to do it by hand on a piece … | |
Re: A agree with both previous posts. If you are an "expert" Java developer a good IDE can give you much higher productivity, but for a learner they just add complexity and confusion. | |
Re: Don't worry, you are not violating any rules! In Eclipse select your project, then export... from the File menu That displays a "Choose export destination." dialog from which you chose Java/Runable Jar, which takes you (first time) into a new Jar wizard. YOu can save your jar settings back into … | |
Re: 1. This is a very old dead thread. If you need help, start a new thread of your own. 2. This thread already contains enough information for you to get started. Have a go, make some effort, and if you get stuck explain what you have done so far and … | |
Re: I have no idea what this means, but I do know that someone in "Executive Management" should have better communication skills. What exactly is it you "want", and why do you think anyone is just going to give it to you? | |
Re: Provide an example: eg I have an array {1,2,3} that needs to be "extended" to length 8. What should the result look like? | |
Re: A [][] array is an array of arrrays. First you need to initialise the first/outer array, then you need to initialise the inner/second arrays, although you can do both at once provided all the inner arrays are the same length eg` int[][] blocklist = new int[6][3]` Your code just initialised … | |
Re: DaniWeb Member Rules include: "Do provide evidence of having done some work yourself if posting questions from school or work assignments" [url]http://www.daniweb.com/forums/faq.php?faq=daniweb_policies[/url] | |
Re: You don't say which action listener you are talking about - the empty one or the not implemented one. And what exactly does "keybindings fail" mean? ps Don't use `System.out.println(e.getMessage());` , use ` e.printStackTrace();` instead so you can see where the error happened as well as what it was | |
Re: There are 3 "versions" of Java - ME, SE, EE ME is for phones etc. SE is the ordinary desktop version. EE is SE plus stuff for entrprise-scale applications (big web servers & databases etc). As a "home" user you would normally go for SE. Java FX is an add-on … | |
Re: You can add an item to a JComboBox by using its addItem method, eg `myComboBox.addItem(myTextField.getText());` You can repeat that for both combos to add the item to both. | |
Re: If this is a Swing app that needs its GUI refreshed every second then I would advise a Timer rather than doing your own thread. (Either will work, but a timer is less likely to give you problems.) Have a look at javax.swing.Timer You create one that runs every 1000 … | |
Re: Since Java does not a 32 bit unsigned data type the "right" answer to this depends on what you want to use it for. Is this for writing/reading compatible files? If the php version is a 32 bit positive integer then a Java long with the same value will have … | |
Re: At a quick look it seems you may not be clearing the Graphics before drawing in the new position, so the old drawing in still there. ps If possible you should update your AWT components to the Swing equivalents, if only to get double-buffering as standard so you can simplify … | |
Re: AFAIK there isn't a calendar GUI component in the standard Java API. You will find some proprietary ones on the web, but most are not free. | |
Re: > if (option == "F" || option == "f") Here's your problem. == tests for two objects being exactly the same object, but option is something you just read from the scanner, and "F" is a String created at compile time - they are two different objects, so the == … | |
Re: The Math.pow method simply takes two parameters and raises the first to the power of thesecond, ie `a^b` in maths translates to `Math.pow(a,b)` in Java | |
Re: DrEinstein - please wrap your Einstein-sized intellect around the fact the OP said "I am studying for our final exam tomorrow." and that was 2 months ago. Your hope that "I helped at least a bit" is unrealistic. Please check the dates of posts before replying. | |
Re: Java Language Spec says: > 5.3 Method Invocation Conversion > Method invocation conversion is applied to each argument value in a method > or constructor invocation (§8.8.7.1, §15.9, §15.12): the type of the argument > expression must be converted to the type of the corresponding parameter. > Method invocation contexts … | |
Re: > i have to post it to have this kind of style of coding and printscreen it for our project So you are just posting to this topic so you can get your code nicely formatted for your own use? You have no need for anyone's participation, nor do you … | |
Re: The key thing that you have to do first is to replace all those b1 - b48 variables with an array - then yhou'll be able to pick one at random, plus your code will be a lot lot shorter because you can replace each block of 48 almost-identical lines … | |
Re: When your object has no remaining references it can be garbage collected. Because you have no remaining references there is no way ever to get it again (excluding very technical/obscure stuff with garbage collection internals). As Norm says Strings are highly optimised in Java, so depending on how "asd" is … |
The End.