// p4_jb2是一个添加面板的按钮 现在我一点就会打开一个 
 //想问下 你们通常是怎么去判断 就是点第一次打开面板 点第二下如果面板没关的话提示(已打开)如果关了就在打开总之就是打开一个就行!  
if(e.getSource()==this.p4_jb2)
{
new NewJFrame();
}

解决方案 »

  1.   

    NewJFrame frame=null;
    if(e.getSource()==this.p4_jb2)
    {
       if(frame==null||frame.isVisible()==false){
         frame=new NewJFrame();
       }else{
          return ;
        }
       
    }
      

  2.   

    把NewJFrame()设置成单子模式
    单子模式要求
    看下这个例子:package test; 
    import javax.swing.JFrame; 
    import javax.swing.JButton; 
    import java.awt.*; 
    import javax.swing.JLabel; 
    import java.awt.event.ActionEvent; 
    import java.awt.event.ActionListener; 
    //单子模式类 
    public class SingletonDemo extends JFrame { 
      //一个私有的,静态的本类对象 
        private static SingletonDemo testFrame=new SingletonDemo(); 
        JLabel jLMes = new JLabel(); 
       //构造必须是私有的,这样其它的类才不能访问 
        private SingletonDemo() { 
            getContentPane().setLayout(null);      
            this.getContentPane().add(jLMes); 
            this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); 
            jLMes.setText("这是产生的唯一窗体"); 
            jLMes.setBounds(new Rectangle(103, 53, 230, 96));       
        } 
    // 公有的静态方法返回一个本类对象 
        public static synchronized SingletonDemo getInstance()    { 
            return testFrame; 
        } 

    //测试类 
    class Test extends JFrame { 
        
         JButton jBFrame = new JButton();  
         public Test() { 
            getContentPane().setLayout(null); 
            jBFrame.setBounds(new Rectangle(125, 182, 118, 43)); 
            jBFrame.setText("单击产生唯一窗体"); 
            
      this.jBFrame.addActionListener(new MyActionListener()); 
       this.getContentPane().add(jBFrame); 
             this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); 
            this.setSize(300,200); 
            this.setVisible(true); 
        } 
        public static void main(String[] args) {  
     
            Test test = new Test(); 
        } 
         
        class MyActionListener implements ActionListener { 
          //单击按钮时调用单子模式类的静态方法,获得一个对象 
            public void actionPerformed(ActionEvent e) {  
                SingletonDemo testFrame=SingletonDemo.getInstance() ; 
                testFrame.setSize(300,200);      
                testFrame.setVisible(true);             
      
            } 
        } 

      

  3.   

    这样做 当我关闭了当前窗口时还要返回一个 false 有点麻烦!
       假如这们设置打开当前窗口就不能操作别的
       只设置当前窗口为活动窗口
      
      

  4.   

    NewJFrameif(evt.getSource()==this.jButton1)
         {
         EmpMode emp = new EmpMode();
         String sql = "insert into Accreditation values(?,?,?,?,?,?,?,?,?,?,?,?,?)";
         String str = (String) jComboBox1.getSelectedItem(); 
         String []paras={jTextField1.getText(),jTextField3.getText(),jTextField2.getText(),jTextField6.getText(),jTextField7.getText(),jTextField8.getText(),jTextField9.getText(),jTextField10.getText(),
         jTextField11.getText(),jTextField4.getText(),jTextField5.getText(),jTextArea1.getText(),str};
         if(!emp.apd(sql, paras))
         {
         JOptionPane.showMessageDialog(this,"添加失败");
    return ;
         }else{
         JOptionPane.showMessageDialog(this,"添加成功");
         this.dispose();
         }
         }
        }                                      if(e.getSource()==this.p4_jb2)
    {
    new NewJFrame();
            //下面更新jtable 我添加的但数据以经添加但就是没更新到 难道逻辑有错误。
    String []parsa= {"1"};
    em = new EmpMode();
    em.querys("select Cs_id,Confirm_name,Legal,tel,Gd_name,Gd_idcad,Zc_Capital,Gd_bili,business_Scope,Registration_adress,Status from Accreditation where 1=?", parsa);
    jtb = new JTable(em);
      

  5.   


    //上面上错了
    new NewJFrame();
    //下面更新jtable  我数据以经添加成功  就是没更新到 难道逻辑有错误。String []parsa= {"1"};
    em = new EmpMode();
    em.querys("select Cs_id,Confirm_name,Legal,tel,Gd_name,Gd_idcad,Zc_Capital,Gd_bili,business_Scope,Registration_adress,Status from Accreditation where 1=?", parsa);
    jtb.setModel(em);
      

  6.   

    KPI:(Key Performance Indicator,关键性能指标)KPI表示某一时刻某对象的性能值。KQI:(Key Quality Indicator,关键质量指标)KQI表示某对象在一段时间内多个KPI的越限率。KQI由下级KQI或KPI计算而来。KPI和KQI的关系:启动内部SLA后,U2520将采集到的数据汇聚成相应的KPI。经过时间和阈值设置,又将KPI汇聚成相应的KQI。最后经过多维度综合计算生成SLA指标。在U2520中,KPI与KQI自动关联,当用户选择KQI时,也同时选择了与KQI关联的KPI。SLA:(Service Level Agreement,服务品质协议)评估运营商提供的服务是否能达到用户期望质量的协议。SLA可以包括服务性能、解决问题时间、故障时间等。内部SLA模板:内部SLA模板是KQI的集合。U2520允许为每一类网络预先创建若干个内部户SLA模板,后续可以应用到具体的内部SLA中,简化了操作步骤。内部SLA:对于电信运营商而言,集团可以与分公司签立质量SLA合同、运营商可以与SP(Service Provider)签立质量SLA合同,这些都属于内部SLA。创建内部SLA时,需要定义评估对象及KQI。启动内部SLA后,U2520将以其为驱动,监控网络质量。