Write a program to create a frame with three button. When any of three button is selected, an appropriate message is displayed.
Answers
Answer:
/ Java program to create frames
// using association
import javax.swing.*;
public class test1
{
JFrame frame;
test1()
{
// creating instance of JFrame with name "first way"
frame=new JFrame("first way");
// creates instance of JButton
JButton button = new JButton("let's see");
button.setBounds(200, 150, 90, 50);
// setting close operation
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
// adds button in JFrame
frame.add(button);
// sets 500 width and 600 height
frame.setSize(500, 600);
// uses no layout managers
frame.setLayout(null);
// makes the frame visible
frame.setVisible(true);
}
public static void main(String[] args)
{
new test1();
}
}