/* Class aaa not found in new */zzz.java import java.awt.*; import java.applet.*; public class zzz extends Applet { public void init() { setLayout(new aaa()); } }
aaa.java
/* Error: can't subclass interfaces:interface java.awt.LayoutManager */import java.awt.*; import java.applet.*; class aaa extends LayoutManager { }
aaa.java
/* Error: 5 errors */import java.awt.*; import java.applet.*; class aaa implements LayoutManager { }
zzz.java
/* Class aaa not found in new */import java.awt.*; import java.applet.*; public class zzz extends Applet { public void init() { setLayout(new aaa()); add((new Button("Hell"); add(new Button("Hello how are you"); add (new TextField("hi",20); } }
aaa.java
import java.awt.*; import java.applet.*; class aaa implements LayoutManager { public void layoutContainer(Container p) { System.out.println("In layoutContainer"); } public Dimension minimumLayoutSize(Container p) { System.out.println("In minimumLayoutSize"); return (new Dimension(200,300)); } public Dimension preferredLayoutSize(Container p) { System.out.println("In preferredLayoutSize"); Dimension d = new Dimension(200,40); return d; } public void addLayoutComponent(String n, Component c) { System.out.println("In addLayoutComponent"); } public void removeLayoutComponent(Component c) { System.out.println("In removeLayoutComponent" ); } }
aaa.java
import java.awt.*; import java.applet.*; class aaa implements LayoutManager { public void layoutContainer(Container p) { System.out.println("In layoutContainer"); System.out.println(p.countComponents()); Component c = p.getComponent(0); c.list(); Dimension d = c.preferredSize(); System.out.println("width "+ d.width + "height "+d.height); } public Dimension minimumLayoutSize(Container p) { System.out.println("In minimumLayoutSize"); return (new Dimension(200,300)); } public Dimension preferredLayoutSize(Container p) { System.out.println("In preferredLayoutSize"); Dimension d = new Dimension(200,40); return d; } public void addLayoutComponent(String n, Component c) { System.out.println("In addLayoutComponent"); } public void removeLayoutComponent(Component c) { System.out.println("In removeLayoutComponent" ); } }
aaa.java
import java.awt.*; import java.applet.*; class aaa implements LayoutManager { public void layoutContainer(Container p) { System.out.println("In layoutContainer"); Component c = p.getComponent(0); Dimension d = c.preferredSize(); c.reshape(1,30,d.width,d.height); } public Dimension minimumLayoutSize(Container p) { System.out.println("In minimumLayoutSize"); return (new Dimension(200,300)); } public Dimension preferredLayoutSize(Container p) { System.out.println("In preferredLayoutSize"); Dimension d = new Dimension(200,40); return d; } public void addLayoutComponent(String n, Component c) { System.out.println("In addLayoutComponent"); } public void removeLayoutComponent(Component c) { System.out.println("In removeLayoutComponent" ); } }
aaa.java
import java.awt.*; import java.applet.*; class aaa implements LayoutManager { public void layoutContainer(Container p) { System.out.println("In layoutContainer"); int n = p.countComponents(); int i; int x = 1;int y = 10; for ( i = 0; i< n; i++ ) { Component c = p.getComponent(i); Dimension d = c.preferredSize(); c.reshape(x,y,d.width,d.height); x=x+d.width+10; y = y+d.height+10; } } public Dimension minimumLayoutSize(Container p) { System.out.println("In minimumLayoutSize"); return (new Dimension(200,300)); } public Dimension preferredLayoutSize(Container p) { System.out.println("In preferredLayoutSize"); Dimension d = new Dimension(200,40); return d; } public void addLayoutComponent(String n, Component c) { System.out.println("In addLayoutComponent"); } public void removeLayoutComponent(Component c) { System.out.println("In removeLayoutComponent" ); } }
zzz.java
import java.awt.*; import java.applet.*; public class zzz extends Applet { Button a,b;TextField c; public void init() { setLayout(new aaa()); add(a=new Button("hell")); add(b=new Button("hello how are you")); add(c=new TextField("hell",60)); } public boolean mouseUp(Event e, int x, int y) { remove(a); return true; } }
zzz.java
import java.awt.*; import java.applet.*; public class zzz extends Applet { Button a,b;TextField c; public void init() { setLayout(new aaa()); add(a=new Button("hell")); add(b=new Button("hello how are you")); add(c=new TextField("hell",60)); } public boolean mouseUp(Event e, int x, int y) { remove(a); add("Good",new Button("aaa")); return true; } } /* For the first time the button with helllabel is removed from the screen, and a new button added, but the screen has to be redrawn Next time when clicked, only button added */
aaa.java
import java.awt.*; import java.applet.*; public class aaa implements LayoutManager { Container t; int n; int i,x,y; Component c;Dimension d; public void layoutContainer(Container p) { t = p; n = p.countComponents(); System.out.println("layoutContainer no =" + n); i=0;x = 1;y = 10; for (i=0;i