📄 house.java
字号:
fnump.setToolTipText("你家庭的人数");
hf4.add(fnum,BorderLayout.WEST);
hf4.add(fnump,BorderLayout.CENTER);
hf4.add(num22,BorderLayout.EAST);
fnumber1.setToolTipText("你原来住房的房号");
hf5.add(fnumber,BorderLayout.WEST);
hf5.add(fnumber1,BorderLayout.CENTER);
hf5.add(num33,BorderLayout.EAST);
ymianjishu.setToolTipText("你原来的住房面积");
hf6.add(yxuqiu,BorderLayout.WEST);
hf6.add(ymianjishu,BorderLayout.CENTER);
hf6.add(ymianji,BorderLayout.EAST);
xxmianjishu.setToolTipText("填写你想要的住房面积");
hf7.add(xxxuqiu,BorderLayout.WEST);
hf7.add(xxmianjishu,BorderLayout.CENTER);
hf7.add(xxmianji,BorderLayout.EAST);
hf8.add(hfb1,BorderLayout.CENTER);
hfb1.setToolTipText("填写正确?提交你的申请");
hfb1.addActionListener(this);
hf8.add(hfb2,BorderLayout.CENTER);
hfb2.setToolTipText("提交完毕?开始换房");
hfb1.addActionListener(this);
hfb2.addActionListener(this);
setSize(450, 350);
setVisible(true);
}
class kuaijieAction implements ActionListener {
public void actionPerformed(ActionEvent event) {
for (int i=0;i<items.length;i++)
if (event.getSource()==items[3]) {
dispose();
return;
}
else if(event.getSource()==items[0])
{
new shenqingFrame();
return;
}
else if(event.getSource()==items[1])
{
new tuifangFrame();
return;
}
else if(event.getSource()==items[2])
{
new PictureBrowse();
return;
}
}
}
public void actionPerformed(ActionEvent e){
if(e.getSource()==hfb1){
namd=dfnam21.getText();
bmd=bumen21.getText();
zcd=zc21.getText();
numd=fnump.getText();
yfhd=fnumber1.getText();
ymjd=ymianjishu.getText();
yqmjd=xxmianjishu.getText();
dfnam21.setText("");
bumen21.setText("");
zc21.setText("");
fnump.setText("");
fnumber1.setText("");
ymianjishu.setText("");
xxmianjishu.setText("");
dfsqbiao d=new dfsqbiao();
}
else if(e.getSource()==hfb2){
dfbiao df=new dfbiao();
deletedf ddf=new deletedf();
new deleteyff();
new dfsqshiFrame();
}
}
}
class tuifangFrame extends JFrame implements ActionListener{
public static String tfbm;
public static String tffh;
public static String tfmj;
JRadioButtonMenuItem items[];
JPopupMenu popupMenu;
JPanel tf1=new JPanel();
JPanel tf2=new JPanel();
JPanel tf3=new JPanel();
JPanel tf4=new JPanel();
Label tbumen2=new Label("部门");
JTextField tbumen21=new JTextField(8);
Label tfnumber=new Label("房号");
JTextField tfnumber1=new JTextField(8);
Label tfmj2=new Label("面积");
JTextField tfmj1=new JTextField(8);
JButton tfb1=new JButton("确定");
JButton tfb2=new JButton("退房");
public tuifangFrame(){
kuaijieAction action = new kuaijieAction();
String[] str = {"申请住房","调换住房","查看图片","返回"};
ButtonGroup kuaijieGroup=new ButtonGroup();
popupMenu=new JPopupMenu();
items=new JRadioButtonMenuItem[4];
for (int i=0;i<items.length;i++) {
items[i]=new JRadioButtonMenuItem(str[i]);
popupMenu.add(items[i]);
kuaijieGroup.add(items[i]);
items[i].addActionListener(action);
}
addMouseListener(new MouseAdapter(){
public void mousePressed( MouseEvent event ) {
triggerEvent(event);
}
public void mouseReleased( MouseEvent event ) {
triggerEvent(event);
}
private void triggerEvent(MouseEvent event) {
if (event.isPopupTrigger())
popupMenu.show(event.getComponent(),event.getX(),event.getY());
}
});
setTitle("退房");
setLocation(200,150);
setLayout(new GridLayout(4,1));
add(tf1);
add(tf2);
add(tf3);
add(tf4);
tbumen21.setToolTipText("输入你所在的部门");
tf1.add(tbumen2,BorderLayout.WEST);
tf1.add(tbumen21,BorderLayout.CENTER);
tfnumber1.setToolTipText("你的住房号");
tf2.add(tfnumber,BorderLayout.WEST);
tf2.add(tfnumber1,BorderLayout.EAST);
tfmj1.setToolTipText("你所在的住房的面积");
tf3.add(tfmj2,BorderLayout.WEST);
tf3.add(tfmj1,BorderLayout.CENTER);
tf4.add(tfb1,BorderLayout.CENTER);
tfb1.setToolTipText("填写正确?提交你的申请");
tf4.add(tfb2,BorderLayout.CENTER);
tfb2.setToolTipText("提交完毕?开始退房");
tfb1.addActionListener(this);
tfb2.addActionListener(this);
setSize(350, 150);
setVisible(true);
}
class kuaijieAction implements ActionListener {
public void actionPerformed(ActionEvent event) {
for (int i=0;i<items.length;i++)
if (event.getSource()==items[0]) {
new shenqingFrame();
return;
}
else if(event.getSource()==items[1])
{
new huanfangFrame();
return;
}
else if(event.getSource()==items[3])
{
dispose();
return;
}
else if(event.getSource()==items[2])
{
new PictureBrowse();
return;
}}}
public void actionPerformed(ActionEvent t){
if(t.getSource()==tfb1){
tfbm=tbumen21.getText();
tffh=tfnumber1.getText();
tfmj=tfmj1.getText();
tbumen21.setText("");
tfnumber1.setText("");
tfmj1.setText("");
}
else if(t.getSource()==tfb2){
new tfbiao();
}
}
}
class PictureBrowse extends JFrame implements ActionListener,ItemListener{
String fname[]={"2.jpg","3.jpg","4.jpg","5.jpg","6.jpg","7.jpg"};
Browse pp;
JPanel p1=new JPanel();
JPanel p2=new JPanel();
JButton prev=new JButton("上页");
JButton next=new JButton("下页");
JButton first=new JButton("首页");
JButton last=new JButton("尾页");
JComboBox comb=new JComboBox(fname);
int n=0;
public PictureBrowse() {
setSize(800, 600);
setTitle("图片浏览程序");
pp=new Browse(fname);
p2.add(prev);p2.add(next);p2.add(first);p2.add(last);p2.add(comb);
next.addActionListener(this);
prev.addActionListener(this);
first.addActionListener(this);
last.addActionListener(this);
comb.addItemListener(this);
p1.setLayout(new FlowLayout(FlowLayout.LEFT));
p1.add(pp);
this.getContentPane().add(pp,"Center");
this.getContentPane().add(p2,"South");
setVisible(true);
}
public void itemStateChanged(ItemEvent e){
pp.dd.show(pp,(String)comb.getSelectedItem());
}
public void actionPerformed(ActionEvent e){
int total=fname.length;
if(e.getSource()==next){pp.dd.next(pp);n=(n+1)%total;}
else if(e.getSource()==prev){pp.dd.previous(pp);n=(n-1+total)%total;}
else if(e.getSource()==first){pp.dd.first(pp);n=0;}
else if(e.getSource()==last){pp.dd.last(pp);n=total;}
}
public static void main(String args[]) {
JFrame.setDefaultLookAndFeelDecorated(true);
Font font = new Font("JFrame", Font.PLAIN, 14);
Enumeration keys = UIManager.getLookAndFeelDefaults().keys();
while (keys.hasMoreElements()) {
Object key = keys.nextElement();
if (UIManager.get(key) instanceof Font)UIManager.put(key, font);
}
PictureBrowse mainFrame = new PictureBrowse();
}
}
class Browse extends JPanel {
CardLayout dd=new CardLayout();
boolean f=false;
Picture pic;
Browse(String fname[]){
setLayout(dd);
for(int i=0;i<fname.length;i++){
pic=new Picture(fname[i]);
add(fname[i],new JScrollPane(pic));
}
}
}
class Picture extends JPanel{
Image im;
MediaTracker tracker=new MediaTracker(this);
Picture(String fname){
Toolkit tool=Toolkit.getDefaultToolkit();//建立Toolkit对象
im=tool.getImage(fname); //使用Toolkit对象打开图像
tracker.addImage(im,0); //进行跟踪
try{
tracker.waitForAll();
}catch(InterruptedException e){}
this.setPreferredSize(new Dimension(im.getWidth(this),im.getHeight(this)));
}
public void paintComponent(Graphics g){
g.drawImage(im,0,0,this);
}
}
class sqbiao
{
public sqbiao()
{
String bms1= shenqingFrame.bms;
String zcs1= shenqingFrame.zcs;
String nams1= shenqingFrame.nams;
String nums1= shenqingFrame.nums;
String mjs1= shenqingFrame.mjs;
try {
Statement stmt;
PreparedStatement pstmt;
ResultSet rs;
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String url = "jdbc:odbc:AADSN";
Connection con = DriverManager.getConnection (url,"System","sys");
pstmt=con.prepareStatement("INSERT INTO yff_tj ("
+ "bumensq,zcsq,name,numsq,mjsq,zfjf) VALUES(?,?,?,?,?,?)");
String sqbm=bms1;
String sqnam=nams1;
try{
Integer sqzc=Integer.parseInt(zcs1);
Integer sqnum=Integer.parseInt(nums1);
Integer sqmj=Integer.parseInt(mjs1);
Integer sqjf=(sqzc*sqnum+4);
pstmt.setString(1,sqbm);
pstmt.setInt(2,sqzc);
pstmt.setString(3,sqnam);
pstmt.setInt(4,sqnum);
pstmt.setInt(5,sqmj);
pstmt.setInt(6,sqjf);
pstmt.execute();
}catch(NumberFormatException q)
{
q.printStackTrace();
}
con.close(); //关闭与数据库的连接
}catch( Exception e ) {
e.printStackTrace();
}
}
}
class tjsqbiao
{
String bumenhf1;
int zchf1;
String namhf1;
int numhf1;
int ymjhf1;
int zfjf1;
public tjsqbiao()
{
try {
Statement stmt;
PreparedStatement pstmt;
ResultSet rs;
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String url = "jdbc:odbc:AADSN";
Connection con = DriverManager.getConnection (url,"System","sys");
stmt=con.createStatement();
rs = stmt.executeQuery("SELECT * from yff_tj order by zfjf DESC");
while(rs.next())
{
bumenhf1 = rs.getString("bumensq");
zchf1= rs.getInt("zcsq");
namhf1=rs.getString("name");
numhf1= rs.getInt("numsq");
ymjhf1= rs.getInt("mjsq");
zfjf1=rs.getInt("zfjf");
pstmt=con.prepareStatement("INSERT INTO tjsqbiao VALUES(?,?,?,?,?,?)");
pstmt.setString(1,bumenhf1);
pstmt.setInt(2,zchf1);
pstmt.setString(3,namhf1);
pstmt.setInt(4,numhf1);
pstmt.setInt(5,ymjhf1);
pstmt.setInt(6,zfjf1);
pstmt.executeUpdate();
}
con.close(); //关闭与数据库的连接
}catch( Exception e ) {
e.printStackTrace();
}
}
}
class fenfang{
String yffbm;
int yffzc;
public static String yffnam;
int yffnum;
int yffmj;
int yffjf;
public static int yfffh;
int yffmji;
int i;
String delnam;
public fenfang(){
try {
Statement stmt;
Statement stmt1;
PreparedStatement pstmt;
PreparedStatement pstmt1;
PreparedStatement pstmt2;
PreparedStatement pstmt3;
PreparedStatement pstmt4;
ResultSet rs;
ResultSet rs1;
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String url = "jdbc:odbc:AADSN";
Connection con = DriverManager.getConnection (url,"System","sys");
stmt=con.createStatement();
rs = stmt.executeQuery("SELECT DISTINCT * from tjsqbiao order by zfjf DESC");
while(rs.next())
{
yffbm=rs.getString("bumensq");
yffzc=rs.getInt("zcsq");
yffnam=rs.getString("name");
System.out.println(yffnam);
yffnum=rs.getInt("numsq");
yffmj= rs.getInt("mjsq");
yffjf= rs.getInt("zfjf");
// rs1=stmt.executeQuery("select * from kfwenjian where mianj='"+yffmj+"' and zdjifen<'"+yffjf+"'");
String sql = "select * from kfwenjian where mianj=? and zdjifen<?";
pstmt2=con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
pstmt2.setInt(1,yffmj);
pstmt2.setInt(2,yffjf);
rs1=pstmt2.executeQuery();
i=0;
while(rs1.next()){
//System.out.println("dasfasf");
//yfffh=yfffh1;
// yffmji=yffmji1;
System.out.println("fffffffffffff");
i++;
if(i==1){
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -