devxlogo

Tip Bank

Highlight Text Automatically

When the focus of a graphical user interface shifts to an empty TextField, you type the desired input and step to the next one. But if the TextField is not

Stabilized Scrollbars

Numerous awt Components provide their own Scrollbars when needed. However, when you first employ one explicitly, perhaps for adjusting colors, you may encounter a frustrating problem. On some platforms the

Enable Pasting to Spreadsheets

A TextArea is ideal for presenting tabular results from an applet or application. It provides Scrollbars automatically when the text exceeds the available screen space. But despite careful use of

Avoid Premature Dialog Closure

On some platforms, hitting the “Enter” key to terminate input to a TextField will cause the whole dialog box to disappear, as if you had clicked an “OK” button. If

Displaying Help from an Application

It’s tempting to use an HTML file to provide help for a Java application, but how do you know which browser is installed on the run time platform and where

Forward Declarations

There are circumstances in which classes refer to one another: //file: bank.hclass Report{public:void Output(const Account& account); // compile time error; class Account is not declared yet};class Account {public:void Show() {Report::Output(*this);}};

Unnamed Function Arguments

When an argument of a function is not used anymore in the function body (in an upgrade, for example), it needn’t be removed from the function’s argument list. It can

Beware of Aliasing

Whenever your class contains pointers, references, or handles, you need to define a copy constructor and assignment operator. Otherwise, the compiler-generated copy constructor and assignment operator will result in aliasing,

Internationalized Strings

If you’ve been using the standard string class and you have to internationalize your software, you don’t have to give up the significant advantages class string offers: you can simply