Results 1 to 5 of 5
- 10-28-2011, 07:07 PM #1
Member
- Join Date
- Oct 2011
- Posts
- 4
- Rep Power
- 0
dispose() gives an "invalid method declaration"
Hello everyone. I am new to Java and struggling a bit my way through it. My current problem is, I have created a custom MessageBox. But when I want to close/dispose it I am getting the error above. Would appreciate if anyone could give me an advice.
Thanks.
Java Code:public class CstMsgBox extends javax.swing.JDialog { /** Creates new form CstMsgBox */ public CstMsgBox(java.awt.Frame parent, boolean modal, String labeFiller) { super(parent, modal); initComponents(); } public void displayCstMsgBox() { this.setVisible(true); } . . . // when pressing the OK button, MessageBox should disappear private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: } /** * @param args the command line arguments */ dispose(); // Variables declaration - do not modify private javax.swing.JButton jButton1; private javax.swing.JLabel jLabel1; // End of variables declaration }
- 10-28-2011, 07:47 PM #2
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,375
- Blog Entries
- 7
- Rep Power
- 17
Re: dispose() gives an "invalid method declaration"
Carefully check your curly brackets: the dispose() method call isn't in a body of any method.
kind regards,
JosWhen people rob a bank they get a penalty; when banks rob people they get a bonus.
- 10-28-2011, 08:03 PM #3
Member
- Join Date
- Oct 2011
- Posts
- 4
- Rep Power
- 0
Re: dispose() gives an "invalid method declaration"
Thanks for help, but I still have some troubles. I thought dispose() has the same function as setVisible(false), additionally setting ressources free, which have been used by frame. But my window/MsgBox doesn't disappear, do I have to use setVisible too?
thanks
- 10-28-2011, 08:15 PM #4
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,375
- Blog Entries
- 7
- Rep Power
- 17
- 10-28-2011, 08:25 PM #5
Member
- Join Date
- Oct 2011
- Posts
- 4
- Rep Power
- 0
Re: dispose() gives an "invalid method declaration"
Hmm, I am a bit confused, here what I've got.
Java Code:public class CstMsgBox extends javax.swing.JDialog { /** Creates new form CstMsgBox */ public CstMsgBox(java.awt.Frame parent, boolean modal, String labeFiller) { super(parent, modal); initComponents(); } public void displayCstMsgBox(String labelFiller) { CstOKLabel.setText(labelFiller); this.setVisible(true); } ... } private void CstOKButtonActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: } /** * @param args the command line arguments */ // Close MessageBox public void hideCstMsgBox() { this.dispose(); } . . } //Calling my MsgBox CstMsgBox box = new CstMsgBox(null,true,"Read Successful"); box.displayCstMsgBox("Read Successful");
Similar Threads
-
"invalid command line parameter" error
By MCinPgh in forum EclipseReplies: 1Last Post: 09-09-2011, 09:03 PM -
Error: "Invalid character constant"
By Turk80 in forum New To JavaReplies: 3Last Post: 04-06-2011, 08:53 AM -
java.sql.SQLException: ORA-00904: "PASS1": invalid identifier
By vishal.jar in forum JDBCReplies: 3Last Post: 01-31-2011, 09:46 AM -
"not a statement" error to array declaration
By SpaceMonkey in forum New To JavaReplies: 3Last Post: 11-25-2010, 11:01 PM -
the dollar sign "$", prints like any other normal char in java like "a" or "*" ?
By lse123 in forum New To JavaReplies: 1Last Post: 10-20-2008, 07:35 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks