Created
February 6, 2013 11:34
-
-
Save sivabudh/4722065 to your computer and use it in GitHub Desktop.
This file contains 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.*; | |
import java.applet.Applet; | |
public class NestedLayoutApplet extends Applet | |
{ | |
Panel southPanel; | |
Panel centerPanel; | |
TextField t; | |
public NestedLayoutApplet(){ | |
String caption = "This example shows an Applet that "+ | |
"have a bit more complex GUI"; | |
setLayout(new BorderLayout()); | |
add(new Label(caption),BorderLayout.NORTH); | |
add(new Button("-"),BorderLayout.EAST); | |
add(new Button("+"),BorderLayout.WEST); | |
southPanel = new Panel(); | |
add(southPanel,BorderLayout.SOUTH); | |
centerPanel = new Panel(); | |
add(centerPanel,BorderLayout.CENTER); | |
centerPanel.setLayout(new GridLayout(2,2,2,2)); | |
centerPanel.add(new Button("A")); | |
centerPanel.add(new Button("B")); | |
centerPanel.add(new Button("C")); | |
centerPanel.add(new Button("D")); | |
Dimension d = getSize(); | |
t = new TextField("", 30); | |
southPanel.setLayout(new FlowLayout()); | |
southPanel.add(t); | |
southPanel.add(new Button("OK")); | |
t.setText("The size of this Applet is "+ d.width+"x"+d.height); | |
} | |
public void init(){ | |
Dimension d = getSize(); | |
t.setText("The size of this Applet is "+ d.width+"x"+d.height); | |
} | |
public void paint(Graphics g){ | |
Dimension d = getSize(); | |
t.setText("The size of this Applet is "+ d.width+"x"+d.height); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment