import [Link].
ActionEvent;
import [Link].*;
import [Link].*;
import [Link];
import [Link];
import [Link].*;
import [Link];
public class RegistraionForm {
JFrame frame1,frame2,frame3;
JMenuBar menuBar;
JMenu menu;
JMenuItem item1,item2;
JLabel label1,label2,label3,label4,label5;
JTextField textField1,textField2,textField3,textField4;
JRadioButton radioButton1,radioButton2;
JButton button1,button2,button3;
JComboBox combo1, combo2;
Connection con;
String name,region,gender;
int id;
public RegistraionForm(){
frame1=new JFrame("Regidtration Format");
[Link](new FlowLayout());
menu=new JMenu("Menu");
item1=new JMenuItem("View Data");
item2=new JMenuItem("Delete Data");
[Link](item1);
[Link](item2);
menuBar=new JMenuBar();
[Link](menu);
[Link](menuBar);
label1=new JLabel("Your Name");
label2=new JLabel("Id");
label3=new JLabel("Gender");
label4=new JLabel("Region");
textField1=new JTextField(30);
textField2=new JTextField(30);
String region[]={"Oromia","Amhara","Tigray","Somlia","Afar","Benushangul
gumuz","Gambella","Harar","Finfinne","Dire Dawa"};
combo1=new JComboBox(region);
radioButton1=new JRadioButton("male",true);
radioButton2=new JRadioButton("female");
button1=new JButton("Register");
button2=new JButton("Reset");
ButtonGroup group=new ButtonGroup();
[Link](radioButton1);
[Link](radioButton2);
[Link](20,20,100,20);
[Link](150,20,150,20);
[Link](20,60,100,20);
[Link](150,60,150,20);
[Link](20,100,100,20);
[Link](130,100,60,20);
[Link](230,100,80,20);
[Link](20,150,80,20);
[Link](120,150,80,20);
[Link](150,100,80,20);
[Link](100,200,100,20);
[Link](220,200,100,20);
[Link](label1);
[Link](textField1);
[Link](label2);
[Link](textField2);
[Link](label3);
[Link](radioButton1);
[Link](radioButton2);
[Link](label4);
[Link](combo1);
[Link](button1);
[Link](button2);
[Link]().setLayout(null);
[Link](300,200,400,400);
[Link](400,500);
[Link](true);
[Link](new AbstractAction() {
@Override
public void actionPerformed(ActionEvent actionEvent) {
[Link]("");
[Link]("");
[Link](true);
[Link]("Oromia");
}
});
[Link](new AbstractAction() {
@Override
public void actionPerformed(ActionEvent actionEvent) {
name=[Link]();
if([Link]()){
gender="male";
}
else{
gender ="female";
}
String region=(String) [Link]();
id=[Link]([Link]());
try {
[Link]("[Link]");
con=[Link]("jdbc:derby://localhost:1527/student
registration");
Statement state=[Link]();
String insert="insert into registration values(" +id+ ",'" +name+
"','" +gender+ "','" +region+ "')";
[Link](insert);
[Link]();
} catch (ClassNotFoundException ex) {
}
catch (SQLException ex) {
}
}
});
[Link](new AbstractAction() {
@Override
public void actionPerformed(ActionEvent actionEvent) {
[Link]();
frame2=new JFrame("views of data");
String driverName = "[Link]";
String url = "jdbc:derby://localhost:1527/student registration";
String[] columnNames = {"NAME", "ID", "GENDER", "REGION"};
frame2 = new JFrame("STUDENT INFORMATION");
[Link](JFrame.EXIT_ON_CLOSE);
[Link](new BorderLayout());
//TableModel tm = new TableModel();
DefaultTableModel model = new DefaultTableModel();
[Link](columnNames);
JTable table = new JTable();
[Link](model);
[Link](JTable.AUTO_RESIZE_ALL_COLUMNS);
[Link](true);
JScrollPane scroll = new JScrollPane(table);
[Link](
JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
[Link](
JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
try
{
[Link](driverName);
Connection con = [Link](url);
String sql = "select * from registration ";
PreparedStatement ps = [Link](sql);
ResultSet rs = [Link]();
int i =0;
while([Link]()){
[Link](new Object[]{[Link](1),
[Link](2),[Link](3),[Link](4)});
}
}
catch(Exception ex)
{
[Link](null, [Link](),"Error",
JOptionPane.ERROR_MESSAGE);
}
JButton back=new JButton("back");
// [Link](back);
[Link](20,440,350,25);
[Link](back);
[Link](new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
[Link]();
RegistraionForm r=new RegistraionForm();
}
});
[Link](scroll);
[Link](true);
[Link](false);
[Link](300,200,400,400);
[Link](400,500);
}
});
[Link](new AbstractAction() {
@Override
public void actionPerformed(ActionEvent actionEvent) {
[Link]();
try {
String delete="select id from registration";
[Link]("[Link]");
con=[Link]("jdbc:derby://localhost:1527/student
registration");
Statement ps=[Link]();
ResultSet set=[Link](delete);
combo2=new JComboBox();
while([Link]()){
[Link]([Link]("id"));
} catch (ClassNotFoundException ex) {
}
catch (SQLException ex) {
JButton back=new JButton("Back");
frame3=new JFrame("Deletion page");
[Link](new FlowLayout());
label5=new JLabel("choose id u want to delete");
button3=new JButton("Delete");
[Link](20,60,150,20);
[Link](200,60,100,20);
[Link](200,150,100,20);
[Link](200,200,100,20);
[Link](label5);
[Link](combo2);
[Link](button3);
[Link](back);
[Link]().setLayout(null);
[Link](300,200,400,400);
[Link](true);
[Link](new ActionListener() {
@Override
public void actionPerformed(ActionEvent actionEvent) {
[Link]();
RegistraionForm r=new RegistraionForm();
}
});
[Link](new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
[Link]();
RegistraionForm tt=new RegistraionForm();
[Link]();
int selected=(Integer) [Link]();
[Link](selected);
try {
[Link]("[Link]");
Connection
con=[Link]("jdbc:derby://localhost:1527/student
registration");
String delete ="delete from registration where id=" +selected+ "";
Statement st=[Link]();
[Link](delete);
[Link]();
[Link](null, "deleted seccussfully");
}catch (SQLException ex) {
catch (ClassNotFoundException ex) {
}
}
});
}
});
}
public static void main(String[] args) {
// write your code here
RegistraionForm reg=new RegistraionForm();
}
}