Код: Выделить всё
import javax.swing.BorderFactory;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import javax.swing.WindowConstants;
import java.awt.Color;
import java.awt.Dimension;
public class ResizingExample {
public static void main(String[] args) {
SwingUtilities.invokeLater(ResizingExample::launch);
}
private static void launch() {
JFrame frame = new JFrame("ScrollPane Example");
frame.setContentPane(createPanel());
frame.setLocationRelativeTo(null);
frame.pack();
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
frame.setVisible(true);
}
private static JPanel createPanel() {
JPanel panel = new JPanel();
panel.setBorder(BorderFactory.createLineBorder(Color.RED, 3));
panel.setPreferredSize(new Dimension(250, 150));
return panel;
}
}
На случай, если вам интересно, процессор Amd Ryzen 3 1200 Quad-Core.>
Подробнее здесь: https://stackoverflow.com/questions/796 ... e-resizing