I need help With these four questions. 1)Write an event handler that displays th
ID: 3660263 • Letter: I
Question
I need help With these four questions. 1)Write an event handler that displays the message "key Pressed" on the console whenever a key is pressed on the keyboard. 2) Write Java statements to create a new thread and put it in the ready queue. 3) Write a code segment to create three radio button such that whenever one of the buttons is selected the other two buttons are deselected automatically. 4) Write a program to create and display a window of size (300, 300) with the title "An empty Window" the program should exit when the window is closed.Explanation / Answer
Ive only done #4 for you.
import java.awt.BorderLayout;
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
public class Empty extends JFrame
{
private JPanel contentPane;
/**
* Launch the application.
*/
public static void main(String[] args)
{
EventQueue.invokeLater(new Runnable()
{
public void run()
{
try
{
Empty frame = new Empty();
frame.setVisible(true);
} catch (Exception e)
{
e.printStackTrace();
}
}
});
}
/**
* Create the frame.
*/
public Empty()
{
setTitle("An empty Window");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 300, 300);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
contentPane.setLayout(new BorderLayout(0, 0));
setContentPane(contentPane);
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.