Skip to content

Instantly share code, notes, and snippets.

@lhpworking
Created May 9, 2020 01:58
Show Gist options
  • Select an option

  • Save lhpworking/0d9f095485952fc6e3a3e9167910bbe9 to your computer and use it in GitHub Desktop.

Select an option

Save lhpworking/0d9f095485952fc6e3a3e9167910bbe9 to your computer and use it in GitHub Desktop.
add prisoner
package Forms;
import javax.swing.*;
import java.awt.*;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
public class Prisoners extends JFrame {
private JPanel defaultpanel;
private JLabel lbl1, lbl2, lbl3, lbl4, lbl5, lbl6, lbl7, lbl8, lbl9, lbl10, lbl11, lbl12;
private JComboBox cbb1, cbb2, cbb3, cbb4, cbb5, cbb6, cbb7, cbb8, cbb9, cbb10;
private JTextField tf1, tf2, tf3;
private JTextArea ta1;
private JRadioButton rbtn1, rbtn2;
private JButton btn1, btn2;
private String dates[]
= {"Date", "1", "2", "3", "4", "5",
"6", "7", "8", "9", "10",
"11", "12", "13", "14", "15",
"16", "17", "18", "19", "20",
"21", "22", "23", "24", "25",
"26", "27", "28", "29", "30",
"31"};
private String months[]
= {"Month", "Jan", "feb", "Mar", "Apr",
"May", "Jun", "July", "Aug",
"Sup", "Oct", "Nov", "Dec"};
private String years[]
= {"Year", "1975", "1976", "1977", "1978", "1979",
"1980", "1981", "1982", "1981", "1982",
"1983", "1984", "1986", "1986", "1987",
"1988", "1989", "1990", "1991", "1992",
"1993", "1994", "1995", "1996", "1997",
"1998", "1999", "2000", "2001", "2002",
"2003", "2004", "2005", "2006", "2007",
"2008", "2009", "2010", "2011", "2012",
"2013", "2014", "2015", "2016", "2017",
"2018", "2019", "2020"};
private String crimes[]
= {"Select", "Cướp giật", "Sát nhân", "Sử dụng chất kích thích", "Mại dâm"
};
private String punishments[]
= {"Select", "Chung thân", "Tử Hình", "Giam 1 năm tù",
"Giam 3 năm tù", "Giam 5 năm tù", "giam 10 năm tù"
};
private String districts[]
= {"Select", "Quận 1", "Quận 2", "Quận 3", "Quận 4", "Quận 5",
"Quận 5", "Quận 6", "Quận 7", "Quận 8", "Quận 9", "Quận 10",
"Quận 11", "Quận 12", "Quận Bình Tân", "Quận Bình thạnh", "Quận Gò Vấp", "Quận Phú Nhuận",
"Quận Tân Bình", "Quận Tân phú ", "Quận Thủ Đức ", "Huyện Bình Chánh", "Huyện Cần Giờ ", "Huyện Nhà Bè",
"Huyện Củ Chi", "Huyện Hóc Môn"
};
private String[] cities
= {"Select", "Tp Hồ Chí Minh", "Tp Hà Nội", "Tp Bà Rịa", "Tp Vũng Tàu",
"Tp Đà Lạt", "Tp Đà Nẵng", "Tp Hải Phòng"
};
public Prisoners(String title) throws HeadlessException {
super(title);
setLayout(null);
defaultpanel = (JPanel) getContentPane();
//init label
lbl1 = new JLabel("Prisoner Id ");
lbl1.setFont(new Font("Arial", Font.PLAIN, 20));
lbl1.setBounds(30, 10, 200, 50);
defaultpanel.add(lbl1);
lbl2 = new JLabel("Prisoner's Name ");
lbl2.setBounds(30, 50, 200, 50);
lbl2.setFont(new Font("Arial", Font.PLAIN, 20));
defaultpanel.add(lbl2);
lbl3 = new JLabel("Gender ");
lbl3.setBounds(30, 90, 200, 50);
lbl3.setFont(new Font("Arial", Font.PLAIN, 20));
defaultpanel.add(lbl3);
lbl4 = new JLabel("Phone Number ");
lbl4.setBounds(30, 130, 200, 50);
lbl4.setFont(new Font("Arial", Font.PLAIN, 20));
defaultpanel.add(lbl4);
lbl5 = new JLabel("Date Of Birth");
lbl5.setFont(new Font("Arial", Font.PLAIN, 20));
lbl5.setBounds(30, 170, 200, 50);
defaultpanel.add(lbl5);
lbl6 = new JLabel("Date Of Arrest ");
lbl6.setBounds(30, 210, 200, 50);
lbl6.setFont(new Font("Arial", Font.PLAIN, 20));
defaultpanel.add(lbl6);
lbl7 = new JLabel("Crime ");
lbl7.setBounds(30, 250, 200, 50);
lbl7.setFont(new Font("Arial", Font.PLAIN, 20));
defaultpanel.add(lbl7);
lbl8 = new JLabel("Punishment ");
lbl8.setBounds(30, 290, 200, 50);
lbl8.setFont(new Font("Arial", Font.PLAIN, 20));
defaultpanel.add(lbl8);
lbl9 = new JLabel("Address ");
lbl9.setBounds(30, 330, 200, 50);
lbl9.setFont(new Font("Arial", Font.PLAIN, 20));
defaultpanel.add(lbl9);
lbl10 = new JLabel("District ");
lbl10.setBounds(30, 450, 200, 50);
lbl10.setFont(new Font("Arial", Font.PLAIN, 20));
defaultpanel.add(lbl10);
lbl11 = new JLabel("City ");
lbl11.setBounds(30, 490, 200, 50);
lbl11.setFont(new Font("Arial", Font.PLAIN, 20));
defaultpanel.add(lbl11);
lbl12 = new JLabel();
lbl12.setBounds(550, 40, 300, 300);
lbl12.setBorder(BorderFactory.createMatteBorder(1, 1, 1, 1, Color.lightGray));
defaultpanel.add(lbl12);
//init textfield
tf1 = new JTextField();
tf1.setBounds(200, 15, 300, 40);
defaultpanel.add(tf1);
tf2 = new JTextField();
tf2.setBounds(200, 55, 300, 40);
defaultpanel.add(tf2);
tf3 = new JTextField();
tf3.setBounds(200, 135, 300, 40);
defaultpanel.add(tf3);
//init textarea
ta1 = new JTextArea();
ta1.setBounds(200, 335, 300, 120);
defaultpanel.add(ta1);
//combobox
cbb1 = new JComboBox(dates);
cbb1.setBounds(200, 170, 100, 50);
defaultpanel.add(cbb1);
cbb2 = new JComboBox(months);
cbb2.setBounds(300, 170, 100, 50);
defaultpanel.add(cbb2);
cbb3 = new JComboBox(years);
cbb3.setBounds(400, 170, 100, 50);
defaultpanel.add(cbb3);
cbb4 = new JComboBox(dates);
cbb4.setBounds(200, 210, 100, 50);
defaultpanel.add(cbb4);
cbb5 = new JComboBox(months);
cbb5.setBounds(300, 210, 100, 50);
defaultpanel.add(cbb5);
cbb6 = new JComboBox(years);
cbb6.setBounds(400, 210, 100, 50);
defaultpanel.add(cbb6);
cbb7 = new JComboBox(crimes);
cbb7.setBounds(200, 250, 300, 50);
defaultpanel.add(cbb7);
cbb8 = new JComboBox(punishments);
cbb8.setBounds(200, 290, 300, 50);
defaultpanel.add(cbb8);
cbb9 = new JComboBox(districts);
cbb9.setBounds(200, 450, 300, 50);
defaultpanel.add(cbb9);
cbb10 = new JComboBox(cities);
cbb10.setBounds(200, 490, 300, 50);
defaultpanel.add(cbb10);
// init radio button
rbtn1 = new JRadioButton("Male");
rbtn1.setBounds(250, 90, 100, 50);
defaultpanel.add(rbtn1);
rbtn2 = new JRadioButton("Female");
rbtn2.setBounds(350, 90, 100, 50);
defaultpanel.add(rbtn2);
//init button
btn1 = new JButton("Save");
btn1.setBounds(250, 550, 200, 50);
defaultpanel.add(btn1);
btn2 = new JButton("Upload Image");
btn2.setBounds(600, 350, 200, 50);
defaultpanel.add(btn2);
//=============================\\
setBounds(300, 50, 900, 700);
setVisible(true);
}
}
@lhpworking
Copy link
Author

chưa có connect

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment