devxlogo

Tip Bank

DevX - Software Development Resource

Port information

Question: I need to take a port number as input froma user. How can I check if the port numberentered by the user is free and not beingused by any

DevX - Software Development Resource

Wrapping Text in TextArea

Question: Is there a way to wrap text that is written to the TextArea? Answer: The java.awt.TextArea class does not have built-in support for wrapping text, but you can implement

DevX - Software Development Resource

Setting textfield focus

Question: I have an initially disabled TextField on a frame.When the user clicks a specific button the TextField is enabled. How do I set the input focus to the TextField

DevX - Software Development Resource

Copy & Paste

Question: How can I copy the selected text from a TextArea to the system clipboard or paste from the system clipboard to a TextArea? Answer: Java 1.1 introduced the java.awt.datatransfer

DevX - Software Development Resource

Classes in sun.* packages

All the classes in sun.* that accompany the Sun JDK are provided assupport classes that are used to implement specific sets of functionalityfor the core JDK classes. The classes in

DevX - Software Development Resource

Converting a String into an int

The Java core API possesses a method equivalent to the C atoi() function in Java. The java.lang.Integer class contains a method called parseInt()which will convert a String into an int.

DevX - Software Development Resource

Generating Random Numbers

The java.util package contains a class called Random which you can useto generate random numbers. A Random object represents a repeatingpseudo-random sequence of numbers. You can either fetch the next

DevX - Software Development Resource

Array Reflection

The java.lang.reflect package provides an Array class through whichthe values of an array can be accessed. It is usually more effectiveto cast the array after it has been obtained through