Java Frame
unknown
plain_text
3 years ago
966 B
12
Indexable
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
class ForStudents extends JFrame implements ActionListener
{
private static final int width = 500;
private static final int height = 500;
private static final int fxo = 150;
private static final int fxy = 250;
private JButton btnOK;
public ForStudents()
{
Container contain = getContentPane();
setSize(width,height);
setResizable(false);
setTitle("This is you sample Frame");
setLocation(fxo,fxy);
contain.setLayout(new FlowLayout());
btnOK = new JButton("PRINT");
contain.add(btnOK);
btnOK.addActionListener(this);
}
public static void main(String[]args)
{
ForStudents frame = new ForStudents();
frame.setVisible(true);
}
public void actionPerformed(ActionEvent event)
{
JButton btnclick = (JButton)event.getSource();
String btnText = btnclick.getText();
setTitle("You Clicked " + btnText);
}
}Editor is loading...