Fit size of an ImageIcon to a JButton [duplicate]
问题 This question already has answers here : Resizing icon to fit on JButton in Java? (4 answers) Closed 3 years ago . Hi how can I fit the size of a ImageIcon to a JButton? I want to adjust the size of the ImageIcon to the size of the Button 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