Skip to content

Instantly share code, notes, and snippets.

@daveray
Created May 31, 2011 15:39
Show Gist options
  • Save daveray/1000703 to your computer and use it in GitHub Desktop.
Save daveray/1000703 to your computer and use it in GitHub Desktop.
setVisible
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