2011年9月7日水曜日

ボタンの表示

import java.awt.BorderLayout;
import java.awt.Container;
import javax.swing.JButton;
import javax.swing.JFrame;
 
public class swingTest {
 
 /**
  * @param args
  */
 public static void main(String[] args) {
  // TODO 自動生成されたメソッド・スタブ
  JFrame frame = new JFrame("サンプル");
 
  // Xボタンが押された時の挙動
  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  // ウインドウサイズ
  // mainFrame.setSize(320, 160);
  // ウインドウの表示場所とサイズ指定
  frame.setLocationRelativeTo(null);
  frame.setBounds(2500, 200, 300, 150);
 
  // JFrameよりContentPaneを取得
  Container contentPane = frame.getContentPane();
  // ボタンのインスタンスを生成
  JButton button = new JButton("button");
  // ボタンをフレームに追加
  contentPane.add(button, BorderLayout.SOUTH);
 
  // ウィンドウを表示
  frame.setVisible(true);
 
 }
 
}

0 件のコメント:

コメントを投稿