package askcsdn;
import java.awt.BorderLayout;
import java.awt.Dimension;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JButton;
import java.awt.Rectangle;
import java.awt.image.*;
import java.awt.Image;
import javax.swing.Icon;
import javax.swing.ImageIcon;
/**
* <p> Title: </p>
*
* <p> Description: </p>
*
* <p> Copyright: Copyright (c) 2007 </p>
*
* <p> Company: </p>
*
* @author not attributable
* @version 1.0
*/
public class Frame1 extends JFrame {
JPanel contentPane;
JButton btnOK = new JButton();
JButton jButton1 = new JButton();
public Frame1() {
try {
setDefaultCloseOperation(EXIT_ON_CLOSE);
jbInit();
} catch (Exception exception) {
exception.printStackTrace();
}
}
/**
* Component initialization.
*
* @throws java.lang.Exception
*/
private void jbInit() throws Exception {
contentPane = (JPanel) getContentPane();
contentPane.setLayout(null);
setSize(new Dimension(400, 300));
setTitle( "Frame Title ");
btnOK.setBounds(new Rectangle(108, 94, 194, 95));
btnOK.setText( "jButton1 ");
/* 这里设置不了图标和JPEG文件,而放入GIF则可以,这是怎么回事 */
ImageIcon image = new ImageIcon( "E:\\dd\\1.ico ");
// ImageIcon image = new ImageIcon( "E:\\dd\\1.gif ");//这样可以放GIF
Image icon = image.getImage();
btnOK.setIcon(image);