Кнопка Swing
JButton b = new JButton();
b.setText("+");
b.setBounds(10,10,100,100);
b.setIcon(new ImageIcon("C:\\img\\1.png"));
b.setFont(new Font("Arial", Font.PLAIN, 40));
JButton b = new JButton("+");
JButton b = new JButton(new ImageIcon("C:\\img\\1.png"));
//"res\\2.jpg", "res/2.jpg", "C:/img/1.png"
import javax.swing.*;
import java.awt.event.*;
public class MyButton implements ActionListener{
JButton b1;
MyButton(){
JFrame f= new JFrame();
b1=new JButton("+");
b1.setBounds(100,100,100,50);
b1.addActionListener(this);
f.add(b1);
f.setSize(300,320);
f.setLayout(null);
f.setVisible(true);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public void actionPerformed(ActionEvent e) {
b1.setText("Працюю");
}
public static void main(String[] args)
{
new MyButton();
}
}