如何隐藏当前的JFrameForm并启动一个新的JFrameForm

时间:2015-10-21 06:23:35

标签: java swing

无法在netbeans项目中隐藏JFrameForm。我试过了

Jframe1 p = new Jframe1();
p.setVisible(true);
this.setVisible(false);

这没有用。 我想在jtable中进行选择时启动一个新的jframe表单,并隐藏正在进行选择的当前表单。 请解释我的问题,并帮助我最简单的方法。我是java编程的新手。

我的代码 -

ListSelectionModel rowSM = jTable1.getSelectionModel();

rowSM.addListSelectionListener(new ListSelectionListener() {
    public void valueChanged(ListSelectionEvent e) {
        ListSelectionModel lsm = (ListSelectionModel) e.getSource();
        int selectedRow = lsm.getMinSelectionIndex();
        int k = selectedRow + 1;

        DefaultTableModel tma = (DefaultTableModel) Select_Album.jTable1.getModel();
           ResultSet rst=null;

        try
        {
            Connection conn=(Connection)DriverManager.getConnection("jdbc:mysql://localhost:3306/music", "root","root");
            Statement stmt1=(Statement) conn.createStatement();
            String sql1="select * from album where genreid="+k+" ;    "; 
            rst =stmt1.executeQuery(sql1);
            rst.first();

            this.setVisible(false); //error- cannot find symbol method :
                                      //setVisible(boolean) 



            Select_song p = new Select_song();
            p.setVisible(true);

            do
            {
                tma.addRow(new Object[] {rst.getInt("id"),rst.getInt("artistid"),rst.getString("name"), rst.getInt("genreid")}); 
            }while (rst.next());

            conn.close();
            stmt1.close();

        }
        catch(Exception o) 
        {
            System.out.println(o.getMessage());
        }

    }

});

0 个答案:

没有答案