import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Font;
import java.awt.GridLayout;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
import javax.swing.border.Border;
import javax.swing.border.LineBorder;
import javax.swing.border.TitledBorder;
public class HW2_ShirFriedman {
/**
* @param args
*/
public static void main(String[] args) {
new ApplicationForm();
}
}
class ApplicationForm
{
ApplicationForm()
{
boolean aln=false;
//declaring the frame
JFrame frame = new JFrame("Aplication Form");
//frame settings
frame.setSize(550, 400);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setLocationRelativeTo(null); // Center the frame
frame.setAlwaysOnTop(true);
//frame.pack();
frame.setVisible(true);
frame.setLayout(new BorderLayout());
frame.setResizable(false);
//north panel
JPanel Personal_Information=new JPanel(new GridLayout(4,2,0,5));
Personal_Information.setBorder(new TitledBorder("Personal Information"));
aln=true;
Personal_Information.add(createLabel("*First name: ",Color.RED,null,aln));
Personal_Information.add(new JTextField(""));
Personal_Information.add(createLabel("*Last name: ",Color.RED,null,aln));
Personal_Information.add(new JTextField(""));
Personal_Information.add(createLabel("Adress: ",null,null,aln));
Personal_Information.add(new JTextField(""));
Personal_Information.add(createLabel("*Cellular: ",Color.RED,null,aln));
Personal_Information.add(new JTextField(""));
//attaching the north panel to the frame
frame.add(BorderLayout.NORTH,Personal_Information);
//center panel
JPanel List_of_references=new JPanel(new GridLayout(5,2));
List_of_references.setBorder(new TitledBorder("List of references"));
aln=true;
List_of_references.add(createLabel("*1: ",Color.RED,null,aln));
List_of_references.add(new JTextField(""));
List_of_references.add(createLabel("*Tel: ",Color.RED,null,aln));
List_of_references.add(new JTextField(""));
List_of_references.add(createLabel("2: ",null,null,aln));
List_of_references.add(new JTextField(""));
List_of_references.add(createLabel("Tel: ",null,null,aln));
List_of_references.add(new JTextField(""));
List_of_references.add(createLabel("3: ",null,null,aln));
List_of_references.add(new JTextField(""));
List_of_references.add(createLabel("Tel: ",null,null,aln));
List_of_references.add(new JTextField(""));
List_of_references.add(createLabel("4: ",null,null,aln));
List_of_references.add(new JTextField(""));
List_of_references.add(createLabel("Tel: ",null,null,aln));
List_of_references.add(new JTextField(""));
List_of_references.add(createLabel("5: ",null,null,aln));
List_of_references.add(new JTextField(""));
List_of_references.add(createLabel("Tel: ",null,null,aln));
List_of_references.add(new JTextField(""));
//attaching the center panel to the frame
frame.add(BorderLayout.CENTER,List_of_references);
//south panel
JPanel Programming_Languages=new JPanel(new GridLayout(2,5));
Programming_Languages.setBorder(new TitledBorder("Programming Languages"));
aln=false;
Border b=new LineBorder(Color.black,2);
Programming_Languages.add(createLabel("JAVA",null,b,aln));
Programming_Languages.add(createLabel("C",null,b,aln));
Programming_Languages.add(createLabel("C++",null,b,aln));
Programming_Languages.add(createLabel("C#",null,b,aln));
Programming_Languages.add(createLabel("Prolog",null,b,aln));
Programming_Languages.add(createLabel("",null,b,aln));
Programming_Languages.add(createLabel("",null,b,aln));
Programming_Languages.add(createLabel("",null,b,aln));
Programming_Languages.add(createLabel("",null,b,aln));
Programming_Languages.add(createLabel("",null,b,aln));
//attaching the center panel to the frame
frame.add(BorderLayout.SOUTH,Programming_Languages);
}
private JLabel createLabel(String label_name,Color c,Border b,boolean setalighright)
{
JLabel label=new JLabel(label_name);
if(setalighright)
label.setHorizontalAlignment(SwingConstants.RIGHT);
else
label.setHorizontalAlignment(SwingConstants.CENTER);
label.setForeground(c);
label.setBorder(b);
Font myFont = new Font("Times New Roman", Font.ITALIC, 15);
label.setFont(myFont);
return label;
}
}