Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Swing / AWT / SWT
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
Swing / AWT / SWT
Refresh a frame
Jesse Walker
Ranch Hand
Posts: 50
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
I am trying to use a checkbox that once it is selected, that it will add a component to the frame do I need to use paint and repaint/update or is there another way??
Thank you
Jesse
Craig Wood
Ranch Hand
Posts: 1535
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
import java.awt.event.*; import javax.swing.*; public class SimpleCheck implements ActionListener { public void actionPerformed(ActionEvent e) { System.out.println("do something"); } public static void main(String[] args) { SimpleCheck test = new SimpleCheck(); JCheckBox checkBox = new JCheckBox("check box"); checkBox.addActionListener(test); JPanel north = new JPanel(); north.add(checkBox); JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.getContentPane().add(north, "First"); f.setSize(200,100); f.setLocation(200,200); f.setVisible(true); } }
Brian Cole
Author
Posts: 986
3
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Call
revalidate()
on the JPanel after you have added the new component.
bitguru blog
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
applet in frame
extends Frame help
frame properties
Size of JScrollPane in a JPanel
Not able to capture Logout
More...