TOP →
Java →
Swing →
JFrame → This Page
JFrame@Swing サンプル03
概要
Java -
Swing -
JFrame のサンプルです。
・装飾の無効化(フレーム枠とタイトルバーを消去)
サンプルイメージ
サンプルソース
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
/**
* JFrame サンプル03
* ・装飾の無効化(フレーム枠とタイトルバーを消去)
*
* @author みっちー
*/
public class JFrame03 extends JFrame implements ActionListener {
private static final long serialVersionUID = 1L;
/**
* 開始メソッド
*
* @param args パラメータ
*/
public static void main(String[] args){
JFrame03 frame = new JFrame03();
// ウインドウのタイトルを設定
frame.setTitle("JFrame サンプル03");
// フレームの幅、高さを設定
frame.setSize(400, 200);
// 装飾の無効化(フレーム枠とタイトルバーを消去)
frame.setUndecorated(true);
// 閉じるボタンの追加
JButton button = new JButton("Close");
button.addActionListener(frame);
frame.add(button);
// フレームを表示(これをしないと透明のフレームが立ち上がってしまう)
frame.setVisible(true);
}
/**
* アクション
*/
public void actionPerformed(ActionEvent e) {
System.exit(0);
}
}
サンプルソースのダウンロード
ソースのダウンロード(Eclipse用のプロジェクトファイルも同梱)
更新履歴
2016/05/13 新規作成
TOP →
Java →
Swing →
JFrame → This Page