How to Write an Action Listener (The Java™ Tutorials > Creating a GUI With JFC/Swing > Writing Event Listeners) Action listeners are probably the easiest — and most common — event handlers to implement. You implement an action listener to define what should be done when an user performs certain operation. An action event occurs, whenever an action is performed by the user. Examples: When the user clicks a button, chooses a menu item, presses Enter in a text field. The result is that an actionPerformed message is sent to all action listeners that are registered on the relevant component. To write an Action Listener, follow the steps given below: In general, to detect when the user clicks an onscreen button (or does the keyboard equivalent), a program must have an object that implements the ActionListener interface. Let us write a simple program which displays how many number of times a button is clicked by the user. public class AL extends Frame implements WindowListener,ActionListener { TextField text = new TextField(20); Button b; private int numClicks = 0; Here is the complete program(AL.java):
NetBeans - Javadoc support Javadoc supportNetBeans supports the Javadoc standard for Java documentation - both viewing it and generating it. It gives the student a solid documentation tool when working with code. Mounting and accessing Javadoc You may have noticed the Javadoc tab in the Explorer window. This operates much like the Filesystems tab where you mount source files, except here you mount directories containing Javadoc documentation. An empty directory is mounted there by default - this is where the IDE puts Javadoc documentation you generate for your own code (see below for details on generating Javadoc). You can also mount existing Javadoc documentation here (for example, the JDK documentation, or the Javadoc for the Open APIs for NetBeans). Generating Javadoc Javadoc documentation can be generated from specially formatted comments within source files.
YUIDoc - Javascript Documentation Tool Welcome to YUIDoc 0.10.0! YUIDoc is a Node.js application that generates API documentation from comments in source, using a syntax similar to tools like Javadoc and Doxygen. YUIDoc provides: Live previews. YUIDoc includes a standalone doc server, making it trivial to preview your docs as you write. Modern markup. Installation and Usage Download and install Node.js Run npm -g install yuidocjs. That's it! User Guides Using YUIDoc — Understanding YUIDoc command line arguments and usage. YUIDoc parses a modified form of JSDoc tags. Example Class Block /** * This is the description for my class. * * @class MyClass * @constructor */ Example Method Block /** * My method description. Example Property Block /** * My property description.
Setting up Java with Windows CMD This page is obsolete. This document instructs you on how to use the Windows Command Prompt with Java. These instructions are specialized to Windows 7, but are similar for Windows XP and Windows Vista. You will use the Java compiler javac to compile your Java programs and the Java interpreter java to run them. You should skip the first step if Java is already installed on your machine. Download and install the latest version of the Java Platform, Standard Edition Development Kit (Java SE 6 Update 27). You will type commands in an application called the Command Prompt. Launch the command prompt via All Programs -> Accessories -> Command Prompt. You will use the javac command to convert your Java program into a form more amenable for execution on a computer. From the Command Prompt, navigate to the directory containing your .java files, say C:\introcs\hello, by typing the cd command below. You will use the java command to execute your program. When I type, "java -version" I get an error.
File Download In Spring In order to implement a file download in Spring, the key is returning null instead of a ModelAndView object. This controller that I created below is specifically for text/ascii data. You'd need to change the content type appropriately in order to download other file types. public class DownloadController implements Controller { /* * Spring dependency injection */ private XService xService; public void setxService( XService xService) { this.xService = xService; } public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception { String idStr = request.getParameter("id"); if (idStr ! private void doDownload(HttpServletRequest request, HttpServletResponse response, String data, String filename) throws IOException { int length = data.length(); ServletOutputStream op = response.getOutputStream(); byte[] bbuf = data.getBytes(); op.write(bbuf, 0, length); op.flush(); op.close(); }}
Gervill: Wiki: Home "Gervill" is a software sound synthesizer which was created as a proposal for the Audio Synthesis Engine Project. Example Applets Features Downloadable Sound Level 2.2 General Midi Level 2 MIDI Tuning Standard SoundFonts 2.04 (24 bit) Use Audio files (AIFF, AU and WAV) as SoundBanks Drumkits can be used on any channel Sinc interpolation with anti-aliasing Uses JavaSound mixers/lines for sound output Pure-Java implementation Emergency soundbank included MIDI Implementation Chart Usages Gervill was designed to be generic synthesizer for Java. Advanced features of Gervill are accessed thru the AudioSynthesizer interface.Warning! Gervill has been tested successfully with these applications: Project Overview Gervill project mainly consists of 3 modules: The SoundBank Readers/Writers Made of these classes: com.sun.media.sound.DLS* com.sun.media.sound.SF2* com.sun.media.sound.AudioFileSoundbankReader There is a one SoundBank reader/writer for each soundbank format which Gervill supports. License
SHA512 Encrypt hash in JavaScript The SHA (Secure Hash Algorithm) can be used to encrypt data for secure transfer between applications. The SHA512() function returns a string with the SHA512 encrypted hash as a 128-character hexadecimal string. It is fully compatible with UTF-8 encoding. Code of the SHA512() function - Usage: 1. - Example. <form action="#" method="post"> Enter a text:<br/><input type="text" name="strex" id="strex" size="20" /><button id="cryptstr">Encrypt</button><br/> SHA512 hash string:<br/><input type="text" name="strcrypt" id="strcrypt" size="33" /></form><script type="text/javascript"> // Here add the code of SHA512 function // register onclick events for Encrypt button document.getElementById('cryptstr').onclick = function() { var txt_string = document.getElementById('strex').value; // gets data from input text // encrypts data and adds it in #strcrypt element document.getElementById('strcrypt').value = SHA512(txt_string); return false; } </script> Demo:
ubuntu java installer JUnit JUnit a été initialement développé par Erich Gamma et Kent Beck. JUnit propose : Un framework pour le développement des tests unitaires reposant sur des assertions qui testent les résultats attendus Des applications pour permettre l'exécution des tests et afficher les résultats Le but est d'automatiser les tests. Cela permet de séparer le code de la classe, du code qui permet de la tester. La rédaction de cas de tests peut avoir un effet immédiat pour détecter des bugs mais surtout elle a un effet à long terme qui facilite la détection d'effets de bords lors de modifications. Les cas de tests sont regroupés dans des classes Java qui contiennent une ou plusieurs méthodes de tests. JUnit permet le développement incrémental d'une suite de tests. Avec JUnit, l'unité de test est une classe dédiée qui regroupe des cas de tests. La version utilisée dans ce chapitre est la 3.8.1 sauf dans la section dédiée à la version 4 de JUnit. La page officielle est à l'url : 92.1. 92.2. 92.3.
jQuery prop('checked') vs. is(':checked') Info A quick test to see if prop('checked') or is(':checked') is faster with jQuery. Preparation code <input type="checkbox" value="y" name="my-test-checkbox" id="my-test-checkbox" checked><script> var $el = $('#my-test-checkbox');</script> Preparation code output Test runner Warning! Java applet disabled. Ready to run. Compare results of other browsers Chart type: bar, column, line, pie, tableFilter: popular, all, desktop, family, major, minor, mobile, prerelease Revisions You can edit these tests or add even more tests to this page by appending /edit to the URL.
Installing Java on Ubuntu systems Introduction Java is a technology originally developed by Sun Microsystems, and acquired by Oracle. The following are the prevalent implementations: OpenJDK: The OpenJDK project is an open-source implementation of the Java SE Platform. OpenJDK Installation of Java Runtime Environment Install the openjdk-6-jre package using any installation method. Browser plugin Install the icedtea6-plugin package using any installation method. This plugin works with the browsers: Epiphany, Firefox and Opera. On Konqueror, go to Settings → Configure Konqueror... and from menu select Java & JavaScript, then tick Enable Java globally option. OpenJDK v6 & v7 SDK (Software Development Kit) In Java parlance the Java Development Kit (JDK) is sometimes used for SDK. Install the openjdk-6-jdk package using any installation method. Alternative Virtual Machines Most users won't need to worry about these, but if you use an architecture (e.g. JamVM: This is the default VM for ARM in 11.10. Oracle Java 7 Script (JRE only)
JUnit Cookbook Kent Beck, Erich Gamma Here is a short cookbook showing you the steps you can follow in writing and organizing your own tests using JUnit. Simple Test Case How do you write testing code? The simplest way is as an expression in a debugger. You can change debug expressions without recompiling, and you can wait to decide what to write until you have seen the running objects. JUnit tests do not require human judgment to interpret, and it is easy to run many of them at the same time. Annotate a method with @org.junit.Test When you want to check a value, import org.junit.Assert.* statically, call assertTrue() and pass a boolean that is true if the test succeeds For example, to test that the sum of two Moneys with the same currency contains a value which is the sum of the values of the two Moneys, write: If you want to write a test similar to one you have already written, write a Fixture instead. Fixture What if you have two or more tests that operate on the same or similar sets of objects?
How to check a not defined variable in javascript