0
I'm guessing you're using the JButton class, in javax.swing.JButton ?
To set the text inside the button (for example, "Post" or "Submit" or "Quit" or "Do Stuff"), when you first make the JButton, pass a String to the constructor. Like so:
JButton quitButton = new JButton("Quit");
To make the button do stuff when you click on it, use the JButton addActionListener() method. You can use a lambda expression like this:
quitButton.addActionListener((ActionEvent event) -> {
// Put code here.
// It will be executed when the button is pressed!
});
Or structure your code like this, which helps you see what's going on a bit better if you're not familiar with lambda expressions:
quitButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
// Put code here.
// It will be executed when the button is pressed!
}
});



