Answer the question
In order to leave comments, you need to log in
How to make the button icon occupy the entire area of the button (fill the button)?
How to make it so that the Icon (picture) of the button Occupies the entire area of the button (filled the button) while not increasing the size of the Button on the Frame, and when the Window is resized, it changes size, but does not stop occupying the entire area of the button?
//Создаю кнопку
my_btn= new JButton();
my_btn.setAlignmentY(0.0f);
my_btn.setFont(new Font("Georgia", my_btn.getFont().getStyle(), 20));
my_btn.setLabel("Колонка 1");
my_btn.setMargin(new Insets(0, 0, 0, 0));
my_btn.setPreferredSize(new Dimension(1, 1));
my_btn.setText("Колонка 1");
//В другом методе добавляю ей иконку(картинку)
try {
Image img = ImageIO.read(getClass().getResource("image.png"));
my_btn.setIcon(new ImageIcon(img));
my_btn.setText(null);
} catch (IOException ex) {
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question