More action with Struts 2
In a recent review of Struts 2 in Action, JW Blogger Oleg Mikheev notes that Struts 2 is "just a collection of extensions built upon WebWork, which is ultimately the right thing to learn before starting a Struts 2 project." While Struts 2 has some architectural flaws, Oleg calls WebWork well-designed, well-tested, and reliable. What are your experiences using Struts 2 and WebWork?

Also see "Hello World the WebWork way," a JavaWorld excerpt from WebWork in Action, by Patrick Lightbody and Jason Carreira.

Newsletter sign-up

Sign up for our technology specific newsletters.

Enterprise Java
View all newsletters

Email Address:

Get a new coffee cup

How to change the steaming coffee cup icon

QHow do you change the steaming coffee cup icon that appears in the top left-hand corner of applets and frames?

AIn order to change the icon image on a frame -- whether in an applet or an application -- you must first create an Image object. There is more than one way to do this, but here we'll use the ImageIcon object, since it has a simple constructor that takes a file name.

ImageIcon image = new ImageIcon("C:/images/your_image.gif");


One you have the ImageIcon, you call its getImage() method and pass it to your Frame's setIconImage() method.

Frame.setIconImage(image.getImage());


It's worth mentioning that, since Swing's JFrame class inherits from the AWT Frame class, the setIconImage() method is also available in JFrame. A complete JFrame example is included below:

Author Bio

Random Walk Computing is the largest Java/CORBA consulting boutique in New York, focusing on solutions for the financial enterprise. Known for their leading-edge Java expertise, Random Walk consultants publish and speak about Java in some of the most respected forums in the world.
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class AppIconFrame extends JFrame {
  public AppIconFrame() {
    enableEvents(AWTEvent.WINDOW_EVENT_MASK);
    initFrame();
  }
  //Frame initialization
  private void initFrame(){
    this.setSize(new Dimension(400, 300));
    this.setTitle("Custom Icon");
    ImageIcon image = new ImageIcon("c:\yourpath\yourfile.gif");
    this.setIconImage(image.getImage());
  }
  //Overridden so we can exit on System Close
  protected void processWindowEvent(WindowEvent e) {
    super.processWindowEvent(e);
    if(e.getID() == WindowEvent.WINDOW_CLOSING) {
      System.exit(0);
    }
  }
  public static void main(String[] args){
    AppIconFrame frame = new AppIconFrame();
     frame.setVisible(true);
  }
}


Resources