Java??????????????
???????????? ???????[ 2017/3/2 11:15:49 ] ??????????????????? Java
??????貌????????
????FlowLayout??????
?????????????????????java.awt???械?FlowLayout?????FlowLayout??????????????????????????????????????????校????????锌??????????小?
1 import java.awt.*;
2 import javax.swing.*;
3
4 public class Crisis extends JFrame {
5 JButton panicButton;
6 JButton dontPanicButton;
7 JButton blameButton;
8 JButton mediaButton;
9 JButton saveButton;
10
11 public Crisis() {
12 super("Crisis");
13 setLookAndFeel();
14 setSize(348?? 128);
15 setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
16 // 1.??????
17 FlowLayout flo = new FlowLayout();
18 setLayout(flo);
19 panicButton = new JButton("Panic");
20 dontPanicButton = new JButton("Don't Panic");
21 blameButton = new JButton("Blame Others");
22 mediaButton = new JButton("Notify the Media");
23 saveButton = new JButton("save yourself");
24 add(panicButton);
25 add(dontPanicButton);
26 add(blameButton);
27 add(mediaButton);
28 add(saveButton);
29 setVisible(true);
30 }
31
32 private void setLookAndFeel() {
33 try {
34 UIManager.setLookAndFeel(
35 "com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
36 } catch (Exception exc) {
37 // ignore error
38 }
39 }
40
41 public static void main(String[] arguments) {
42 Crisis frame = new Crisis();
43 }
44 }
????GridLayout??????
????GridLayout??位??java.awt???校??????????????械??????????????????????????????????????????????????
??????????????????????GridLayout?????械??????????????械????位??????????????????????????????????????????????械??????????
1 import java.awt.*;
2 import javax.swing.*;
3
4 public class Crisis extends JFrame {
5 JButton panicButton;
6 JButton dontPanicButton;
7 JButton blameButton;
8 JButton mediaButton;
9 JButton saveButton;
10
11 public Crisis() {
12 super("Crisis");
13 setLookAndFeel();
14 setSize(348?? 128);
15 setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
16
17 // 2.GridLayout????
18 GridLayout grid = new GridLayout(2?? 3);
19 setLayout(grid);
20 panicButton = new JButton("Panic");
21 dontPanicButton = new JButton("Don't Panic");
22 blameButton = new JButton("Blame Others");
23 mediaButton = new JButton("Notify the Media");
24 saveButton = new JButton("save yourself");
25 add(panicButton);
26 add(dontPanicButton);
27 add(blameButton);
28 add(mediaButton);
29 add(saveButton);
30 setVisible(true);
31 }
32
33 private void setLookAndFeel() {
34 try {
35 UIManager.setLookAndFeel(
36 "com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
37 } catch (Exception exc) {
38 // ignore error
39 }
40 }
41
42 public static void main(String[] arguments) {
43 Crisis frame = new Crisis();
44 }
45 }
????BorderLay??????
????BorderLayout???位??java.awt???校??????????械???????????????位?????位????5????位??????????????????小?
????BorderLayout????????????????5??位???????4??位??????????????????????????????????????????貌??????????????add()???????????2???????????????????梅????位?谩??貌????????BorderLayout???5???????????NORTH??SOUTH??EAST??WEST??CENTER??
??????GridLayout???????BorderLayout??????锌???????????????????围????4?????????????渭???????????????????????????????
1 import java.awt.*;
2 import javax.swing.*;
3
4 public class Crisis extends JFrame {
5 JButton panicButton;
6 JButton dontPanicButton;
7 JButton blameButton;
8 JButton mediaButton;
9 JButton saveButton;
10
11 public Crisis() {
12 super("Crisis");
13 setLookAndFeel();
14 setSize(348?? 128);
15 setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
16 BorderLayout crisisLayout = new BorderLayout();
17 setLayout(crisisLayout);
18
19 panicButton = new JButton("Panic");
20 dontPanicButton = new JButton("Don't Panic");
21 blameButton = new JButton("Blame Others");
22 mediaButton = new JButton("Notify the Media");
23 saveButton = new JButton("save yourself");
24 add(panicButton?? BorderLayout.NORTH);
25 add(dontPanicButton?? BorderLayout.SOUTH);
26 add(blameButton?? BorderLayout.EAST);
27 add(mediaButton?? BorderLayout.WEST);
28 add(saveButton?? BorderLayout.CENTER);
29 setVisible(true);
30 }
31
32 private void setLookAndFeel() {
33 try {
34 UIManager.setLookAndFeel(
35 "com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
36 } catch (Exception exc) {
37 // ignore error
38 }
39 }
40
41 public static void main(String[] arguments) {
42 Crisis frame = new Crisis();
43 }
44 }
??????

???路???
??????????????????
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