Regístrate gratis para participar de los foros, o si ya estás registrado haz login.
| comentario del autor | Mie Ago 13, 2008 5:08 pm | |
|
import java.applet.Applet; import java.awt.*; public class UserLayout extends Applet { private Choice cb1, cb2; private Button b1, b2, b3; public void init(){ setLayout(new VLayout()); cb1 = new Choice(); cb1.addItem("Cosa 1"); cb1.addItem("Cosa 2"); cb2 = new Choice(); cb1.addItem("Opcion 1"); cb1.addItem("Opcion 2"); b1 = new Button("Boton 1"); b2 = new Button("Boton 2"); b3 = new Button("Boton 3"); add(cb1); add(b1); add(b2); add(b3); add(cb2); } } class VLayout implements LayoutManager{ public void layoutContainer(Container c) { int numberOfComponents = c.countComponents(); if (numberOfComponents > 5) numberOfComponents = 5; Insets i = c.insets(); int w = c.size().width - i.left - i.right; int h = c.size().height - i.bottom - i.top; int x = 0, y = 0; for(int j = 0; j < numberOfComponents; j++){ Component comp = c.getComponent(j); Dimension d = comp.preferredSize(); switch(j){ case 0: x = (int) (0.2 * w); y = (int) (0.25 * h); break; case 1: x = (int) (0.3 * w); y = (int) (0.5 * h); break; case 2: x = (int) (0.4 * w); y = (int) (0.75 * h); break; case 3: x = (int) (0.5 * w); y = (int) (0.5 * h); break; case 4: x = (int) (0.6 * w); y = (int) (0.25 * h); break; } comp.reshape( x, y, d.width, d.height ); } } public void addLayoutComponent(String s, Component c) {} public void removeLayoutComponent(Component c) {} public Dimension preferredLayoutSize(Container c) {return minimumLayoutSize(c);} public Dimension minimumLayoutSize(Container c) {return new Dimension(0, 0); } } public static void main( String args[] ) { UserLayout application = new UserLayout(); application.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE ); } me marca error en el main y el error me lo da en las lineas en negritas. el error que me da es: class, interface, or enum expected me marac ese error en las 2 ocasiones alguien me puede hechar la mano se lo agradeceria mucho!!!! |
||
| asistió a la solución | Mie Ago 13, 2008 5:28 pm | |
|
lo que pusiste tu!!! public static void main( String args[] ) bueno eso lo cheque con el libro y todos marcan eso!!!! y con respecto a lo otro checa tus clases y tus llaves de apertura y clausura de codigo!!!! Bueno espero que sea de ayuda!!!! |
||