The method addChangeListener(ChangeListener) in the type JSlider is not applicable for the arguments (new ChangeListener(){}). fIx this. // Гистограмма для sawtooth4Image()
private void sawtooth4Image() {
if (image != null) {
// Запрос значения порогов в цикле до тех пор, пока пользователь не введет правильные значения
float t1 = 0, t2 = 0;
boolean valid = false;
while (!valid) {
t1 = userInput("Введите значение порога 1: ", 0, 1);
t2 = userInput("Введите значение порога 2: ", 0, 1);
if (t2 > t1) {
valid = true;
} else {
JOptionPane.showMessageDialog(null,“Значение порога 2 должно быть больше порога 1”);
}
}

BufferedImage sawtoothContrastImage1 = sawtoothContrastUp(image, t1, t2);
setImageIcon(sawtoothContrastImage1);
saveImage(sawtoothContrastImage1);

BufferedImage sawtoothContrastImage2 = sawtoothContrastDown(image, t1, t2);
setImageIcon(sawtoothContrastImage2);
saveImage(sawtoothContrastImage2);

BufferedImage combinedImage = combineImages(sawtoothContrastImage1, sawtoothContrastImage2, sawtoothContrastImage1);

int[] originalHistogram = ImageReader.getImageHistogram(image);
int[] sawtoothHistogram = ImageReader.getImageHistogram(combinedImage);

JFrame histogramFrame = new JFrame(“Гистограммы””);
histogramFrame.setLayout(new GridLayout(1, 2, 10, 10));

JPanel originalHistogramPanel = ImageReader.createHistogramPanel(originalHistogram,“Гистограмма исходного изображения”);

JPanel sawtoothHistogramPanel = ImageReader.createHistogramPanel(sawtoothHistogram, “Гистограмма после контрастирования”);

// Обработка изменения пороговых значений
JSlider t1Slider = new JSlider(0, 100, (int)(t1 * 100));
JSlider t2Slider = new JSlider(0, 100, (int)(t2 * 100));
t1Slider.setMajorTickSpacing(10);
t1Slider.setPaintTicks(true);
t2Slider.setMajorTickSpacing(10);
t2Slider.setPaintTicks(true);
t1Slider.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
t1 = (float)t1Slider.getValue() / 100;
sawtoothContrastImage1 = sawtoothContrastUp(image, t1, t2);
combinedImage = combineImages(sawtoothContrastImage1, sawtoothContrastImage2, sawtoothContrastImage1);
setImageIcon(combinedImage);
saveImage(combinedImage);
sawtoothHistogram = ImageReader.getImageHistogram(combinedImage);
sawtoothHistogramPanel.removeAll();
sawtoothHistogramPanel.add(ImageReader.createHistogramPanel(sawtoothHistogram, “Гистограмма после контрастирования”));
sawtoothHistogramPanel.revalidate();
sawtoothHistogramPanel.repaint();
}
});
t2Slider.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
t2 = (float)t2Slider.getValue() / 100;
sawtoothContrastImage2 = sawtoothContrastDown(image, t1, t2);
combinedImage = combineImages(sawtoothContrastImage1, sawtoothContrastImage2, sawtoothContrastImage1);
setImageIcon(combinedImage);
saveImage(combinedImage);
sawtoothHistogram = ImageReader.getImageHistogram(combinedImage);
sawtoothHistogramPanel.removeAll();
sawtoothHistogramPanel.add(ImageReader.createHistogramPanel(sawtoothHistogram, “Гистограмма после контрастирования”));
sawtoothHistogramPanel.revalidate();
sawtoothHistogramPanel.repaint();
}
});

JPanel slidersPanel = new JPanel();
slidersPanel.setLayout(new GridLayout(2, 1, 5, 5));
slidersPanel.setBorder(BorderFactory.createTitledBorder(“Пороговые значения”));
slidersPanel.add(t1Slider);
slidersPanel.add(t2Slider);

JPanel sawtoothPanel = new JPanel(new GridLayout(1, 1));
sawtoothPanel.setBorder(BorderFactory.createTitledBorder(“Контрастированное изображение”));
sawtoothPanel.add(new JLabel(new ImageIcon(combinedImage)));

JPanel histogramPanel = new JPanel(new GridLayout(1, 2, 10, 10));
histogramPanel.setBorder(BorderFactory.createTitledBorder(“Гистограммы”));
histogramPanel.add(originalHistogramPanel);
histogramPanel.add(sawtoothHistogramPanel);

JPanel containerPanel = new JPanel(new BorderLayout());
containerPanel.add(slidersPanel, BorderLayout.NORTH);
containerPanel.add(sawtoothPanel, BorderLayout.CENTER);
containerPanel.add(histogramPanel, BorderLayout.SOUTH);

JFrame sawtoothFrame = new JFrame(“Контрастирование через зигзагообразный порог”);
sawtoothFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
sawtoothFrame.add(containerPanel);
sawtoothFrame.setSize(900, 600);
sawtoothFrame.setLocationRelativeTo(null);
sawtoothFrame.setVisible(true);
}
}