import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
class GuiFlowLayout extends JFrame implements ActionListener
{
private JButton cancelButton;
private JButton okButton;
private JLabel promptText1;
public GuiFlowLayout( )
{
super("Sample Gui using Flow Layout");
setLayout(new FlowLayout());
okButton = new JButton("Ok");
add(okButton);
cancelButton = new JButton("Cancel");
add(cancelButton);
promptText1 = new JLabel();
promptText1.setText("Code:");
add(promptText1);
okButton.addActionListener(this);
cancelButton.addActionListener(this);
setDefaultCloseOperation(EXIT_ON_CLOSE);
}
public void actionPerformed(ActionEvent event)
{
JButton clickedButton = (JButton) event.getSource();
String buttonText = clickedButton.getText();
setTitle("You clicked " + buttonText);
}
public static void main(String[] args)
{
GuiFlowLayout frame = new GuiFlowLayout();
frame.setSize(100,150);
frame.setResizable(false);
frame.setVisible(true);
}
}