0
你好我如何適應一個ImageIcon的大小JButton?我想通過簡單地增加一個小方法,你的項目給ImageIcon的大小調整到Button適合JButton ImageIcon的大小
JFrame frame2 = new JFrame("Tauler Joc");
JPanel panell = new JPanel();
ImageIcon icon = new ImageIcon("king.jpg");
JButton jb= new JButton(icon);
jb.setBounds(200,200,700,700);
panell.add(jb);
frame2.add(panell);
frame2.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
如果要將圖像圖標大小調整爲700px,請調整大小700px搜索有關如何調整大小圖像 – Blip
您可能還想看看[this](http://stackoverflow.com/questions/11959758/java-maintaining -aspect-ratio-of-jpanel-background-image/11959928#11959928)和[this](http://stackoverflow.com/questions/14115950/quality-of-image-after-resize-very-low-java/ 14116752#14116752) – MadProgrammer