-1

私はJFrame3つJPanelのコンテナを持っています。1つは上に、もう1つは左側にあり、最後のコンテナは中央にあり、フレームの残りを占めています。問題は、サイド パネルに を設定しようとするとSpringLayout、パネルに表示されないことです。フレームには、デフォルトのボーダー レイアウトがあります。

public final class board extends JFrame {

    public final JPanel top = new JPanel();
    public final JPanel side = new JPanel();
    public final JPanel center = new JPanel();

    public board(){

        initComponents();
        initWindow();

    }

    public void initComponents(){

        Font font = new Font("HelvLight", Font.PLAIN, 20);
        Font fontT = new Font("Century Gothic", Font.BOLD, 30);
        SpringLayout layoutT = new SpringLayout(); 
        JSeparator sep = new JSeparator();
        JLabel title = new JLabel("TITLE");
        JLabel calendar = new JLabel("Calendar");
        JButton settings = new JButton("C"); //Add Icon

        title.setFont(fontT);
        calendar.setFont(font);
        title.setForeground(Color.WHITE);
        calendar.setForeground(Color.WHITE);
        sep.setBackground(Color.white);
        sep.setForeground(Color.white);

        //layoutT.putConstraint(SpringLayout.WEST, calendar, 50, SpringLayout.EAST, center);

        top.setLayout(new BorderLayout());
        top.add(settings, BorderLayout.EAST);

        top.add(title, BorderLayout.CENTER); // Not centered
        top.setBackground(Color.decode("#4C004C"));

        center.setBackground(Color.green);

        side.setBackground(Color.decode("#0f001e"));
        side.setLayout(layoutT);
        side.add(calendar, SpringLayout.SOUTH);
        side.add(sep);
    }

    public void initWindow() {
        Toolkit tk = Toolkit.getDefaultToolkit();

        setDefaultCloseOperation(EXIT_ON_CLOSE);
        setSize((int)  tk.getScreenSize().getWidth() ,
                (int)  tk.getScreenSize().getHeight()
              );
        //setResizable(false);

        add(top, BorderLayout.NORTH);
        add(side, BorderLayout.WEST);
        add(center, BorderLayout.CENTER);

        pack();
        setVisible(true);
    }
}

それは私にとってはうまくいくはずですが、そうではありません。

4

1 に答える 1