
Michael wants to create a Java application with the following requirements: 1.Two labels representing name and age. 2.Two textboxes accepting name and age. The textbox accepting age should accept maximum 2 values. 3.A listbox representing values male and female.
Write a code which will accomplish the above mentioned task.

Java create swing frame
import java.awt.*;
import javax.swing.*;
class FrameExample
{
public static void main(String[] args)
{
JFrame f=new JFrame();
f.setLayout(null);
JLabel lab1=new JLabel("Name");
JLabel lab2=new JLabel("Age");
JLabel lab3=new JLabel("Select");
JTextField text1=new JTextField(20);
JTextField text2=new JTextField(20);
JComboBox combo=new JComboBox();
combo.addItem("Select");
combo.addItem("Male");
combo.addItem("Female");
lab1.setBounds(10,10,100,20);
text1.setBounds(120,10,100,20);
lab2.setBounds(10,40,100,20);
text2.setBounds(120,40,100,20);
lab3.setBounds(10,70,100,20);
combo.setBounds(120,70,100,20);
f.add(lab1);
f.add(text1);
f.add(lab2);
f.add(text2);
f.add(lab3);
f.add(combo);
f.setVisible(true);
f.setSize(300,150);
}
}
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.