📄 buttonwithlargefont.java
字号:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
class ButtonWithLargeFont extends JFrame implements ActionListener {
private JButton button;
private JPanel panel;
public static void main(String[] args) {
ButtonWithLargeFont frame = new ButtonWithLargeFont();
frame.setSize(400,300);
frame.createGUI();
frame.show();
}
private void createGUI() {
setDefaultCloseOperation(EXIT_ON_CLOSE);
Container window = getContentPane();
window.setLayout(new FlowLayout() );
panel = new JPanel();
panel.setPreferredSize(new Dimension(300, 200));
panel.setBackground(Color.white);
window.add(panel);
button = new JButton("Press me");
button.setFont(new Font(null, Font.BOLD, 60));
window.add(button);
button.addActionListener(this);
}
public void actionPerformed(ActionEvent event) {
Graphics paper = panel.getGraphics();
paper.drawLine(0,0,111,113);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -