標題:
佈局元件 - BorderLayout
[打印本頁]
作者:
tonyh
時間:
2020-9-7 19:30
標題:
佈局元件 - BorderLayout
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()
{
btn1=new JButton("xxx");
btn2=new JButton("xxxxxxx");
btn3=new JButton("xxxxxxxxxxx");
btn4=new JButton("xxxxxxxxx xxxxxxx");
btn5=new JButton("xxx");
//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));
//如果沒有設Layout,則預設值就是 BorderLayout
//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();
}
}
複製代碼
作者:
戴嘉禾
時間:
2020-9-7 19:55
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()
{
btn1=new JButton("xxx");
btn2=new JButton("xxxxxxx");
btn3=new JButton("xxxxxxxxxxx");
btn4=new JButton("xxxxxxxxx xxxxxxx");
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 Ch01();
}
}
複製代碼
作者:
黃宇綸
時間:
2020-9-7 19:56
本帖最後由 黃宇綸 於 2020-9-7 20: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()
{
btn1=new JButton("xxx");
btn2=new JButton("xxxxxxx");
btn3=new JButton("xxxxxxxxxxx");
btn4=new JButton("xxxxxxxxx xxxxxxx");
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 Ch01();
}
}
複製代碼
作者:
黃宇瑄
時間:
2020-9-7 20:00
import javax.swing.JFrame;
import javax.swing.JButton;
import java.awt.BorderLayout;
public class Ch01 {
JFrame fm;
JButton b1,b2,b3,b4,b5,b6;
Ch01()
{
b1=new JButton("xxx");
b2=new JButton("xxxxxxx");
b3=new JButton("xxxxxxxxxxx");
b4=new JButton("xxxxxxxxx xxxxxxx");
b5=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(b1, BorderLayout.NORTH);
fm.add(b2, BorderLayout.SOUTH);
fm.add(b3, BorderLayout.WEST);
fm.add(b4, BorderLayout.CENTER);
fm.add(b5, BorderLayout.EAST);
}
public static void main(String[] args) {
new Ch01();
}
}
複製代碼
作者:
李沛昂
時間:
2020-9-7 20:09
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()
{
btn1=new JButton("xxx");
btn2=new JButton("xxxxxxx");
btn3=new JButton("xxxxxxxxxxx");
btn4=new JButton("xxxxxxxxx xxxxxxx");
btn5=new JButton("xxx");
//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));
//如果沒有設Layout,則預設值就是 BorderLayout
//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();
}
}
複製代碼
作者:
鄭楀諺
時間:
2020-9-18 19:05
import java.awt.BorderLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
public class Ch130 {
JFrame fn;
JButton btn1, btn2, btn3, btn4, btn5, btn6;
Ch130()
{
btn1 = new JButton("xxx");
btn2 = new JButton("xxxxxxx");
btn3 = new JButton("xxxxxxxxxxx");
btn4 = new JButton("xxxxxxxxx xxxxxxx");
btn5 = new JButton("xxx");
//btn6 = new JButton("x");
fn = new JFrame("Grid");
fn.setBounds(100, 100, 300, 200);
fn.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
fn.setVisible(true);
fn.setLayout(new BorderLayout(5, 5));
fn.add(btn1, BorderLayout.NORTH);
fn.add(btn2, BorderLayout.SOUTH);
fn.add(btn3, BorderLayout.EAST);
fn.add(btn4, BorderLayout.WEST);
fn.add(btn5, BorderLayout.CENTER);
//fn.add(btn6);
}
public static void main(String[] args) {
new Ch130();
}
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://seed.istak.org.tw/)
Powered by Discuz! 7.2