November 11, 1998

A Static Member Function can Access Only Static Members

A static member function does not receive an implicit this argument. It can be invoked even when no object instance exists: #include < ctime >using namespace std;class Clock {public: static time_t getTime ( ){ return time (0); }//seconds elapsed since 1/1/1970 };main() {cout

Suppress Trailing Zeros on Output

The format string “%f” in printf() call displays trailing zeros of its argument: float num = 1.33; printf( “%f”, num); // output: 1.330000 To get rid of the trailing zeros, you should use the “%g” format instead: float num = 1.33; printf( “%g”, num); //output: 1.33

Vector Elements are not Guaranteed to Occupy Contiguous Memory

Built-in arrays in C++ reside in contiguous chunks of memory. The Standard, however, does not guarantee that elements of a vector occupy contiguous memory. All current STL implementations store vector elements in contiguous memory, but it’s just a convention, not a requirement.

Absolute Layout Manager

Question: Do you know of any LayoutManager that would allow me to lay out components exactly where I want them, or any other way of doing so? Answer: There is no standard AWT or Swing LayoutManager implementation that will perform absolute positioning of components. Instead, java.awt.Component, and therefore every subclass

Converting IP Address Formats

Question: Is there a Java equivalent class or method for the Unix Internet address manipulation routines like inet_ntoa()? Answer: Java does not have direct analogs for the inet functions that originally appeared in the BSD 4.3 C library, but still supports the equivalent functionality. All Internet address manipulation in Java

RMI method invocation

Question: I want my RMI server application to populate a java.awt.List with data on the client with a method invocation. What’s the best way to do this? Answer: When writing distributed applications, it is usually desirable to minimize the amount of communication. This means you want to reducethe number of

JTable Headers

Question: I would like to add an icon to the header of a column of a JTable indicating the direction the column is currently sorted. Answer: It can be pretty tough for even a Java programmer experienced with Swing to figure out how to change the rendering of column headers.

Installing Own Colormap

Question: How can I make my Java application install its own colormap? Answer: The ability to allow a Java application to install its own colormap is not supported by the Java core API. You could add this functionality yourself by writing native code.

HTML File to Download CAB File

Question: I have a CAB file produced by Wise Installation System 7.0 that contains an application setup.exe. I need to create an HTML file that will download the CAB file. The INF in the CAB file should kick off the actual setup.exe. The problem is that the EXE is not