CardLayout 按钮和 TextField 大小

问题描述

我正在尝试使用 cardlayout 修复文本字段、文本区域和按钮的大小。目前,它们太大了,我想将它们的尺寸缩小到更正常的尺寸。

到目前为止,我没有运气。我的代码在下面,代码后面有截图链接

public JPanel card3Panel(){
        //JLabel label3 = new JLabel( "card three" );
       
          JPanel card3 = new JPanel();
          card3.setLayout(new GridLayout(3,1));
          lSearch = new JLabel("Enter student's name",SwingConstants.RIGHT);
          card3.add(lSearch,BorderLayout.norTH);
          sSearch = new JTextField(10);
          card3.add(sSearch,BorderLayout.EAST);
          searchButton = new JButton("Submit student search");
          card3.add(searchButton,BorderLayout.soUTH);
          searchButton.addActionListener(this);
          search = new JTextArea(20,20);
          card3.add(search);
          return card3;

按钮屏幕截图:

https://i.stack.imgur.com/EcELL.png

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)