If you're using JFrames, you can try setting the icon image as follows.
frame.setIconImage(img);
Also, by name it sounds a bit like you mean the frame's title. When you create the a frame, you can set the title as follows:
Frame frame = new JFrame("Title goes here");
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…