Java JSplitPane LookAndFeel图案减少按钮或拇指

Java JSplitPane LookAndFeel图案减少按钮或拇指,java,look-and-feel,jsplitpane,motif,Java,Look And Feel,Jsplitpane,Motif,我以前问过这个问题: 我测试了我的代码,但是当LookAndFeel是Motif时,我不能拖动JSplitPane public class JFr_SplitPaneMotif extends JFrame { private JButton jbRight = new JButton(); private JLabel jlLeft = new JLabel(); private JPanel jpLeft = new JPanel();

我以前问过这个问题:

我测试了我的代码,但是当LookAndFeel是Motif时,我不能拖动JSplitPane

    public class JFr_SplitPaneMotif extends JFrame {

      private JButton jbRight = new JButton();
      private JLabel jlLeft = new JLabel();
      private JPanel jpLeft = new JPanel();
      private JPanel jpRight = new JPanel();
      private JPanel jpMain = new JPanel();
      private JSplitPane jspMain = new JSplitPane();
      private JTextField jtfLeft = new JTextField();
      private JTextField jtfRight = new JTextField();

      public JFr_SplitPaneMotif() {
        setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

        jpMain.setBorder(BorderFactory.createEtchedBorder());
        jpMain.setPreferredSize(new Dimension(692, 36));

        jspMain.setDividerLocation(0.5);
        jspMain.setOneTouchExpandable(true);
        jspMain.setPreferredSize(new Dimension(338, 30));

        jlLeft.setBorder(BorderFactory.createEtchedBorder());

        jpLeft.setPreferredSize(new Dimension(320, 25));
        jlLeft.setPreferredSize(new Dimension(24, 18));
        jtfLeft.setPreferredSize(new Dimension(6, 25));

        jpRight.setPreferredSize(new Dimension(320, 25));
        jbRight.setPreferredSize(new Dimension(24, 18));
        jbRight.setMinimumSize(new Dimension(24, 18)); /*Why is smaller?*/
        jtfRight.setPreferredSize(new Dimension(6, 25));

        GroupLayout jpLeftLayout = new GroupLayout(jpLeft);
        jpLeft.setLayout(jpLeftLayout);
        jpLeftLayout.setHorizontalGroup(
          jpLeftLayout.createParallelGroup(Alignment.LEADING)
          .addGroup(jpLeftLayout.createSequentialGroup()
            .addGap(4, 4, 4)
            .addComponent(jlLeft, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
            .addGap(2, 2, 2)
            .addComponent(jtfLeft, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addContainerGap())
        );
        jpLeftLayout.setVerticalGroup(
          jpLeftLayout.createParallelGroup(Alignment.LEADING)
          .addGroup(jpLeftLayout.createSequentialGroup()
            .addGap(3, 3, 3)
            .addComponent(jlLeft, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
            .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
          .addComponent(jtfLeft, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
        );

        jspMain.setLeftComponent(jpLeft);

        GroupLayout jpRightLayout = new GroupLayout(jpRight);
        jpRight.setLayout(jpRightLayout);
        jpRightLayout.setHorizontalGroup(
          jpRightLayout.createParallelGroup(Alignment.LEADING)
          .addGroup(jpRightLayout.createSequentialGroup()
            .addGap(4, 4, 4)
            .addComponent(jbRight, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
            .addGap(2, 2, 2)
            .addComponent(jtfRight, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addContainerGap())
        );
        jpRightLayout.setVerticalGroup(
          jpRightLayout.createParallelGroup(Alignment.LEADING)
          .addGroup(jpRightLayout.createParallelGroup(Alignment.CENTER)
            .addComponent(jbRight, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
            .addComponent(jtfRight, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
        );

        jspMain.setRightComponent(jpRight);

        GroupLayout jpMainLayout = new GroupLayout(jpMain);
        jpMain.setLayout(jpMainLayout);
        jpMainLayout.setHorizontalGroup(
          jpMainLayout.createParallelGroup(Alignment.LEADING)
          .addComponent(jspMain, Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        jpMainLayout.setVerticalGroup(
          jpMainLayout.createParallelGroup(Alignment.LEADING)
          .addGroup(Alignment.TRAILING, jpMainLayout.createSequentialGroup()
            .addGap(0, 0, 0)
            .addComponent(jspMain, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
        );

        GroupLayout layout = new GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
          layout.createParallelGroup(Alignment.LEADING)
          .addGap(0, 702, Short.MAX_VALUE)
          .addGroup(layout.createParallelGroup(Alignment.LEADING)
            .addGroup(Alignment.TRAILING, layout.createSequentialGroup()
              .addGap(0, 0, 0)
              .addComponent(jpMain, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
              .addContainerGap()))
        );
        layout.setVerticalGroup(
          layout.createParallelGroup(Alignment.LEADING)
          .addGap(0, 54, Short.MAX_VALUE)
          .addGroup(layout.createParallelGroup(Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
              .addGap(0, 0, 0)
              .addComponent(jpMain, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
              .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
        );

        pack();
      }

      public static void main(String args[]) {
        try {
          UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel");
        } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) {
        }

        EventQueue.invokeLater(new Runnable() {
          public void run() {
            new JFr_SplitPaneMotif().setVisible(true);
          }
        });
      }
    }
我在测试,我有我的图像:

Linux:

Mac:

窗口:

问题是:

  • 如何减少JSplitPane的(左和右)“三角形”的大小?

  • 为什么JButton不保留首选项?