1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
/* Determine If The Button Is Visible Example This java example shows how to determine if the Button is visible or not using isVisible method. */ import java.applet.Applet; import java.awt.Graphics; import java.awt.Button; /* <applet code="DetermineIfButtonVisible" width=100 height=200> </applet> */ public class DetermineIfButtonVisible extends Applet{ boolean isButton1Visible; boolean isButton2Visible; public void init(){ //create Buttons Button Button1 = new Button("Ok"); Button Button2 = new Button("Cancel"); //add Buttons add(Button1); add(Button2); Button2.setVisible(false); /* * To determine if the Button is visible or not use * boolean isVisible() method. */ isButton1Visible = Button1.isVisible(); isButton2Visible = Button2.isVisible(); } public void paint(Graphics g){ g.drawString("Is Button 1 visible? " + isButton1Visible, 10,50); g.drawString("Is Button 2 visible? " + isButton2Visible, 10,70); } } |
Example Output
Add Comment