Skip to content

Instantly share code, notes, and snippets.

@uncoded-ro
Created June 14, 2022 07:24
Show Gist options
  • Save uncoded-ro/d3e21d39d3e3d4b4f81eeaffdb158a5a to your computer and use it in GitHub Desktop.
Save uncoded-ro/d3e21d39d3e3d4b4f81eeaffdb158a5a to your computer and use it in GitHub Desktop.
package ro.virtualcampus.gui;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class ButtonPanel extends JPanel implements ActionListener {
private static final long serialVersionUID = 1L;
private JButton ok, cancel;
private JLabel text;
public ButtonPanel() {
ok = new JButton("Ok");
ok.setFont(new Font(" Arial ", Font.BOLD, 12));
ok.setBackground(Color.YELLOW);
cancel = new JButton("Cancel");
text = new JLabel("Apasa un buton !");
add(ok);
add(cancel);
add(text);
ok.addActionListener(this);
cancel.addActionListener(this);
}
public void actionPerformed(ActionEvent e) {
text.setText(e.getActionCommand());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment