in java
make a frame and a panel that show your full name at each corner of the frame. Let the names be (MyNamePanel, MyNameFrame) and choose whatever formats you want.
my name is (lamaa khaled)
Steps:
1. Create a frame using JFrame and assign the name here.
(Import the headerfile to use JFrame)
2. Create a panel using JPanel
(Import the headerfile to use JPanel)
3. Add the frame to the panel
4. Set the size of the frame using the setSize method.
5. Add the close icon to the frame, which closes the frame when clicked
6. Finally, set the visibilty to true
Code:
import javax.swing.JFrame;
import javax.swing.JPanel;
public class Frame extends JFrame{
public static void main(String[] args) {
//Create a frame and assign the name here
JFrame frame = new JFrame("Lamaa Khaled");
//Create a Panel using JPanel
JPanel panel = new JPanel();
//Add the panel into the frame
frame.add(panel);
//Set the size of the frame using the setSize(width, height)
frame.setSize(300, 300);
//Add the close icon to the frame, which closes the frame when clicked
frame.setDefaultCloseOperation(EXIT_ON_CLOSE);
//Set the visibility to true
frame.setVisible(true);
}
}
Get Answers For Free
Most questions answered within 1 hours.