문제

I have a FlowLayout where default alignment of the component is CENTER. I want to change the component alignment (some Buttons) to left when the left button is clicked Like all the buttons will be skewed to left.

and this is my left button actionListener code

    left.addActionListener(new ActionListener(){

        @Override
        public void actionPerformed(ActionEvent e) {
            setLayout(new FlowLayout(FlowLayout.LEFT));

        }

    });

What is the problem here?

도움이 되었습니까?

해결책

Use revalidate() after changing layout.

left.addActionListener(new ActionListener(){

        @Override
        public void actionPerformed(ActionEvent e) {
            setLayout(new FlowLayout(FlowLayout.LEFT));
            revalidate();
        }

    });
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top