LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-21-2006, 07:33 AM   #1
trscookie
Member
 
Registered: Apr 2004
Location: oxford
Distribution: gentoo
Posts: 463

Rep: Reputation: 30
how to hide java netbeans forms


hello all im trying to use netbeans to design my forms im not using swing ive got a form but how do i despose of it?:


Code:
package forms;
public class form_one extends javax.swing.JFrame {
    public form_one() {
        initComponents();
    }

    private void initComponents() {
        jButton1 = new javax.swing.JButton();

        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                exitForm(evt);
            }
        });

        jButton1.setText("jButton1");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        getContentPane().add(jButton1, java.awt.BorderLayout.CENTER);

        pack();
    }
    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
        form_two frmTwo = new form_two();
        frmTwo.setVisible( true );
    }
    private void exitForm(java.awt.event.WindowEvent evt) {
        System.exit(0);
    }
    public static void main(String args[]) {
        new form_one().show();
    }
    // Variables declaration - do not modify
    private javax.swing.JButton jButton1;
    // End of variables declaration
}

what i want to do is destroy the current form frm_one. its bugging the hell out of me! please help.
 
Old 04-21-2006, 11:52 AM   #2
mrcheeks
Senior Member
 
Registered: Mar 2004
Location: far enough
Distribution: OS X 10.6.7
Posts: 1,690

Rep: Reputation: 52
If you want to hide the form frm_one do :
Code:
frm_one.setVisible(false);
If you do not want the frm_one to appear at all remove the line
Code:
new form_one().show();
in the mehod
Code:
public static void main(String args[])
 
Old 04-21-2006, 12:13 PM   #3
trscookie
Member
 
Registered: Apr 2004
Location: oxford
Distribution: gentoo
Posts: 463

Original Poster
Rep: Reputation: 30
when i change the code in the jbutton from this:

Code:
    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
        form_two frmTwo = new form_two();
        frmTwo.setVisible( true );
    }
to this:

Code:
    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
        form_two frmTwo = new form_two();
        frmTwo.setVisible( true );
        
        form_one.setVisible( false );
    }
this is the error that i get!?:

Code:
forms/form_one.java [30:1] non-static method setVisible(boolean) cannot be referenced from a static context
        form_one.setVisible( false );
                ^
1 error
Errors compiling form_one.
i understand that its because the creation of the form_one is in the scope of this fuction so how do i get the button to recognise form_one? cheers again.
 
Old 04-21-2006, 01:04 PM   #4
mrcheeks
Senior Member
 
Registered: Mar 2004
Location: far enough
Distribution: OS X 10.6.7
Posts: 1,690

Rep: Reputation: 52
Maybe you should do
Code:
this.setVisible(false);
because you cannot call directly setVisible without an object like this :
Code:
form_one frm = new form_one();
frm.setVisible(false);
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Installing Java and Netbeans Bundle oookiezooo Linux - Newbie 4 01-25-2006 05:21 PM
Enabe Netbeans with Java Tiger (1.5) trumpetdork Programming 6 05-01-2005 02:56 PM
Adding a java module to netbeans Setheck Linux - Software 0 03-28-2005 09:55 PM
Java: Netbeans IDE question ludeKing Programming 0 09-01-2004 09:20 AM
installing netbeans/java cobundle? guitarnix Linux - Software 4 12-17-2003 06:44 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:07 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration