アットウィキロゴ

swing2

import java.awt.*;
import javax.swing.*;

class pro extends JFrame{
pro(){ 
setDefaultCloseOperation( WindowConstants.EXIT_ON_CLOSE ); // 終了ボタン有効
Container contentPane = this.getContentPane(); // フレームのコンテントペイン取得
JLabel label1 = new JLabel( new ImageIcon( "girl1.jpg" ) );
JLabel label2 = new JLabel( "女性の写真" );
contentPane.add( label1, BorderLayout.CENTER ); // 中央に写真を配置
contentPane.add( label2, BorderLayout.NORTH ); // テキストを上に配置
}

public static void main( String [] args ){
	pro jf = new pro();

	jf.setTitle( "Swing版フレームのコンテンツペインへの貼り付け" );
	jf.setSize( 200, 200 );
	jf.setVisible( true );
}
}
最終更新:2012年01月10日 09:28