7,116 Posted Topics
Re: [url]http://docs.oracle.com/javase/tutorial/java/javaOO/accesscontrol.html[/url] | |
Re: I can't see where Generics comes into this - you just need a Worker class and a Work interface that work units all implement. ps (Apart from when you create your queues etc, but that's just stuff like Queue<Work> = new Queue<Work>(); what I meant was that I can't see … | |
Re: Can you create the map as Map<String, SomeObject > ? | |
Re: @csanuj: 1. This thread is from 2008 2. If that was supposed to be an answer to this long-dead thread, it is completely wrong anyway. | |
Re: It sounds like you are looking for [B]source code management software[/B] Have a look at [url]http://sourceforge.net/apps/trac/sourceforge/wiki/What%20is%20Source%20Code%20Management[/url] CVS, Subversion and Git are very widely used for Java projects, but there are many others and everyone has their own preferences. | |
Re: It looks like your paint method should loop thru all the shapes in shapeList drawing them, not just the latest one? ps don't override paint(Graphics g), override paintComponent(Graphics g) [url]http://java.sun.com/products/jfc/tsc/articles/painting/[/url] | |
Re: In your valueChanged method ev.getSource() will just be the list box itself, which you probably knew anyway. You can use list.getSelectedValue() to find out which object in the list is currently selected inside your valueChanged method. ps @stultuske: in this particular case both getSource and getSelectedValue return the actual object … | |
Re: Did you mean javac javaclassname.java or java javaclassname | |
Re: This is a common symptom, and the usual cause is that Java is looking for the icon files in the wrong place. new ImageIcon(iconName) will not throw an exception if there is a problem, it just returns null. If you pass null to a JLabel or JButton for the image … | |
Re: If your images don't appear this may be relevant... [url]http://www.daniweb.com/software-development/java/threads/403274/1724025#post1724025[/url] | |
![]() | Re: Have you filled your Board with non-transparent components? ![]() |
Re: Using someone else's code for your homework is called "cheating". Nobody here is going to help you cheat. Write your own code and you [B][I]will [/I][/B]get help. | |
Re: Maybe those method [B]definitions [/B]belong in the class they apply to, ie in Student there is a [I]delete(Student s)[/I] method, in Course there's [I]delete(Course c[/I]) etc etc. (These should probably be just named [I] delete()[/I] defined as instance methods.) In a typical controller class you will [I]call [/I]those methods, but … | |
Re: When you have a serializable class you're supposed to define a serialVersionUID that ideentifies the version of the serialized form - if you change how it's serialized you're supposed to change the serialVersionUID. It's a complete waste of time and a real annoyance. Either ignore it, or create a private … | |
Re: What are you doing? This is a duplicate of your post 2 days ago, with exactly the same code mistakes, and completely ignoring the input you got from your previous post. | |
Re: (u == user) As gets posted here about once a week on average... don't try to compare Strings with ==, use .equals instead. Google for details. | |
Re: [QUOTE=predator5047;1722115]I do not understand what you wanted to do with this: [CODE]for ( int i=0;i<=size;i++){ if(array[i]==array[i].length-1) ... }[/CODE] You are just comparing the number stored in array[i] with the length of the array minus one.[/QUOTE] Not even that really. It's just some invalid uncompilable code that doesn't actually do anything. … | |
Re: total and total1 are local variables in methods sample and sample1 respectively. They do not exist outside those methods, and cannot be accessed from outside those methods. | |
Re: Remember Java chars are numeric - ordinary characters correspond to integer values under 128. If you have an array of 127 ints you can use a char as the index to access an element of the array and increment it... | |
Re: [CODE]if(num<=min){ num=min; count=0; }[/CODE] You start with min=0, so how often will num be less that that? [CODE]for(;;){ if(num==0) break; ... [/CODE] I see what you intended here, but the more usual way to code that is [CODE]while(num != 0) { ...[/CODE] And finally, indenting your code will make it … | |
Re: You are confusing Objects with variables. A variable is reference (pointer) to an Object. You can't assign null to an Object - that doesn't even make sense. You [I]can [/I]assign null to a variable - it means that the variable stops referring to an Object and now refers to nothing. … | |
Re: [CODE]while (true) {// Game Loop c.repaint(); }[/CODE] This is really not a good idea. You tie up a thread running as fast as it possibly can, triggering repaints at an arbitrary but very high rate. It's going to burn all the CPU it can, and will run at completely different … | |
Re: [CODE]Login required = new Login(); int pass = Login.accessGrant;[/CODE] Here you create a Login() then immediately query the value of its accessGrant variable. That query happens before Swing gets to display the dialog, and certainly long before the user could enter anything. | |
Re: ... but even better: create class as above. Add a variable for amount, that can be set by a parameter in the constructor. When adding instances of this class to each button pass the appropriate value into the constructor. Now there's no need for getSource or a switch or any … | |
Re: You could use an inner class for the listener that has the x,y coordinates as instance variables, that can be set by parameters in the constructor. When adding instances of this class to each button pass the appropriate values into the constructor. Now there's no need for getSource or any … | |
![]() | Re: Glad that' solved, so here are a few comments for next time... That's Java code and Java syntax problems, so this is the right forum to post in. [ICODE]while(grade.equals("A" + "B" + "C" + "D" + "F"))[/ICODE] I think I can guess what that was intended to do, but it … |
Re: 1. For GUI -related timing you should use a java.swing.Timer rather than a java.util.Timer because it integrates with the whole swing event queue/ thread environment. [url]http://docs.oracle.com/javase/tutorial/uiswing/misc/timer.html[/url] 2. If you are updating some thing that affects the GUI you need to call repaint() or one of those methods to let the … | |
Re: [CODE]ImageIcon tenP = new ImageIcon("10p.jpeg"); tenP = new JButton("", tenP); (etc)[/CODE] You declare tenP to be an ImageIcon, OK, but then you try to assign a JLabel to that variable, not OK. You need to create a different variable for the JLabel itself. | |
Re: Just start with the server. Write your code in small steps and test/debug each step by hard-coding some data and print statements. Maybe the first few steps could be: Write the Book class. Test it by creating and printing a couple of instances. Start the Server class - read the … | |
Re: DaniWeb Member Rules include: "Do not hijack old threads by posting a new question as a reply to an old one" [url]http://www.daniweb.com/forums/faq.php?faq=daniweb_policies[/url] | |
Re: IMHO Java itself is more solid than the OS it runs on, [I]but [/I]Java's support for serial comms is very old, and was never very solid in the first place. I did a project years ago to interface with a serial hardware control device (multiple digital I/O lines) and found … | |
Re: There are many formats for sounds to play, and many possible sources to play them from. There are classes to play various formats from various sources, all different classes. But they all implement the same interface, so they all support the same calls to their play methods. This means that … | |
Re: [CODE]p2.setLayout(null); p2.add(label, BorderLayout.CENTER);[/CODE] Why set a null layout then try to use a BorderLayout option? If you want a null layout manager then hypou have to supply complete bounds for p2. [CODE]ImageIcon img = new ImageIcon(x);[/CODE] There's a gotcha with new ImageIcon - if it fails for any reason whatsoever … | |
Re: You can populate a JComboBox with any kind of Objects, and it will use the objects' toString() method to display the object, but when you query the selected item you will get the original object. If you don't want to have your toString() method just returning the name, then use … | |
Re: [CODE]Scanner scan= new Scanner(inputFile); String N= scan.println(N):[/CODE] I don't know how you can read anything with this code - it won't compile - there is no println method in Scanner (not to mention the missing catch) | |
Re: [QUOTE=hfx642;1718333]Sounds like you want to do ObjectInputStream and ObjectOutputStream to read and write binary files.[/QUOTE] I think this is a slip of the keyboard - should be DataInputStream and DataOutputStream ;) | |
Re: Duplicate thread [url]http://www.daniweb.com/software-development/java/threads/401345[/url] 03hasnam: Simply re-posting it is an insult to hfx642, NormR1, and stultuske who have already taken time to answer this the first time you posted it. DaniWeb Member Rules include: "Do not post the same question multiple times" | |
Re: Lines 17,18 are executed regardless of whether you have found the account to delete or not - they are outside the if test. | |
| |
Re: Like it said: [I]Recompile with -Xlint:deprecation for details.[/I] then post the resulting details back here if you don't understand them. | |
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 doing your homework for you. DaniWeb Member Rules include: "Do provide evidence of having done some work yourself if posting … ![]() | |
Re: Draw 14 rectangles in the right positions! Post the code you have written so far. | |
Re: If line 14 throws an exception then you will get to line42 with f1 not initialised. Similarly for f2 ps NEVER do this: [CODE]catch(Exception e) { }[/CODE] when you get any error of any kind in the try block you will see no error message of any kind, and will … | |
Re: 1. Surprisingly, it seems that output to System.out doesn't get sent to the console until the line is terminated - I reproduced this behaviour in Eclipse as well, but I'm sure that's not always so. 2. Please see my latest post re wait/notify. If you have a quick look at … | |
Re: Change the code in your previous post/question to make B b static. Now you have 2 threads each calling the sum method on the same object (static b). If sum is synchronised then the second thread will be held up and won't be able to start executing sum until the … | |
Re: I certainly have done my share of multithreading and scraping in my time, but not a lot with proxies. But I'm with Peter here: "bots for multiple account creations" sounds very suspicious indeed, and I won't have anything to do with it unless I see a genuine justification. | |
Re: Three personal opinions: 1. An IDE is a very useful tool for someone who knows what they are doing, but for a beginner (like most posters here) it leaves most of Swing, eg layout managers, listener classes etc as a mysterious black box. Most experienced users here recommend that beginners … | |
Re: Here's an overview of a typical way to do this: Create the spheres as instances of a Sphere class- each Sphere with its own size, position, velocity. Maintain a list of all the spheres you have created. In your main method start a javax.swing.Timer to call an update method on … | |
Re: Unless the applications are math-based you need very little math to work in Java. Basically just arithmetic and logic. Very little algebra, no geometry, no calculus. |
The End.