Java????????????????
???????????? ???????[ 2013/4/8 10:31:19 ] ????????
????????????д????????й?JAVA????????е???????????????????????????? NetBeans ??????Eclipse ???????????????????????????????????????????????????棬?????£???????????????
????JAVA??Layout Mananager??ν???????????????BorderLayout??FlowLayout??GridLayout??GridLayBagout
????1??BorderLayout??JFrame?е??????????????????????????????????岼????????????????????????????????????????????????????????????λ???????????????????????????????????BorderLayout ???СС???????
import javax.swing.*;
import java.awt.*;
public class BorderLayout1 {
public BorderLayout1(){
JFrame frame=new JFrame();
frame.add(BorderLayout.NORTH??new JButton("North"));
frame.add(BorderLayout.SOUTH??new JButton("South"));
frame.add(BorderLayout.WEST??new JButton("West"));
frame.add(BorderLayout.EAST??new JButton("East"));
frame.add(BorderLayout.CENTER??new JButton("Center"));
frame.setVisible(true);
frame.setSize(400??200);
}
public static void main(String[] args) {
new BorderLayout1();
}
}
????????????????浱????к?淶????????????????????????????????????д???????????????????沼??Ч????
????2??FlowLayout ?????????????????????????????????????????????棬?????????????赲?????????????????????????????????齫?????????????????????????????????????????????????С??ò???????????????£?
import javax.swing.*;
import java.awt.*;
public class FlowLayout1{
public FlowLayout1() {
JFrame frame=new JFrame();
frame.setLayout(new FlowLayout());
for(int i = 1; i <=5; i++)
frame.add(new JButton("Button " + i));
frame.setVisible(true);
frame.setSize(500??100);
}
public static void main(String[] args) {
new FlowLayout1();
}
}
????3??GridLayout ????????????齫????????????????У??????????????????????????????????????????????????????????BorderLayout ???????????????????????????????????????????????????????????????????????????????????Ч???????????С?????
import javax.swing.*;
import java.awt.*;
public class GridLayout1 {
public GridLayout1() {
JFrame frame=new JFrame();
frame.setLayout(new GridLayout(3??2)); //3??2?е?????
for(int i = 0; i < 7; i++)
frame.add(new JButton("Button " + i));
frame.setVisible(true);
frame.setSize(500??300);
}
public static void main(String[] args) {
new GridLayout1();
}
}
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11