📄 frame1.java~19~
字号:
package com.cdaccp.view;
import java.awt.*;
import javax.swing.*;
public class Frame1
extends JFrame {
GridBagLayout gridBagLayout1 = new GridBagLayout();
JButton jButton2 = new JButton();
JLabel jLabel1 = new JLabel();
JTextField jTextField1 = new JTextField();
public Frame1() {
try {
jbInit();
}
catch (Exception exception) {
exception.printStackTrace();
}
}
private void jbInit() throws Exception {
getContentPane().setLayout(gridBagLayout1);
jButton2.setText("jButton2");
jLabel1.setText("jLabel1");
jTextField1.setText("jTextField1");
GridBagConstraints c = new GridBagConstraints();
c.fill = GridBagConstraints.NORTHWEST;
c.weightx=2;
c.gridx=0;
c.gridy = 0;
makebutton(jButton2,gridBagLayout1,c);
c.gridx=1;
c.gridy = 1;
makebutton(jLabel1,gridBagLayout1,c);
c.gridx=0;
c.gridy = 1;
}
void makebutton(Component component,
GridBagLayout gridbag,
GridBagConstraints c) {
gridbag.setConstraints(component, c);
add(component);
}
public static void main(String[] args) {
Frame1 frame1 = new Frame1();
frame1.setSize(400, 300);
frame1.setVisible(true);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -