我已经为基本的文本编辑器创建了一个布局,我希望顶部栏的左边是按钮,顶栏是JPanel,它使用的是FlowLayout管理器.它使用GridBag布局管理器在网格内部.有什么建议?
import java.awt.*;
import javax.swing.*;
public class GridTest {
private static JButton firstButton, secondButton, thirdButton;
private static JPanel panel, sidebar, infoPanel;
private static JTextArea textArea;
public static void addComponentsToPane(Container container) {
container.setLayout(new GridBagLayout());
GridBagConstraints c = new GridBagConstraints();
firstButton = new JButton("Button 1");
secondButton = new JButton("Button 2");
thirdButton = new JButton("Button 3");
panel = new JPanel(new FlowLayout());
sidebar = new JPanel(new FlowLayout());
infoPanel = new JPanel(new FlowLayout());
textArea = new JTextArea("This is some generic text!");
c.fill = GridBagConstraints.HORIZONTAL;
c.ipady …Run Code Online (Sandbox Code Playgroud)