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
Forums
Register
Login
Java
»
Swing / AWT / SWT
Refresh a frame
Jesse Walker
,
Ranch Hand
Dec 13, 2006 12:54:00
(0 cow)
(0 skulls)
+Pie
Number of slices to send:
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
Dec 13, 2006 22:46:00
(0 cow)
(0 skulls)
+Pie
Number of slices to send:
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
Dec 13, 2006 23:06:00
(0 cow)
(0 skulls)
+Pie
Number of slices to send:
Send
Call
revalidate()
on the JPanel after you have added the new component.
Post by:
autobot
I'm thinking about a new battle cry. Maybe "Not in the face! Not in the face!" Any thoughts tiny ad?
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
reply
This thread has been viewed 13386 times.
Similar Threads
applet in frame
extends Frame help
frame properties
Size of JScrollPane in a JPanel
Not able to capture Logout
More...
All times above are in ranch (not your local) time.
The current ranch time is
Mar 18, 2024 22:33:51
.