package PbuliClass; import java.awt.Color; import java.awt.Container; import java.awt.Dimension; import java.awt.Toolkit; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.WindowEvent; import java.awt.event.WindowListener; import javax.swing.ImageIcon; import javax.swing.JDialog; import javax.swing.JPanel; import javax.swing.JTextField; import DataBase.DatabaseManagement; import Frame.AnchorManage; import Method.Bj; import Method.GetNowTime; import anchor.Anchor_Dell; public class FastAddAnc extends JDialog implements WindowListener { /** * */ private static final long serialVersionUID = 1L; JPanel mb=null; JlableModel anchorId=new JlableModel("»ùÕ¾µÄID:");//»ùÕ¾id JlableModel posx=new JlableModel("X×ø±ê(cm):");//x×ø±ê JlableModel posy=new JlableModel("Y×ø±ê(cm):");//y×ø±ê JlableModel posz=new JlableModel("Z×ø±ê(cm):");//z×ø±ê JTextField anchornum=null;//»ùÕ¾×ÜÊý JTextField anchorIdFile=null;//»ùÕ¾idÎı¾¿ò JTextField posxFile=null;//x×ø±êÎı¾¿ò JTextField posyFile=null;//y×ø±êÎı¾¿ò JTextField poszFile=null;//z×ø±êÎı¾¿ò JButtonModel sure=null;//È·¶¨°´Å¥ /**¹Ø±Õ¶Ô»°¿ò·½·¨*/ public void closeTagDialog() { this.dispose(); } /**»ñÈ¡¶Ô»°¿ò·½·¨*/ public FastAddAnc(String title) { super(); this.setAlwaysOnTop(true);//×ÜÊÇÖö¥ this.setTitle(title); Toolkit toolkit = getToolkit();// »ñµÃ´°Ì幤¾ß°ü Dimension screenSize = toolkit.getScreenSize();// »ñÈ¡ÆÁÄ»´óС int width = (int) (screenSize.width* 0.5);// ¼ÆËã´°Ìåпí¶È int height = (int) (screenSize.height * 0.5);// ¼ÆËã´°Ìåпí¶È int x0=width-200;//´°Ìåx0×ø±ê int y0=height-230;//´°Ìåy0×ø±ê Container rq=getContentPane(); rq.add(getMb()); this.setBounds(x0, y0, 450, 300); this.addWindowListener((WindowListener) this); this.setVisible(true); this.setIconImage(new ImageIcon("image/icon/versionicon.png").getImage()); } /**»ñÈ¡Ãæ°å*/ public JPanel getMb() { if(mb==null){ mb=new JPanel(); mb.setLayout(null); mb.setBackground(Color.white); int x=50; int y=30; int height=25; mb.add(anchorId); mb.add(posx); mb.add(posy); mb.add(posz); mb.add(getAnchorIdFile()); mb.add(getPosxFile()); mb.add(getPosyFile()); mb.add(getPoszFile()); mb.add(getSure()); mb.add(getAnchornum()); int x0=100; int w=230; anchorId.setBounds(x, y, x0, height); anchorIdFile.setBounds(x+x0, y,100, height); anchornum.setBounds(x+x0+110, y,w-110, height); int y1=y+25+20; posx.setBounds(x, y1, x0, height); posxFile.setBounds(x+x0, y1,w, height); int y2=y1+25+20; posy.setBounds(x, y2, x0, height); posyFile.setBounds(x+x0, y2,w, height); int y3=y2+25+20; posz.setBounds(x, y3, x0, height); poszFile.setBounds(x+x0, y3,w, height); int y4=y3+45; sure.setBounds(165, y4, 120, height); } return mb; } public JTextField getAnchorIdFile() { if(anchorIdFile==null) { anchorIdFile=new JTextField(10); } return anchorIdFile; } public JTextField getPosxFile() { if(posxFile==null) { posxFile=new JTextField(10); } return posxFile; } public JTextField getPosyFile() { if(posyFile==null) { posyFile=new JTextField(10); } return posyFile; } /**»ñÈ¡Z×ø±êµÄÎı¾¿ò*/ public JTextField getPoszFile() { if(poszFile==null) { poszFile=new JTextField(10); } return poszFile; } /**»ñȡȷ¶¨°´Å¥*/ public JButtonModel getSure() { if(sure==null) { sure=new JButtonModel("È· ¶¨"); sure.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String acr=anchorIdFile.getText(); String x=posxFile.getText(); String y=posyFile.getText(); String z=poszFile.getText(); String[] ziduan= {"anchorid","POSX","POSY","POSZ","layer","zu","liangcheng","GreateTime"}; String[] zhi= {acr,x,y,z,"0","0","65535",GetNowTime.now()}; DatabaseManagement.insertfast("tb_achor", ziduan, zhi); AnchorManage.add_new_anchor_do(acr, x, y, z, "0", "0", "65535", "","0","1","0"); Bj.setHavefas(false); int ac=Integer.parseInt(acr); Bj.setAnc(ac+1); closeTagDialog() ; } }); } return sure; } @Override public void windowOpened(WindowEvent e) { // TODO ×Ô¶¯Éú³ÉµÄ·½·¨´æ¸ù } @Override public void windowClosing(WindowEvent e) { Bj.setHavefas(false); } @Override public void windowClosed(WindowEvent e) { } @Override public void windowIconified(WindowEvent e) { // TODO ×Ô¶¯Éú³ÉµÄ·½·¨´æ¸ù } @Override public void windowDeiconified(WindowEvent e) { // TODO ×Ô¶¯Éú³ÉµÄ·½·¨´æ¸ù } @Override public void windowActivated(WindowEvent e) { // TODO ×Ô¶¯Éú³ÉµÄ·½·¨´æ¸ù } @Override public void windowDeactivated(WindowEvent e) { // TODO ×Ô¶¯Éú³ÉµÄ·½·¨´æ¸ù } public JTextField getAnchornum() { if(anchornum==null) { anchornum=new JTextField("»ùÕ¾×ÜÊý£º"+Anchor_Dell.getAnchor_vector().size()); anchornum.setEnabled(false); } return anchornum; } }