首页上一页 1  下一页尾页 1 条记录 1/1页
        JWindow如何自动消失
                 	
                        发表在Java答疑区
                        2020-06-17                         悬赏:2 学分
悬赏:2 学分                        
                    		
                                                                            	
                        
                        
                    
                     悬赏:2 学分
悬赏:2 学分                        
                    		
                                                                            	
                        
                        
                    
                    	是否精华
                    	是
                    	否
                    
                    
                    
                            版块置顶:
                            是
                            否
                        
                    想在文本框中输入内容时自动弹出JWindow窗体,并实时显示相关内容,但是点击其他区域,此窗体一直无法自动消失,请问如何解决?

JLabel tym = new JLabel("药品名称:",JLabel.RIGHT);
		tym.setFont(new Font("仿宋",Font.BOLD,16));
		tym.setBounds(5, 0, 90, 30);
		p4.add(tym);
		tfypmc = new JTextField(null, 12);
		tfypmc.setFont(new Font("仿宋", Font.PLAIN, 15));
		tfypmc.setBounds(87, 5, 120, 20);
		p4.add(tfypmc);
		
		tfypmc.addKeyListener(new KeyAdapter(){//为第一个输入框添加键盘监听器
			public void keyReleased(KeyEvent e){//释放某个键时调用此方法
				jw =new JWindow();
				jw.setSize(430, 200);
				jw.setLocation(tfypmc.getLocationOnScreen().x, tfypmc.getLocationOnScreen().y+20);
				
				String sql ="select * from jbdrug where (namepy like '"+'%'+tfypmc.getText()+'%'+"')";
				data = queryData(sql);
		        head=new String[] { "编号", "通 用 名", "商品名","规  格","厂家" };
		        table = new JTable(data,head);
		        table.setBorder(new LineBorder(new Color(0, 0, 0)));
		        table.setFont(new Font("宋体", Font.PLAIN, 13));  //设置表格内容字体
		        table.getColumnModel().getColumn(0).setPreferredWidth(50);  //编号
		        table.getColumnModel().getColumn(1).setPreferredWidth(120); //通用名
		        table.getColumnModel().getColumn(2).setPreferredWidth(60); //商品名
		        table.getColumnModel().getColumn(3).setPreferredWidth(80); //规格
		        table.getColumnModel().getColumn(4).setPreferredWidth(100); //厂家
		        
		        table.setRowHeight(20);  //设置表格行高;
		        table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
				
				JScrollPane jp = new JScrollPane(table);
				jw.add(jp);
				jw.setVisible(true);
				
				}
	});
 
	
                                                 VIP会员
VIP会员 购物车
购物车

 私信
                         私信 
                     
					 
					 
					 
					 
					 发表新帖
发表新帖 立即签到
立即签到 
        		  
        		 
         		 关注
关注
                  回复
 回复 支持(
                	支持( 反对(
                    反对( 
                    

 
               			  
                







 
                     
                     
					 
						 
						 
						 
						