0
最大値が2に設定されている水平スクロールバーを作成したい場合(0,1または2を値として選択する必要があります)、ノブは表示されません。私は12にmaximum
値を変更すると値がより小さい11JScrollBar:小さな最大値でノブが表示されない
scrlLineDist = new JScrollBar();
scrlLineDist.setBlockIncrement(1);
scrlLineDist.addAdjustmentListener(new AdjustmentListener() {
public void adjustmentValueChanged(AdjustmentEvent e) {
System.out.println(scrlLineDist.getValue());
}
});
GridBagConstraints gbc_scrlLineDist = new GridBagConstraints();
gbc_scrlLineDist.insets = new Insets(0, 0, 5, 0);
gbc_scrlLineDist.fill = GridBagConstraints.HORIZONTAL;
gbc_scrlLineDist.gridx = 0;
gbc_scrlLineDist.gridy = 3;
panel_4.add(scrlLineDist, gbc_scrlLineDist);
scrlLineDist.setMaximum(2);
scrlLineDist.setToolTipText("");
scrlLineDist.setOrientation(JScrollBar.HORIZONTAL);
であり、それは私が望むように動作(可視ノブ、値[0,2])。なぜこうなった?あなたが探しているものを
scrlLineDist = new JScrollBar();
scrlLineDist.setBlockIncrement(1);
scrlLineDist.addAdjustmentListener(new AdjustmentListener() {
public void adjustmentValueChanged(AdjustmentEvent e) {
System.out.println(scrlLineDist.getValue());
}
});
GridBagConstraints gbc_scrlLineDist = new GridBagConstraints();
gbc_scrlLineDist.insets = new Insets(0, 0, 5, 0);
gbc_scrlLineDist.fill = GridBagConstraints.HORIZONTAL;
gbc_scrlLineDist.gridx = 0;
gbc_scrlLineDist.gridy = 3;
panel_4.add(scrlLineDist, gbc_scrlLineDist);
scrlLineDist.setMaximum(12);
scrlLineDist.setToolTipText("");
scrlLineDist.setOrientation(JScrollBar.HORIZONTAL);
おっとをチェックアウトし、
JSlider
の詳細については、公式チュートリアルについてそうです。ありがとうございました! –