標題:
佈局元件 - BorderLayout
[打印本頁]
作者:
tonyh
時間:
2016-9-3 16:30
標題:
佈局元件 - BorderLayout
本帖最後由 tonyh 於 2016-9-3 16:33 編輯
[attach]1750[/attach]
import javax.swing.JFrame;
import javax.swing.JButton;
import java.awt.BorderLayout;
public class Ch115 {
JFrame fm;
JButton btn1,btn2,btn3,btn4,btn5,btn6;
Ch115()
{
JButton btn1=new JButton("xxx");
JButton btn2=new JButton("xxxxxxx");
JButton btn3=new JButton("xxxxxxxxxxx");
JButton btn4=new JButton("xxxxxxxxx xxxxxxx");
JButton btn5=new JButton("xxx");
//JButton btn6=new JButton("x");
fm=new JFrame("BorderLayout");
fm.setBounds(100, 100, 300, 200);
fm.setVisible(true);
fm.setResizable(true);
fm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
fm.setLayout(new BorderLayout(5,5));
//BorderLayout 預設物件之間的水平及垂直距離為0像素
fm.add(btn1, BorderLayout.NORTH);
fm.add(btn2, BorderLayout.SOUTH);
fm.add(btn3, BorderLayout.WEST);
fm.add(btn4, BorderLayout.CENTER);
fm.add(btn5, BorderLayout.EAST);
//fm.add(btn6, BorderLayout.EAST);
}
public static void main(String[] args) {
new Ch115();
}
}
複製代碼
作者:
李允軒
時間:
2016-9-3 16:32
import javax.swing.JFrame;
import javax.swing.JButton;
import java.awt.BorderLayout;
public class Ch01{
JFrame fm;
JButton btn1,btn2,btn3,btn4,btn5,btn6;
Ch01(){
JButton btn1=new JButton("xxx");
JButton btn2=new JButton("xxxxxx");
JButton btn3=new JButton("xxxxxxxxxxx");
JButton btn4=new JButton("xxxxxxxxx xxxxxxx");
JButton btn5=new JButton("xxx");
JButton btn6=new JButton("x");
JFrame fm=new JFrame("GridLayout");
fm.setBounds(100, 100, 300, 200);
fm.setVisible(true);
fm.setResizable(true);
fm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
fm.setLayout(new BorderLayout());
fm.add(btn1,BorderLayout.NORTH);
fm.add(btn2,BorderLayout.SOUTH);
fm.add(btn3,BorderLayout.WEST);
fm.add(btn4,BorderLayout.CENTER);
fm.add(btn5,BorderLayout.EAST);
}
public static void main(String args[]){
new Ch01();
}
}
複製代碼
作者:
張峻瑋
時間:
2016-9-3 16:32
import javax.swing.JFrame;
import javax.swing.JButton;
import java.awt.BorderLayout;
public class Ch115{
private JFrame fm=new JFrame("BorderLayout");
private JButton btn1,btn2,btn3,btn4,btn5;
Ch115()
{
JButton btn1=new JButton("xxx");
JButton btn2=new JButton("xxxxxxx");
JButton btn3=new JButton("xxxxxxxxxxx");
JButton btn4=new JButton("xxxxxxxxx xxxxxxx");
JButton btn5=new JButton("xxx");
fm.setBounds(100, 100, 300, 200);
fm.setVisible(true);
fm.setResizable(true);
fm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
fm.setLayout(new BorderLayout(5,5));
fm.add(btn1,BorderLayout.NORTH);
fm.add(btn2,BorderLayout.SOUTH);
fm.add(btn3,BorderLayout.WEST);
fm.add(btn4,BorderLayout.CENTER);
fm.add(btn5,BorderLayout.EAST);
}
public static void main(String[] args) {
new Ch115();
}
}
複製代碼
作者:
劉得恩
時間:
2016-9-3 16:35
import javax.swing.*;
import java.awt.BorderLayout;
public class Ch115 {
private JFrame f;
private JButton btn[]=new JButton[]{new JButton("xxx"),new JButton("xxxxxxx"),new JButton("xxxxxxxxxxx"),new JButton("xxxxxxxxxxx"),new JButton("xxx")};
Ch115()
{
f=new JFrame("\u30df\udcef");
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setResizable(true);
f.setVisible(true);
f.setBounds(100,100,300,200);
f.setLayout(new BorderLayout(5,5));
f.add(btn[0],BorderLayout.NORTH);
f.add(btn[1],BorderLayout.SOUTH);
f.add(btn[2],BorderLayout.WEST);
f.add(btn[3],BorderLayout.CENTER);
f.add(btn[4],BorderLayout.EAST);
}
public static void main(String[] args) {
new Ch115();
}
}
複製代碼
作者:
張彥承
時間:
2016-9-3 16:49
import javax.swing.JFrame;
import javax.swing.JButton;
import java.awt.BorderLayout;
public class Ch100 {
JFrame fm;
JButton btn1,btn2,btn3,btn4,btn5,btn6;
Ch100()
{
JButton btn1=new JButton("xxx");
JButton btn2=new JButton("xxxxxxx");
JButton btn3=new JButton("xxxxxxxxxxx");
JButton btn4=new JButton("xxxxxxxxx xxxxxxx");
JButton btn5=new JButton("xxx");
fm=new JFrame("BorderLayout");
fm.setBounds(100, 100, 300, 200);
fm.setVisible(true);
fm.setResizable(true);
fm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
fm.setLayout(new BorderLayout(5,5));
fm.add(btn1,BorderLayout.NORTH);
fm.add(btn2,BorderLayout.SOUTH);
fm.add(btn3,BorderLayout.WEST);
fm.add(btn4,BorderLayout.EAST);
fm.add(btn5,BorderLayout.CENTER);
}
public static void main(String[] args) {
new Ch100();
}
}
複製代碼
作者:
林宇翔
時間:
2016-9-24 09:11
import javax.swing.JFrame;
import javax.swing.JButton;
import java.awt.BorderLayout;
public class ch113
{
JFrame fm;
JButton btn1,btn2,btn3,btn4,btn5,btn6;
ch113()
{
JButton btn1=new JButton("xxx");
JButton btn2=new JButton("xxxxxxx");
JButton btn3=new JButton("xxxxxxxxxxx");
JButton btn4=new JButton("xxxxxxxxx xxxxxxx");
JButton btn5=new JButton("xxx");
fm=new JFrame("BorderLayout");
fm.setBounds(100, 100, 300, 200);
fm.setVisible(true);
fm.setResizable(true);
fm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
fm.setLayout(new BorderLayout(5,5));
fm.add(btn1, BorderLayout.NORTH);
fm.add(btn2, BorderLayout.SOUTH);
fm.add(btn3, BorderLayout.WEST);
fm.add(btn4, BorderLayout.CENTER);
fm.add(btn5, BorderLayout.EAST);
}
public static void main(String[] args)
{
new ch113();
}
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://istak.org.tw/seed/)
Powered by Discuz! 7.2