📄 borderwindow.java
字号:
/* * Swing version. */import java.awt.*;import java.awt.event.*;import javax.swing.*;public class BorderWindow extends JFrame { boolean inAnApplet = true; public BorderWindow() { Container contentPane = getContentPane(); //Use the content pane's default BorderLayout. //contentPane.setLayout(new BorderLayout()); //unnecessary contentPane.add(new JButton("Button 1 (NORTH)"), BorderLayout.NORTH); contentPane.add(new JButton("2 (CENTER)"), BorderLayout.CENTER); contentPane.add(new JButton("Button 3 (WEST)"), BorderLayout.WEST); contentPane.add(new JButton("Long-Named Button 4 (SOUTH)"), BorderLayout.SOUTH); contentPane.add(new JButton("Button 5 (EAST)"), BorderLayout.EAST); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { if (inAnApplet) { dispose(); } else { System.exit(0); } } }); } public static void main(String args[]) { BorderWindow window = new BorderWindow(); window.inAnApplet = false; window.setTitle("BorderLayout"); window.pack(); window.setVisible(true); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -