Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-21-2008, 01:04 PM
tajinvillage's Avatar
Member
 
Join Date: Jan 2008
Posts: 5
tajinvillage is on a distinguished road
close a frame..
hi every body!..
here i have a prob with my system that using java..when i click a button, it will run a frame..here i want to ask how to close the frame only without close the whole system..i have put down the coding below but it doesnt work
Quote:
this.setVisible(false)
please advise me...
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 03-21-2008, 04:47 PM
Senior Member
 
Join Date: Jul 2007
Posts: 1,124
hardwired is on a distinguished road
frame.dispose();
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 03-22-2008, 05:15 AM
tajinvillage's Avatar
Member
 
Join Date: Jan 2008
Posts: 5
tajinvillage is on a distinguished road
thanks bro..
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 04-26-2008, 07:06 PM
Member
 
Join Date: Apr 2008
Posts: 2
coolbiker is on a distinguished road
frame.dispose does not work for me any sugestions
I found this post while doing a Yahoo search and tried this with no luck it tells me I cannot set a static reference to a non static method dispose()

maybe Im setting it up the wrong way but in someway I need to have an exit button for a form for a practice test and my teachers says that dispose should work. belows the code for the button. It is a default frame using Eclipse 3.2.2 through its visual editor and 1.6_5Update of java sdk(the newest one at the time)

Code:
private JButton getJButtonexit() { if (jButtonexit == null) { jButtonexit = new JButton(); jButtonexit.setBounds(new Rectangle(267, 199, 106, 33)); jButtonexit.setText("Exit Frame"); jButtonexit.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { System.out.println("actionPerformed()"); // TODO Auto-generated Event stub actionPerformed() frame.dispose(); } }); } return jButtonexit;
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 04-26-2008, 08:24 PM
Senior Member
 
Join Date: Jul 2007
Posts: 1,124
hardwired is on a distinguished road
it tells me I cannot set a static reference to a non static method dispose
Sounds like there may be trouble with a static modifier somewhere.
I would want to look at the exact exception wording.
If I mistakenly capitalized the "frame" reference, viz, Frame.dispose(); then I'd get this compile error:
Code:
C:\jexp>javac test.java test.java:12: non-static method dispose() cannot be referenced from a static context Frame.dispose(); ^ 1 error
Code:
import java.awt.*; import java.awt.event.*; import javax.swing.*; public class Test { JFrame frame; public Test() { JButton button = new JButton("exit"); button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { frame.dispose(); } }); JPanel panel = new JPanel(); panel.add(button); frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(panel); frame.pack(); frame.setLocation(200,200); frame.setVisible(true); } public static void main(String[] args) { new Test(); } }
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 04-27-2008, 11:22 PM
Member
 
Join Date: Apr 2008
Posts: 2
coolbiker is on a distinguished road
Hardwired I seem to have found my solution for whatever Eclipse won't allow me to do "frame." and I saw some other post that simply did "setVisible(false); and just plain dispose(); I have 1_6_05 so maybe they do it differently.
Its probably like the new stuff my teacher telling us about generic functions that are supposedly not in earlier versions of Java and supposed to do allot of stuff if you can understand them under your belt.
I thank you for your response "hardwired"
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Frame close operation Java Tip Java Tips 0 12-21-2007 09:39 AM
How to close a JFrame valery New To Java 1 08-06-2007 06:33 PM
How to close JDBC Connection Heather Database 2 07-15-2007 02:07 PM
Close a JDialog Programmatically Marcus Advanced Java 1 07-06-2007 05:06 PM
What could be causing the browser to close? Marcus Java Applets 2 07-04-2007 08:26 AM


All times are GMT +3. The time now is 05:45 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org