📄 test.java
字号:
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
public class Test extends JFrame {
public Test() {
Container contentPane = getContentPane();
JPanel panel = new JPanel();
panel.setBorder(BorderFactory.createEtchedBorder());
contentPane.add(panel,BorderLayout.CENTER);
contentPane.add(GJApp.getStatusArea(),BorderLayout.SOUTH);
GJApp.showStatus(GJApp.getResource("statusAreaText"));
}
public static void main(String args[]) {
GJApp.launch(new Test(),"Status Area",300,300,450,300);
}
}
class GJApp {
static private JPanel statusArea = new JPanel();
static private JLabel status = new JLabel("");
static private ResourceBundle resources;
static {
resources = ResourceBundle.getBundle(
"GJApp", Locale.getDefault());
};
private GJApp() {} // defeat instantiation
public static void launch(final JFrame f, String title,
final int x, final int y,
final int w, int h) {
f.setTitle(title);
f.setBounds(x,y,w,h);
f.setVisible(true);
statusArea.setBorder(BorderFactory.createEtchedBorder());
statusArea.setLayout(new FlowLayout(FlowLayout.LEFT,0,0));
statusArea.add(status);
status.setHorizontalAlignment(JLabel.LEFT);
f.setDefaultCloseOperation(
WindowConstants.DISPOSE_ON_CLOSE);
f.addWindowListener(new WindowAdapter() {
public void windowClosed(WindowEvent e) {
System.exit(0);
}
});
}
static public JPanel getStatusArea() {
return statusArea;
}
static public void showStatus(String s) {
status.setText(s);
}
static String getResource(String key) {
return (resources == null) ? null :
resources.getString(key);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -