This week's book giveaway is in the General Computing forum.
We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes refreshing JFrame? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Swing / AWT / SWT
Reply Bookmark "refreshing JFrame?" Watch "refreshing JFrame?" New topic
Author

refreshing JFrame?

jeff krystyan
Greenhorn

Joined: Apr 02, 2012
Posts: 8
Hey everybody,

I have a JFrame with a grid layout on it, each grid has a button. What I'm trying to do is remove all the buttons when a button is pushed. I believe I have it correct except that the JFrame won't refresh the revised panel. Advice?

Also, I noticed on some sites that people were able to paste their code in with lined numbers to make referencing it easier. Anyone know how i can do that to make it easier on you all to read? Thanks.

John Jai
Bartender

Joined: May 31, 2011
Posts: 1778
jeff krystyan wrote:Also, I noticed on some sites that people were able to paste their code in with lined numbers to make referencing it easier. Anyone know how i can do that to make it easier on you all to read? Thanks.

You can use code tags to represent code in a better way. Please read UseCodeTags.
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 8566

Welcome to the Ranch.
Please check out the link John provide to UseCodeTags I have added them this time for you.
You will also be able to edit your post using the No need to repost

In your code, you have declared ButtonListener but never used it.
Also, after removing the buttons, call revalidate and repaint.

This question would be more suitable on the UI forums. I will move it over there for you


[Donate a pint, save a life!] [How to ask questions] [Onff-turn it on!]
jeff krystyan
Greenhorn

Joined: Apr 02, 2012
Posts: 8
thank you Maneesh,

i made those changes and it works perfectly now
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 8566

You are welcome!
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: refreshing JFrame?
 
Similar Threads
Please need help with calculator program...
problem with handling the states of the events
Mouse shift event coding - to trigger a predetermined sequence of images to a GUI
tictactoe help
Adding JButton Array to a applet issue