문제

JSlider slider = new JSlider();
slider.x();
slider.domorestuff();

JLabel label = new JLabel();
label.setBorder(BorderFactory.createTitledBorder("X"));
label.setPreferredSize(new Dimension(780, 100));
label.setVisible(true);
label.add(slider);

frame.add(label);

If I add the label I see a label with nothing in it. If I add only the slider it will be displayed normally

도움이 되었습니까?

해결책

Both JSlider and JLabel are core components. You can't add JSlider on top of JLabel. Use container like JPanel to add JSlider.

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