Created
May 31, 2011 15:39
-
-
Save daveray/1000703 to your computer and use it in GitHub Desktop.
setVisible
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.awt.BorderLayout; | |
import java.awt.event.MouseAdapter; | |
import java.awt.event.MouseEvent; | |
import javax.swing.JButton; | |
import javax.swing.JFrame; | |
import javax.swing.JPanel; | |
public class VisibleButton { | |
public static void main(String[] args) { | |
final JFrame f = new JFrame(); | |
f.setSize(800, 600); | |
final JPanel p = new JPanel(new BorderLayout()); | |
final JButton bottom = new JButton("BYE"); | |
final JButton top = new JButton("HI"); | |
top.addMouseListener(new MouseAdapter() { | |
@Override | |
public void mouseClicked(MouseEvent e) { | |
bottom.setVisible(true); | |
} | |
}); | |
p.add(top, BorderLayout.NORTH); | |
bottom.setVisible(false); | |
p.add(bottom, BorderLayout.SOUTH); | |
f.setContentPane(p); | |
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); | |
f.setVisible(true); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment