Aeternus
Senior Members-
Posts
349 -
Joined
-
Last visited
Content Type
Profiles
Forums
Events
Everything posted by Aeternus
-
It'll depend on how your motherboard is laid out. Check the manual and it should tell you where to stick the two sticks to get it to use Dual Channel (some motherboards are colour-coded for the different channels and some can't handle more than a certain frequency in both dual channel setups etc so...).
-
I think what Klaynos meant to say was "It even does subtraction procedures by addition" (as using Twos Complement and slightly modified Adder circuits it all works out nicely, so 6 - 4 is just 6 + -4 etc)
-
With regards to the palindrome check, if you simply convert the integer to a string (trivial, there'll be plenty of examples of this around, just using mod 10 and division to work out the digits and then adding a constant to put it in the right ascii range). Then you can do something like - int palindrome ( char *theString ) { unsigned int length = strlen( theString ) - 1; unsigned int counter = 0; int palindromeFlag = 1; while ( counter < length ) { if ( theString[counter] != theString[length] ) { palindromeFlag = 0; break; } length--; counter++; } return palindromeFlag; }; Obviously you would need to make sure when generating the string you null terminate it (ie this isnt a fully functioning stand alone code segment, you need a main() function and some IO stuff and conversion) but it might give you an idea of how to go about things. You might be able to do the same thing but without converting it into a string (ie by doing the checks for equality as you convert from the whole number to its digits without adding the additional constant to convert to ascii) but it was easier just to knock this one together quickly to give you an idea.
-
or has some form of surgical plate or pin inside :\
-
I think the problem here is that everyone is replying in terms of which you would prefer to use but the poster wishes to know which you would prefer to develop (ie write software) for. A good example of a non-console to pc comparison of open and relatively closed systems would be comparing the PC to the Mac, while there are various generations of Mac the actual different variations on hardware are limited compared to the PC and this allows for them to write software tailored to those systems which can result in a much smoother experience and less driver problems etc. I think most developers would prefer developing for a closed system but would only really care when it actually affected them. Alot of projects won't need to take alot into account as the OS will take care of it for you or if not some form of virtual machine or just set standards. But as you said, some closed systems like Consoles can often have smaller OS footprints so that can be a plus but then again you will have to write alot more yourself when the OS doesn't do something for you, so despite having the resources yourself you can lose time having to do extra coding etc.
-
http://www.scienceforums.net/forums/search.php?searchid=119920 Dave started some Calculus tutorials, I'm sure if he no longer wants to continue them, then someone else would be happy to fork them or something.
-
From what I can see you seem to just be drawing rectangles onto a graphics buffer but you aren't adding the actual Component objects to the frame and all you have is an image. I'm not entirely sure if the way in which you are doing this is a good way to do it, I would've thought if you wanted custom buttons, that all the Graphics work would be on each component and then the button can just be treated like a normal Button like in AWT, however each to their own. Adding the additional add() calls here seems to fix the problem - for (int i=0; i<nums.length-1; i++) { for (int p=0; p<nums[0].length; p++) { nums[i][p].addMouseListener(nums[i][p]); this.add(nums[i][p]); System.out.println("makin the buttons listen"); } } nums[3][1].addMouseListener(nums[3][1]); add(nums[3][1]);
-
So you arent getting anything printed out on the command line? I can understand why if you are changing any colours they wont update, as youll need to refresh the GUI so that everything is redrawn with the new colours (not exactly sure how you are handling the colour change, seems a little odd just to set some vague variable to a different colour, I don't see how that changes anything, perhaps you need to run another method and pass these colours in, and then refresh? It might work through referencing I suppose so you might not have to pass it back in if you passed them in the first time, depends how it all works internally) but if the String aren't printing out on the command line then I don't see what the problem is (you can pass in an object itself to the addMouseListener, i've tried it). Perhaps you could post the code as a whole (ie all the code), there are [ code ] [ / code ] tags (obv remove spaces) on here so you can display things more easily, or you can use things like pastebin. When we can see the code as a whole its easier to debug it ourselves and point out any problems.
-
Yes..... he's doing the same thing but with MouseListener instead of ActionListener, which is fine. Callipygous, could you paste some of the code here so we can see what you are doing? What exactly should it do when you move your mouse over the buttons or click them? Baring in mind if you have made any changes to the actual GUI itself youll need to refresh things by doing something like hiding and reshowing things with setVisible(true) and setVisible(false).
-
I've never come across one having to implement ActionListener on a Button :\ ok so have you actually compiled this seperate class first? It won't be visible to the other class you are trying to use it in otherwise, also on the same note, are you sure you are implementing the MouseListener correctly, it will obviously not compile correctly otherwise but I'm wondering if you have compiled your first class (the button class) before trying to compile the second. You'll need to implement all of the MouseListener's methods (there are about 5 of them). They don't need to have code, they just need to be there (ie they can just have a method header and no code in the brackets/code block).
-
ok..... Sorry, I forgot that your button was a little special, its a Rectangle or something isn't it? You have some custom Rectangle class that inherits from Rectangle?? Could you describe a little how exactly you have everything laid out
-
As far as I know, either should be fine, I'd say the code is more readable using a MouseListener if that is all you are doing although using an ActionListener would be easier to tie multiple events together under one heading (ie you can check for a mouse click OR a key press etc and run the same code more easily). Are you running addMouseListener on the button itself? Ie youll have a button object and you'll want to call addMouseListener on the button object like button.addMouseListener( this ) , replacing this with whatever object instantiates the class that you defined the MouseListener interface methods in.
-
AWT and SWING are two different Java GUI frameworks, AWT is older and gives a more basic but standardised look and Swing uses GUI components from the system it is running on (so it looks and feels more natural on Windows or Linux+KDE or Linux+Gnome or Mac OS Xs Aqua etc). They are relatively simple to use and if you google for something like Java GUI tutorial, I'm sure you'll find a lot of information. With respect to your problem, you are using the Graphics Class I take it, as far as I can see from the docs, this doesn't offer a way to change the pen or brush size when drawing elements but if you use the Graphics2D Class, it offers a way you can set the "stroke" for the image which allows you to define the brush or pen attributes when drawing any elements. The Graphics2D Class inherits from the Graphics Class so all the methods etc that you have been using SHOULD be there, it just allows more control over the way things are done. You can do things like setStroke( new BasicStroke(10) ) to have a pen/brush width of 10 pixels (afaik, i havent tested). Take a look here - http://java.sun.com/j2se/1.4.2/docs/api/java/awt/Graphics2D.html#setStroke(java.awt.Stroke) http://java.sun.com/j2se/1.4.2/docs/api/java/awt/BasicStroke.html
-
I'm unsure of exactly what you are looking for but from what you are saying I'm assuming you want to increase the size of or alter the border of the buttons? If so this might be of use, I've never been inclined to do that myself but it looks like this might be the way to do it - http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/JComponent.html#setBorder(javax.swing.border.Border) http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/border/Border.html Thats using a JButton rather than a simple button, not sure how you'd go about it otherwise. If you simply mean changing the size then obv you can just use setSize(). If I'm misunderstanding you completely and you are doing something with canvas drawing and 2D drawing then you might want to look here - http://java.sun.com/developer/technicalArticles/GUI/java2d/java2dpart1.html Sorry I'm just providing links, it's just a) I don't really understand what you want and b) I haven't really done much with Canvas drawing if that is what you want and in general am not particularly fussed about aesthetics . My Exams finish after this weekend so if your problem still isn't solved by then, I'll be happy to try and give a bit more of a hand.
-
Glad it all worked out Thanks for the offer, I do do a few little things with JavaScript every now and again so I could very well be asking you a few questions at some point
-
The error you list simply means that whatever method you are using or overriding is probably deprecated (ie it is no longer used or at least not the way you are using it). I think it will have compiled anyway (ie i think that is just a warning not an error) but obviously you'll want to read the API documentation for whatever Interface you are using to see why it might be giving you that warning (or as the warning says, use the option provided to get more details). I don't do alot of coding with Applets myself.... mainly because java applets in general get on my nerves and I try to avoid them when possible but as far as I know the idea behind the event handling is the same as in GUI programing. You have a component (ie your JApplet or JFrame or whatever you are trying to get an action for (JButton... whatever), you then somehow(*) implement an EventListener (will be called ActionListener, KeyPressListener, MouseListener or some other wierd name depending on what you are trying to do) in some class and the have an object instance of this class somewhere. Then you pass this object instance through to the method call addEventListener (or addActionListener etc etc) of the JFrame or... or JButton object you have. ---------------------------------------------- * - Ie this can be in one of your other classes, an anonymous member class as mentioned below or anything as long as you can make an instance object of it to pass into the addEventListener() type method. (ie this is javas way of handling function pointers and callbacks etc as obviously it doesnt have actual pointers (all objects are passed by reference) and certainly doesnt allow function/method pointers so interfaces and objects are the way it goes). ---------------------------------------------- This is then stored and when one of those events occurs the JButton or whatever will call the appropriate method that you've written to satisfy the interface implementation ( for instance with ActionListeners you have to implement a actionPerformed() method in whatever classes implements it and actionPerformed() is called ), and inside you can use the actual Event that is passed to these methods to determine more specifically what has happened (ie you know a key has been pressed but you want something to happen only when 'x' or 'y' has been pressed then you use the various Event methods to determine whether or not to do anything). This can cause problems as often when the particular method is called execution will not continue on the particular components thread of execution until the event handling method returns. This is problematic if you want to do long calculations based on an event as your whole app can seize up. What you can do in this situation is start another Thread to execute the operations you wish to occur and return immediately leaving that other Thread to do the work. This can prove troublesome sometimes as you might want access to certain things inside the class/object you implemented the EventListener Interface on but this can be fixed by simply using anonymous member classes which are just classes that you declare within a class or method that you can create an object instance with, that have the same access as the encompassing class or method (ie they can access the classes private fields etc). An example of what i mean is below - /** * Handles the MouseClick event for this Picture */ public void mouseClicked ( MouseEvent e ) { Runnable runSunset = new Runnable () { public void run () { sunset(); return; } }; Thread subThread = new Thread(runSunset); subThread.start(); } This was something I did when altering a simple assignment to start based on a MouseClick rather than straight away (wasn't necessary but was interesting to try). I could easily be wrong in alot of this, feel free to ask questions and if I am wrong, I am sure someone will correct me. There are probably easily and much tidier ways to do some of these things but these are just what I know etc. I'll try to knock together a simple applet that demonstrates this in a little while. [Edit] Knocked together a quick working example using the swing JApplet stuff, a button and mouse clicking. It allows you to click a button and it will change it's text (nothing special but it just illustrates how you can do it). import javax.swing.JApplet; import javax.swing.JButton; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; /** * Simple explanatory JApplet * * @author Matthew Gwynne * @version 05/01/2006 */ public class AppTest extends JApplet implements MouseListener { // Fields private JButton button; // Methods - Public /** * Constructor */ public AppTest() { // Init button = new JButton( "Hello" ); // Add Button this.getContentPane().add( button ); // Set up Event Listener button.addMouseListener ( this ); // Passing in this object // Show setVisible( true ); // This replaces show in Java 1.1 so.... could be the error } /** * Main method equivalent */ public void init() { AppTest x = new AppTest(); } // Methods - MouseListener /** * Handles Mouse Click Events */ public void mouseClicked(MouseEvent e) { if ( e.getButton() == e.BUTTON1 ) { button.setText("OMG NOOOO!!"); this.getContentPane().setVisible( false ); this.getContentPane().setVisible( true ); // Repaint the JApplet. } }; public void mouseEntered(MouseEvent e) {}; public void mouseExited(MouseEvent e) {}; public void mousePressed(MouseEvent e) {}; public void mouseReleased(MouseEvent e) {}; } [/Edit] Some Links - http://java.sun.com/docs/books/tutorial/uiswing/events/index.html http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/JApplet.html http://java.sun.com/docs/books/tutorial/uiswing/components/applet.html http://java.sun.com/j2se/1.4.2/docs/api/java/util/EventListener.html
-
If this is a non SSL site/page (ie not HTTPS), you might be able to find it out by using a Packet Sniffer such as Ethereal and monitoring the packets sent as you submit the password in IE. Also, if you look in the page source a bit, you can probably get the value using a bit of javascript in the URL bar, for instance if the password input has an id (say "passwordInput1" from <input type="password" id="passwordInput1" name="someName" />) you can use "javascript:alert(document.getElementById("passwordInput1").value);" in the url bar to have the password shown to you in an alert/dialog box. If the password field doesn't have an Id, you can do the same thing but it gets a little harder, something along the lines of "javascript:alert(document.forms[$x].$inputName.value);" where $x is which form it is in the page (ie if it is the second form in the source, you want $x to be 1 (as it starts at 0)), and $inputName is the input fields name (ie with <input name="password1" type="password" /> the $inputName would be password1 ). You might get some security warning in IE about using active content, you should be able to allow it for this site (clicking the yellow bar at the top) and then when you've found the password, disallow it again (I don't use IE normally so...). This is intended to help you retrieve your OWN passwords, and I am assuming you are telling the truth. I do not condone using this to find for instance the passwords of family members or others on a shared or public computer.
-
Ah, I forgot to mention you can set the path more perminantly in Control Panel -> System -> Advanced -> Environment Variables -> Path and just adding the path to the end. Otherwise you end up having to use the set path command constantly and it gets rather annoying. ---------- EDIT--------- Just noticed your next post, heh. You should have the filename the same as the public class you are trying to compile, so you have HelloWorldApp as the classname, this should be in HelloWorldApp.java and when compiled will make a HelloWorldApp.class file, which you can run with "java HelloWorldApp". If it compiled, it would still have produced "HelloWorldApp.class" so you'll need to do "java HelloWorldApp". If you haven't compiled it with javac then you'll need to use javac first ("javac HelloWorldApp.java" then "java HelloWorldApp" to run).
-
Some might remember this speech used in the film Coach Carter - [quote name='Marianne Williamson - A Return To Love: Reflections on the Principles of A Course in Miracles] Our deepest fear is not that we are inadequate. Our deepest fear is that we are powerful beyond measure. It is our light' date=' not our darkness that most frightens us. We ask ourselves, Who am I to be brilliant, gorgeous, talented, fabulous? Actually, who are you not to be? You are a child of God. Your playing small does not serve the world. There is nothing enlightened about shrinking so that other people won't feel insecure around you. We are all meant to shine, as children do. We were born to make manifest the glory of God that is within us. It is not just in some of us; it is in everyone. And as we let our own light shine, we unconsciously give other people permission to do the same. As we are liberated from our own fear, our presence automatically liberates others. [/quote']
-
Freeman, what exactly do you need this for? Also I'm not exactly sure what you mean... Do you mean something along the lines of Preprocessor methods/actions such as are found in C where one can conditionally and even through certain functions define function code that will actually be compiled. I am not aware of anyway in the default java installation that you can do this sort of thing, and I haven't tried myself but there seem to be several java preprocessors that you can download which might be helpful. Do you mean something along the lines of using different methods with the same method name depending on the situation? (ie function pointers, not method overloading). As far as I know Java doesnt support this, although you can have an interface which various classes implement that has a certain methods and then these implementations could have instance objects which can be passed into various methods, which can have the method run on them, executing different code depending on the class that that object belongs to (ie each class that implements that interface can implement it differently). This is what is done alot of the time with ActionListeners and so on in the GUI programming aspect of Java. If you are simply looking to have different code loaded in at runtime depending on the situation (ie perhaps a plugin architecture) then you might want to look at the ClassLoader Class which allows precompiled class files to be loaded at runtime and used to create new instance objects.
-
Once you have the developer kit and it's installed, you need to find the directory where javac.exe is stored (probably something like C:\Program Files\Java\jdk... although it can differ quite alot so look around). Then open up a cmd prompt, go to the file you want to compile, then you need to set the path using set PATH=%PATH%;"$path_to_javac_directory" where $path_to_javac_directory is the path to the directory you found javac in. Then you can simply type "javac someFile.java" to compile someFile.java and then you can use "java someFile" to execute it (as the file should be named the same as the public class it contains). If you have any problems involving class defs not being found or other similar problems, you might have to add the current directory to the classpath (where java searches for class files when running and compiling other class files). This can be done in a similar way to setting the path - set CLASSPATH=%CLASSPATH%;"$path_to_current_directory" where $path_to_current_directory is the current directory ( for instance "c:\my project\"). This is all assuming you are using a windows system, if not say and I'll be happy to provide you with instructions for a linux system or help in finding those for for instance Mac OS X (similar to linux/unix nowdays id imagine due to the BSD-based backend). If you are looking for an IDE that will let you compile within it for ease of use, there are numerous free IDEs around, for instance there is BlueJ which is used in alot of Java courses in universities, there's Eclipse which is more powerful and features a whole host of addons and there are things such as NetBeans which is also very popular. All of these are free as far as I know.
-
I think he just wants to send the request, he doesn't care about the response. This is possible, it is called IP Spoofing, but implementing this at a higher level (ie higher than the hardware or OS level) might be hard, not sure exactly how it is done (i doubt there will be much info easily available). The legality of IP Spoofing is certainly dubious, you are obviously misrepresenting yourself and trying to misuse the system/network. If you are looking for an easy way to do it with some built-in functionality in most programming languages, I doubt you'll find it (as i said, I'd imagine you'd have to do it at the hardware/firmware or at least OS Networking level (as youd probably be changing the headers at the Network Encapsulation level (OSI Model).
-
Java programming questions related to network...
Aeternus replied to albertlee's topic in Computer Science
Not sure if there are any specifics API's but there could be. I think you can simply do it by keeping track of how much data you are sending and watching the timestamps etc, sleeping for a certain amount of time to keep the datarate below a certain threshold (as you send X bytes and read X bytes with read() etc).